Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the problem of NoSuchMethod error of auth provider #66

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.lang.NonNull;
Expand Down Expand Up @@ -160,7 +161,10 @@ Mono<Set<String>> fetchEnabledProviders() {
return client.fetch(ConfigMap.class, SystemSetting.SYSTEM_CONFIG)
.map(configMap -> {
var authProvider = getAuthProvider(configMap);
return authProvider.getEnabled();
return authProvider.getStates().stream()
.filter(SystemSetting.AuthProviderState::isEnabled)
.map(SystemSetting.AuthProviderState::getName)
.collect(Collectors.toSet());
})
.defaultIfEmpty(Set.of());
}
Expand All @@ -180,8 +184,8 @@ private static SystemSetting.AuthProvider getAuthProvider(ConfigMap configMap) {
authProvider = JsonUtils.jsonToObject(providerGroup, SystemSetting.AuthProvider.class);
}

if (authProvider.getEnabled() == null) {
authProvider.setEnabled(new HashSet<>());
if (authProvider.getStates() == null) {
authProvider.setStates(List.of());
}
return authProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ void findByRegistrationId_withValidId_returnsClientRegistration() {
.thenReturn(Mono.just(authProvider));
ConfigMap systemConfig = new ConfigMap();
systemConfig.setData(Map.of(SystemSetting.AuthProvider.GROUP,
"{\"enabled\":[\"github\"]}"));
"""
{"states":[{"name":"github", "enabled":true}]}\
"""));
when(client.fetch(eq(ConfigMap.class), eq(SystemSetting.SYSTEM_CONFIG)))
.thenReturn(Mono.just(systemConfig));

Expand Down