-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: alexandr cumarav <alexandr.cumarav@broadcom.com>
- Loading branch information
Showing
7 changed files
with
137 additions
and
52 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
49 changes: 49 additions & 0 deletions
49
...y-service/src/test/java/org/zowe/apiml/gateway/security/service/token/OIDCConfigTest.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,49 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
package org.zowe.apiml.gateway.security.service.token; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import lombok.SneakyThrows; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.InputStream; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class OIDCConfigTest { | ||
private final ObjectMapper oidcJwkMapper = new OIDCConfig().oidcJwkMapper(); | ||
|
||
@Test | ||
@SneakyThrows | ||
void shouldParseJwksFormatWithExtraProperties() { | ||
try (InputStream is = this.getClass().getResourceAsStream("/test_samples/azure_jwks.json")) { | ||
JwkKeys jwkKeys = oidcJwkMapper.readValue(is, JwkKeys.class); | ||
|
||
assertThat(jwkKeys.getKeys()).hasSize(1); | ||
JwkKeys.Key key = jwkKeys.getKeys().get(0); | ||
assertThat(key.getKid()).isEqualTo("9GmnyFPkhc3hOuR22mvSvgnLo7Y"); | ||
assertThat(key.getKty()).isEqualTo("RSA"); | ||
} | ||
} | ||
|
||
@Test | ||
@SneakyThrows | ||
void shouldParseExpectedJwksFormat() { | ||
try (InputStream is = this.getClass().getResourceAsStream("/test_samples/okta_jwks.json")) { | ||
JwkKeys jwkKeys = oidcJwkMapper.readValue(is, JwkKeys.class); | ||
|
||
assertThat(jwkKeys.getKeys()).hasSize(2); | ||
JwkKeys.Key key = jwkKeys.getKeys().get(0); | ||
assertThat(key.getKid()).isEqualTo("Lcxckkor94qkrunxHP7Tkib547rzmkXvsYV-nc6U-N4"); | ||
assertThat(key.getKty()).isEqualTo("RSA"); | ||
} | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
gateway-service/src/test/resources/test_samples/azure_jwks.json
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,16 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"kty": "RSA", | ||
"use": "sig", | ||
"kid": "9GmnyFPkhc3hOuR22mvSvgnLo7Y", | ||
"x5t": "9GmnyFPkhc3hOuR22mvSvgnLo7Y", | ||
"n": "z_w-5U4eZwenXYnEgt2rCN-753YQ7RN8ykiNprNiLl4ilpwAGLWF1cssoRflsSiBVZcCSwUzUwsifG7sbRq9Vc8RFs72Gg0AUwPsJFUqNttMg3Ot-wTqsZtE5GNSBUSqnI-iWoZfjw-uLsS0u4MfzP8Fpkd-rzRlifuIAYK8Ffi1bldkszeBzQbBZbX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gTDlKf4Wb5Exy7u9dMW1TChiy28ieVkETKdqwXcbhqM8GOLBUFicdmgP2y9aDGjb89BuaeoHJCGpWWCi3UZth14clVzC6p7ZD6fFx5tKMOL/hQvs3ugGtvFDWCsvcT8bB84RO8=" | ||
], | ||
"issuer": "https://login.microsoftonline.com/d10ec64d-2698-489f-8a03-7e77cdca82d7/v2.0" | ||
} | ||
] | ||
} |
20 changes: 20 additions & 0 deletions
20
gateway-service/src/test/resources/test_samples/okta_jwks.json
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,20 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"kty": "RSA", | ||
"alg": "RS256", | ||
"kid": "Lcxckkor94qkrunxHP7Tkib547rzmkXvsYV-nc6U-N4", | ||
"use": "sig", | ||
"e": "AQAB", | ||
"n": "v6wT5k7uLto_VPTV8fW9_wRqWHuqnZbyEYAwNYRdffe9WowwnzUAr0Z93-4xDvCRuVfTfvCe9orEWdjZMaYlDq_Dj5BhLAqmBAF299Kv1GymOioLRDvoVWy0aVHYXXNaqJCPsaWIDiCly-_kJBbnda_rmB28a_878TNxom0mDQ20TI5SgdebqqMBOdHEqIYH1ER9euybekeqJX24EqE9YW4Yug5BOkZ9KcUkiEsH_NPyRlozihj18Qab181PRyKHE6M40W7w67XcRq2llTy-z9RrQupcyvLD7L62KN0ey8luKWnVg4uIOldpyBYyiRX2WPM-2K00RVC0e4jQKs34Gw" | ||
}, | ||
{ | ||
"kty": "RSA", | ||
"alg": "RS256", | ||
"kid": "-716sp3XBB_v30lGj2mu5MdXkdh8poa9zJQlAwC46n4", | ||
"use": "sig", | ||
"e": "AQAB", | ||
"n": "5rYyqFsxel0Pv-xRDHPbg3IfumE4ks9ffLvJrfZVgrTQyiFmFfBnyD3r7y6626Yr5-68Pj0I5SHlCBPkkgTU_e9Z3tCYiegtIOeJdSdumWR2JDVAsbpwFJDG_kxP9czgX7HL0T2BPSapx7ba0ZBXd2-SfSDDL-c1Q0rJ1uQEJwDXAGZV4qy_oXuQf5DuV65Xj8y2Qn1DtVEBThxita-kis_H35CTWgW2zyyaS_08wa00R98mnQ2SHfmO5fZABITmH0DO0coDHqKZ429VNNpELLX9e95dirQ1jfngDbBCmy-XsT8yc6NpAaXmd8P2NHdsO2oK46EQEaFRyMcoDTs3-w" | ||
} | ||
] | ||
} |