-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
bbilger
committed
Dec 6, 2016
1 parent
44c4e65
commit 6e31ae8
Showing
10 changed files
with
127 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ws-core/src/test/java/com/jrestless/aws/security/CognitoUserPoolAuthorizerClaimsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.jrestless.aws.security; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import org.junit.Test; | ||
|
||
public class CognitoUserPoolAuthorizerClaimsTest { | ||
|
||
@Test | ||
public void getName_PrincipalIdInClaimsGiven_ShouldReturnPrincipalIdFromClaims() { | ||
CognitoUserPoolAuthorizerClaims claims = mock(CognitoUserPoolAuthorizerClaims.class); | ||
when(claims.getClaim("cognito:username")).thenReturn("someCognitoUsernameValue"); | ||
when(claims.getCognitoUserName()).thenCallRealMethod(); | ||
assertEquals("someCognitoUsernameValue", claims.getCognitoUserName()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...core/src/test/java/com/jrestless/aws/security/CognitoUserPoolAuthorizerPrincipalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.jrestless.aws.security; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import org.junit.Test; | ||
|
||
public class CognitoUserPoolAuthorizerPrincipalTest { | ||
|
||
@Test | ||
public void getName_SubInClaimsGiven_ShouldReturnSubFromClaims() { | ||
CognitoUserPoolAuthorizerPrincipal principal = mock(CognitoUserPoolAuthorizerPrincipal.class); | ||
CognitoUserPoolAuthorizerClaims claims = mock(CognitoUserPoolAuthorizerClaims.class); | ||
when(claims.getSub()).thenReturn("someSubValue"); | ||
when(principal.getClaims()).thenReturn(claims); | ||
when(principal.getName()).thenCallRealMethod(); | ||
assertEquals("someSubValue", principal.getName()); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...less-aws-core/src/test/java/com/jrestless/aws/security/CustomAuthorizerPrincipalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.jrestless.aws.security; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import org.junit.Test; | ||
|
||
public class CustomAuthorizerPrincipalTest { | ||
@Test | ||
public void getName_PrincipalIdInClaimsGiven_ShouldReturnPrincipalIdFromClaims() { | ||
CustomAuthorizerPrincipal principal = mock(CustomAuthorizerPrincipal.class); | ||
CustomAuthorizerClaims claims = mock(CustomAuthorizerClaims.class); | ||
when(claims.getPrincipalId()).thenReturn("somePrincipalId"); | ||
when(principal.getClaims()).thenReturn(claims); | ||
when(principal.getName()).thenCallRealMethod(); | ||
assertEquals("somePrincipalId", principal.getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters