This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
forked from research-software-directory/RSD-as-a-service
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from hifis-net/86-update_v1.11.0
Update v1.11.0
- Loading branch information
Showing
120 changed files
with
2,358 additions
and
886 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
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
79 changes: 79 additions & 0 deletions
79
authentication/src/test/java/nl/esciencecenter/rsd/authentication/UtilsTest.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,79 @@ | ||
// SPDX-FileCopyrightText: 2022 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
// SPDX-FileCopyrightText: 2022 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package nl.esciencecenter.rsd.authentication; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.net.URI; | ||
|
||
public class UtilsTest { | ||
|
||
@Test | ||
void givenValidWellKnownData_whenExtractingTokenEndpoint_correctResultReturned() { | ||
String data = """ | ||
{ | ||
"token_endpoint_auth_signing_alg_values_supported": [ | ||
"RS256" | ||
], | ||
"id_token_signing_alg_values_supported": [ | ||
"RS256" | ||
], | ||
"userinfo_endpoint": "https://sandbox.orcid.org/oauth/userinfo", | ||
"authorization_endpoint": "https://sandbox.orcid.org/oauth/authorize", | ||
"token_endpoint": "https://sandbox.orcid.org/oauth/token", | ||
"jwks_uri": "https://sandbox.orcid.org/oauth/jwks", | ||
"claims_supported": [ | ||
"family_name", | ||
"given_name", | ||
"name", | ||
"auth_time", | ||
"iss", | ||
"sub" | ||
], | ||
"scopes_supported": [ | ||
"openid" | ||
], | ||
"subject_types_supported": [ | ||
"public" | ||
], | ||
"response_types_supported": [ | ||
"code", | ||
"id_token", | ||
"id_token token" | ||
], | ||
"claims_parameter_supported": false, | ||
"token_endpoint_auth_methods_supported": [ | ||
"client_secret_post" | ||
], | ||
"grant_types_supported": [ | ||
"authorization_code", | ||
"implicit", | ||
"refresh_token" | ||
], | ||
"issuer": "https://sandbox.orcid.org" | ||
}"""; | ||
|
||
URI tokenEndpoint = Utils.extractTokenUrlFromWellKnownData(data); | ||
|
||
Assertions.assertEquals(URI.create("https://sandbox.orcid.org/oauth/token"), tokenEndpoint); | ||
} | ||
|
||
@Test | ||
void givenInvalidJson_whenExtractingTokenEndpoint_thenExceptionThrown() { | ||
String data = "{"; | ||
|
||
Assertions.assertThrows(RuntimeException.class, () -> Utils.extractTokenUrlFromWellKnownData(data)); | ||
} | ||
|
||
@Test | ||
void givenDataWithoutTokenEndpoint_whenExtractingTokenEndpoint_thenExceptionThrown() { | ||
String data = "{\"token_endpoint\": null}"; | ||
|
||
Assertions.assertThrows(ClassCastException.class, () -> Utils.extractTokenUrlFromWellKnownData(data)); | ||
} | ||
|
||
} |
Oops, something went wrong.