Skip to content

Commit

Permalink
Merge branch 'main' into snyk-upgrade-4b20f466e87cbecfd4adbd81bf5f6f40
Browse files Browse the repository at this point in the history
  • Loading branch information
smirnovaae authored Oct 24, 2024
2 parents a1b10b1 + 93566e9 commit 2cd4a00
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<properties>
<project.root>${basedir}/..</project.root>
<springfox.version>3.0.0</springfox.version>
<okta-jwt.version>0.5.8</okta-jwt.version>
<okta-jwt.version>0.5.10</okta-jwt.version>
<sonar.coverage.exclusions>**/JobClient.java</sonar.coverage.exclusions>
<!--
- AB2D-6099 -
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package gov.cms.ab2d.api.security;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.junit.jupiter.api.Test;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import gov.cms.ab2d.common.model.PdpClient;
import gov.cms.ab2d.common.repository.PdpClientRepository;

class CustomUserDetailsServiceTest {

@Test
void testLoadUserByUsername1() {
PdpClientRepository pdpClientRepository = mock(PdpClientRepository.class);
CustomUserDetailsService customUserDetailsService = new CustomUserDetailsService(pdpClientRepository);
PdpClient pdpClient = new PdpClient();
when(pdpClientRepository.findByClientId("clientId")).thenReturn(pdpClient);
assertEquals(
customUserDetailsService.loadUserByUsername("clientId"),
pdpClient
);
}

@Test
void testLoadUserByUsername2() {
PdpClientRepository pdpClientRepository = mock(PdpClientRepository.class);
CustomUserDetailsService customUserDetailsService = new CustomUserDetailsService(pdpClientRepository);
when(pdpClientRepository.findByClientId(null)).thenReturn(null);
assertThrows(
UsernameNotFoundException.class,
() -> {customUserDetailsService.loadUserByUsername(null);}
);
}

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<checkstyle.config>${project.root}/src/main/resources/checkstyle.xml</checkstyle.config>
<logback-encoder.version>7.3</logback-encoder.version>
<testcontainers.version>1.18.3</testcontainers.version>
<newrelic.version>8.4.0</newrelic.version>
<newrelic.version>8.15.0</newrelic.version>
<postgres.version>42.7.3</postgres.version>
<spring-cloud-aws.version>2.4.4</spring-cloud-aws.version>

Expand Down

0 comments on commit 2cd4a00

Please sign in to comment.