generated from cuioss/cui-java-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #52 from cuioss/feature/oauth-config-validation
Feature/oauth config validation
- Loading branch information
Showing
13 changed files
with
259 additions
and
41 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
63 changes: 63 additions & 0 deletions
63
...src/test/java/de/cuioss/portal/authentication/oauth/impl/Oauth2ConfigurationImplTest.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,63 @@ | ||
package de.cuioss.portal.authentication.oauth.impl; | ||
|
||
import de.cuioss.test.generator.Generators; | ||
import de.cuioss.test.generator.TypedGenerator; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
class Oauth2ConfigurationImplTest { | ||
|
||
private static final TypedGenerator<String> nonEmptyLetterStringGenerator = Generators.letterStrings(1, 5); | ||
|
||
@Test | ||
void validConfig() { | ||
Oauth2ConfigurationImpl config = createConfig(); | ||
|
||
assertDoesNotThrow(config::validate); | ||
} | ||
|
||
@Test | ||
void missingTokenUri() { | ||
Oauth2ConfigurationImpl config = createConfig(); | ||
config.setTokenUri(null); | ||
|
||
assertThrows(IllegalStateException.class, config::validate); | ||
} | ||
|
||
@Test | ||
void missingClientId() { | ||
Oauth2ConfigurationImpl config = createConfig(); | ||
config.setClientId(null); | ||
|
||
assertThrows(IllegalStateException.class, config::validate); | ||
} | ||
|
||
@Test | ||
void missingAuthorizeUri() { | ||
Oauth2ConfigurationImpl config = createConfig(); | ||
config.setAuthorizeUri(null); | ||
|
||
assertThrows(IllegalStateException.class, config::validate); | ||
} | ||
|
||
private Oauth2ConfigurationImpl createConfig() { | ||
Oauth2ConfigurationImpl.Oauth2ConfigurationImplBuilder configBuilder = Oauth2ConfigurationImpl.builder(); | ||
configBuilder.clientId(nonEmptyLetterStringGenerator.next()); | ||
configBuilder.clientSecret(nonEmptyLetterStringGenerator.next()); | ||
configBuilder.initialScopes(nonEmptyLetterStringGenerator.next()); | ||
configBuilder.logoutUri(nonEmptyLetterStringGenerator.next()); | ||
configBuilder.externalContextPath(nonEmptyLetterStringGenerator.next()); | ||
configBuilder.authorizeUri(nonEmptyLetterStringGenerator.next()); | ||
configBuilder.logoutRedirectParamName(nonEmptyLetterStringGenerator.next()); | ||
configBuilder.postLogoutRedirectUri(nonEmptyLetterStringGenerator.next()); | ||
configBuilder.roleMapperClaims(Collections.singletonList(nonEmptyLetterStringGenerator.next())); | ||
configBuilder.tokenUri(nonEmptyLetterStringGenerator.next()); | ||
configBuilder.externalContextPath(nonEmptyLetterStringGenerator.next()); | ||
configBuilder.userInfoUri(nonEmptyLetterStringGenerator.next()); | ||
return configBuilder.build(); | ||
} | ||
} |
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
Oops, something went wrong.