Skip to content

Commit

Permalink
Fixing unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Aug 23, 2024
1 parent f76bd4a commit 1d1d02e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.eclipse.microprofile.config.inject.ConfigProperty;

import java.io.Closeable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -39,6 +40,7 @@
import static de.cuioss.portal.authentication.oauth.OAuthConfigKeys.OPEN_ID_SERVER_BASE_URL;
import static de.cuioss.tools.net.UrlHelper.addTrailingSlashToUrl;
import static de.cuioss.tools.string.MoreStrings.isBlank;
import static de.cuioss.tools.string.MoreStrings.requireNotEmpty;

/**
* Produces {@link Oauth2Configuration} using the new config params
Expand Down Expand Up @@ -151,20 +153,24 @@ public void init() {
private Oauth2Configuration createConfiguration(final Map<String, Object> discovery) {
final var newConfiguration = new Oauth2ConfigurationImpl();

// fill dto with data from configuration system
// fill dto with data from a configuration system

oauth2clientId.get().ifPresent(newConfiguration::setClientId);
oauth2clientSecret.get().ifPresent(newConfiguration::setClientSecret);
externalContextPath.get().ifPresent(newConfiguration::setExternalContextPath);
oauth2initialScopes.get().ifPresent(newConfiguration::setInitialScopes);
logoutRedirectParameter.get().ifPresent(newConfiguration::setLogoutRedirectParamName);
postLogoutRedirectUri.get().ifPresent(newConfiguration::setPostLogoutRedirectUri);
roleMapperClaim.get().ifPresent(newConfiguration::setRoleMapperClaims);
Optional<List<String>> roleMapperClaims = roleMapperClaim.get();
if(roleMapperClaims.isPresent()) {
newConfiguration.setRoleMapperClaims(roleMapperClaims.get());
} else {
newConfiguration.setRoleMapperClaims(Collections.emptyList());
}
logoutWithIdTokenHintProvider.get().ifPresent(newConfiguration::setLogoutWithIdTokenHintEnabled);

// fill dto with data from discovery endpoint.
// endpoints are usually pointing to cluster-external URLs, i.e. reachable by
// web-browser.
// endpoints are usually pointing to cluster-external URLs, i.e., reachable by web-browser.
for (final Map.Entry<String, Object> entry : discovery.entrySet()) {
switch (entry.getKey()) {
case "authorization_endpoint":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public String getConfigSourceName() {
@Override
public List<String> getKeysIgnoreList() {
return immutableList(OPEN_ID_CLIENT_ID, OPEN_ID_CLIENT_SECRET, OPEN_ID_SERVER_BASE_URL, EXTERNAL_HOSTNAME,
OPEN_ID_SERVER_TOKEN_URL, OPEN_ID_SERVER_USER_INFO_URL, OPEN_ID_CLIENT_POST_LOGOUT_REDIRECT_URI);
OPEN_ID_SERVER_TOKEN_URL, OPEN_ID_SERVER_USER_INFO_URL, OPEN_ID_CLIENT_POST_LOGOUT_REDIRECT_URI, OPEN_ID_ROLE_MAPPER_CLAIM);
}

@Override
Expand Down

0 comments on commit 1d1d02e

Please sign in to comment.