Skip to content
Snippets Groups Projects
Commit ade8a8ef authored by Evgeny Bardin's avatar Evgeny Bardin
Browse files

OZG-7092 map all attribute keys

parent 00639acc
Branches
No related tags found
1 merge request!1OZG-7092 Anpassung TokenChecker
...@@ -177,6 +177,11 @@ public class SamlAttributeService { ...@@ -177,6 +177,11 @@ public class SamlAttributeService {
} }
TokenAttribute buildTokenAttribute(Map.Entry<String, String> attribute) { TokenAttribute buildTokenAttribute(Map.Entry<String, String> attribute) {
return TokenAttribute.builder().name(attribute.getKey()).value(attribute.getValue()).build(); return TokenAttribute.builder().name(getMappedKey(attribute.getKey())).value(attribute.getValue()).build();
}
String getMappedKey(String attributeKey) {
return tokenValidationProperty.getMappings().entrySet().stream().filter(entry -> StringUtils.equals(entry.getValue(), attributeKey))
.map(Map.Entry::getKey).findFirst().orElse(attributeKey);
} }
} }
...@@ -793,4 +793,24 @@ class SamlAttributeServiceTest { ...@@ -793,4 +793,24 @@ class SamlAttributeServiceTest {
assertThat(result).usingRecursiveComparison().isEqualTo(TokenAttributeTestFactory.create()); assertThat(result).usingRecursiveComparison().isEqualTo(TokenAttributeTestFactory.create());
} }
} }
@Nested
class TestGetMappedKey {
@Test
void shouldReturnDefaultKey() {
var result = service.getMappedKey(TokenAttributeTestFactory.VALUE);
assertThat(result).isEqualTo(TokenAttributeTestFactory.VALUE);
}
@Test
void shouldReturnMappedKey() {
when(tokenValidationProperty.getMappings()).thenReturn(Map.of(TokenAttributeTestFactory.NAME, TokenAttributeTestFactory.VALUE));
var result = service.getMappedKey(TokenAttributeTestFactory.VALUE);
assertThat(result).isEqualTo(TokenAttributeTestFactory.NAME);
}
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment