-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scim_id attribute for oidc tokens (#1010)
- Loading branch information
Showing
6 changed files
with
24 additions
and
23 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,7 @@ public void createIasToken_isNotNull() { | |
.withClaimValue("last_name", "doe") | ||
.withClaimValue("email", "[email protected]") | ||
.withClaimValue(SAP_GLOBAL_USER_ID, "1234567890") | ||
.withClaimValue(SAP_GLOBAL_SCIM_ID, "scim-1234567890") | ||
.withPrivateKey(keys.getPrivate()); | ||
Token token = cut.createToken(); | ||
|
||
|
@@ -100,6 +101,7 @@ public void createIasToken_isNotNull() { | |
assertThat(token.getClientId()).isEqualTo("T000310"); | ||
assertThat(token.getExpiration()).isEqualTo(JwtGenerator.NO_EXPIRE_DATE); | ||
assertThat(token.getClaimAsString(SAP_GLOBAL_USER_ID)).isEqualTo("1234567890"); | ||
assertThat(token.getClaimAsString(SAP_GLOBAL_SCIM_ID)).isEqualTo("scim-1234567890"); | ||
assertThat(token.getPrincipal().getName()).isEqualTo("1234567890"); | ||
String encodedModulusN = Base64.getUrlEncoder() | ||
.encodeToString(((RSAPublicKey) keys.getPublic()).getModulus().toByteArray()); | ||
|
@@ -297,7 +299,7 @@ public void loadClaimsFromFile_doesNotContainValidJson_throwsException() throws | |
} | ||
|
||
@Test | ||
public void loadClaimsFromFile_containsStringClaims() throws IOException { | ||
public void loadClaimsFromFile_containsStringClaims() { | ||
final Token token = cut.withClaimsFromFile("/claims.json").createToken(); | ||
|
||
assertThat(token.getClaimAsString(EMAIL)).isEqualTo("[email protected]"); | ||
|
@@ -306,14 +308,14 @@ public void loadClaimsFromFile_containsStringClaims() throws IOException { | |
} | ||
|
||
@Test | ||
public void loadClaimsFromFile_containsExpirationClaim() throws IOException { | ||
public void loadClaimsFromFile_containsExpirationClaim() { | ||
final Token token = cut.withClaimsFromFile("/claims.json").createToken(); | ||
|
||
assertThat(token.getExpiration()).isEqualTo(Instant.ofEpochSecond(1542416800)); | ||
} | ||
|
||
@Test | ||
public void loadClaimsFromFile_containsJsonObjectClaims() throws IOException { | ||
public void loadClaimsFromFile_containsJsonObjectClaims() { | ||
final Token token = cut.withClaimsFromFile("/claims.json").createToken(); | ||
|
||
JsonObject externalAttributes = token.getClaimAsJsonObject("ext_attr"); | ||
|
@@ -324,7 +326,7 @@ public void loadClaimsFromFile_containsJsonObjectClaims() throws IOException { | |
} | ||
|
||
@Test | ||
public void loadClaimsFromFile_containsListClaims() throws IOException { | ||
public void loadClaimsFromFile_containsListClaims() { | ||
final Token token = cut.withClaimsFromFile("/claims.json").createToken(); | ||
|
||
assertThat(token.getClaimAsStringList(TokenClaims.XSUAA.SCOPES)) | ||
|
@@ -333,7 +335,7 @@ public void loadClaimsFromFile_containsListClaims() throws IOException { | |
} | ||
|
||
@Test | ||
public void getInstanceFromFile_overridesTokenPropertiesForTesting() throws IOException { | ||
public void getInstanceFromFile_overridesTokenPropertiesForTesting() { | ||
Token token = JwtGenerator.getInstanceFromFile(XSUAA, "/token.json") | ||
.createToken(); | ||
|
||
|
@@ -342,7 +344,7 @@ public void getInstanceFromFile_overridesTokenPropertiesForTesting() throws IOEx | |
} | ||
|
||
@Test | ||
public void getInstanceFromFile_loadsJsonData() throws IOException { | ||
public void getInstanceFromFile_loadsJsonData() { | ||
Token token = JwtGenerator.getInstanceFromFile(XSUAA, "/token.json") | ||
.createToken(); | ||
|
||
|
@@ -355,15 +357,15 @@ public void getInstanceFromFile_loadsJsonData() throws IOException { | |
} | ||
|
||
@Test | ||
public void getInstanceFromFile_noHeader_noErrorAndReadsPayload() throws IOException { | ||
public void getInstanceFromFile_noHeader_noErrorAndReadsPayload() { | ||
Token token = JwtGenerator.getInstanceFromFile(XSUAA, "/token_no_header.json") | ||
.createToken(); | ||
|
||
assertThat(token.getClaimAsString(TokenClaims.XSUAA.ZONE_ID)).isEqualTo("zone-id"); | ||
} | ||
|
||
@Test | ||
public void getInstanceFromFile_invalidAlg_throwsException() throws IOException { | ||
public void getInstanceFromFile_invalidAlg_throwsException() { | ||
assertThatThrownBy(() -> JwtGenerator.getInstanceFromFile(XSUAA, "/token_invalid_alg.json")) | ||
.isInstanceOf(UnsupportedOperationException.class); | ||
} | ||
|
@@ -385,23 +387,23 @@ public void createToken_signatureCalculation_NoSuchAlgorithmExceptionTurnedIntoR | |
JwtGenerator instance = JwtGenerator.getInstance(XSUAA, (key, alg, data) -> { | ||
throw new NoSuchAlgorithmException(); | ||
}); | ||
assertThatThrownBy(() -> instance.createToken()).isInstanceOf(RuntimeException.class); | ||
assertThatThrownBy(instance::createToken).isInstanceOf(RuntimeException.class); | ||
} | ||
|
||
@Test | ||
public void createToken_signatureCalculation_SignatureExceptionTurnedIntoRuntimeException() { | ||
JwtGenerator instance = JwtGenerator.getInstance(XSUAA, (key, alg, data) -> { | ||
throw new SignatureException(); | ||
}); | ||
assertThatThrownBy(() -> instance.createToken()).isInstanceOf(RuntimeException.class); | ||
assertThatThrownBy(instance::createToken).isInstanceOf(RuntimeException.class); | ||
} | ||
|
||
@Test | ||
public void createToken_signatureCalculation_InvalidKeyExceptionTurnedIntoRuntimeException() { | ||
JwtGenerator instance = JwtGenerator.getInstance(XSUAA, (key, alg, data) -> { | ||
throw new InvalidKeyException(); | ||
}); | ||
assertThatThrownBy(() -> instance.createToken()).isInstanceOf(RuntimeException.class); | ||
assertThatThrownBy(instance::createToken).isInstanceOf(RuntimeException.class); | ||
} | ||
|
||
} |
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