Skip to content

Commit

Permalink
Rename userAttributes to attributeMappings and make whitelist a list
Browse files Browse the repository at this point in the history
[#104349358] https://www.pivotaltracker.com/story/show/104349358

Signed-off-by: Leslie Chang <lescha@pivotal.io>
  • Loading branch information
mbhave authored and Leslie Chang committed Sep 30, 2015
1 parent 24d12a8 commit 3abfcb2
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 57 deletions.
@@ -1,6 +1,5 @@
package org.cloudfoundry.identity.uaa; package org.cloudfoundry.identity.uaa;


import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;


Expand All @@ -18,24 +17,24 @@
*******************************************************************************/ *******************************************************************************/
public class ExternalIdentityProviderDefinition extends AbstractIdentityProviderDefinition { public class ExternalIdentityProviderDefinition extends AbstractIdentityProviderDefinition {
public static final String EXTERNAL_GROUPS_WHITELIST = "externalGroupsWhitelist"; public static final String EXTERNAL_GROUPS_WHITELIST = "externalGroupsWhitelist";
public static final String USER_ATTRIBUTES = "userAttributes"; public static final String ATTRIBUTE_MAPPINGS = "attributeMappings";


private Map<String, List<String>> externalGroupsWhitelist; private List<String> externalGroupsWhitelist;
private Map<String, String> userAttributes; private Map<String, Object> attributeMappings;


public Map<String, List<String>> getExternalGroupsWhitelist() { public List<String> getExternalGroupsWhitelist() {
return externalGroupsWhitelist; return externalGroupsWhitelist;
} }


public void setExternalGroupsWhitelist(Map<String, List<String>> externalGroupsWhitelist) { public void setExternalGroupsWhitelist(List<String> externalGroupsWhitelist) {
this.externalGroupsWhitelist = externalGroupsWhitelist; this.externalGroupsWhitelist = externalGroupsWhitelist;
} }


public void setUserAttributes(Map<String, String> userAttributes) { public void setAttributeMappings(Map<String, Object> attributeMappings) {
this.userAttributes = userAttributes; this.attributeMappings = attributeMappings;
} }


public Map<String, String> getUserAttributes() { public Map<String, Object> getAttributeMappings() {
return userAttributes; return attributeMappings;
} }
} }
Expand Up @@ -21,7 +21,6 @@
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;


import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;


Expand Down Expand Up @@ -99,10 +98,10 @@ public static LdapIdentityProviderDefinition fromConfig(Map<String,Object> ldapC
definition.setEmailDomain((List<String>) source.getProperty("emailDomain")); definition.setEmailDomain((List<String>) source.getProperty("emailDomain"));
} }
if (source.getProperty("externalGroupsWhitelist")!=null) { if (source.getProperty("externalGroupsWhitelist")!=null) {
definition.setExternalGroupsWhitelist((Map<String, List<String>>) source.getProperty("externalGroupsWhitelist")); definition.setExternalGroupsWhitelist((List<String>) source.getProperty("externalGroupsWhitelist"));
} }
if (source.getProperty(USER_ATTRIBUTES)!=null) { if (source.getProperty(ATTRIBUTE_MAPPINGS)!=null) {
definition.setUserAttributes((Map<String, String>) source.getProperty(USER_ATTRIBUTES)); definition.setAttributeMappings((Map<String, Object>) source.getProperty(ATTRIBUTE_MAPPINGS));
} }


definition.setLdapProfileFile((String) source.getProperty("profile.file")); definition.setLdapProfileFile((String) source.getProperty("profile.file"));
Expand Down
Expand Up @@ -38,7 +38,6 @@
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
Expand All @@ -48,7 +47,7 @@


import static org.cloudfoundry.identity.uaa.AbstractIdentityProviderDefinition.EMAIL_DOMAIN_ATTR; import static org.cloudfoundry.identity.uaa.AbstractIdentityProviderDefinition.EMAIL_DOMAIN_ATTR;
import static org.cloudfoundry.identity.uaa.ExternalIdentityProviderDefinition.EXTERNAL_GROUPS_WHITELIST; import static org.cloudfoundry.identity.uaa.ExternalIdentityProviderDefinition.EXTERNAL_GROUPS_WHITELIST;
import static org.cloudfoundry.identity.uaa.ExternalIdentityProviderDefinition.USER_ATTRIBUTES; import static org.cloudfoundry.identity.uaa.ExternalIdentityProviderDefinition.ATTRIBUTE_MAPPINGS;


public class SamlIdentityProviderConfigurator implements InitializingBean { public class SamlIdentityProviderConfigurator implements InitializingBean {
private static Log logger = LogFactory.getLog(SamlIdentityProviderConfigurator.class); private static Log logger = LogFactory.getLog(SamlIdentityProviderConfigurator.class);
Expand Down Expand Up @@ -349,8 +348,8 @@ public void setIdentityProviders(Map<String, Map<String, Object>> providers) {
String iconUrl = (String)((Map)entry.getValue()).get("iconUrl"); String iconUrl = (String)((Map)entry.getValue()).get("iconUrl");
String zoneId = (String)((Map)entry.getValue()).get("zoneId"); String zoneId = (String)((Map)entry.getValue()).get("zoneId");
List<String> emailDomain = (List<String>) saml.get(EMAIL_DOMAIN_ATTR); List<String> emailDomain = (List<String>) saml.get(EMAIL_DOMAIN_ATTR);
Map<String, List<String>> externalGroupsWhitelist = (Map<String, List<String>>) saml.get(EXTERNAL_GROUPS_WHITELIST); List<String> externalGroupsWhitelist = (List<String>) saml.get(EXTERNAL_GROUPS_WHITELIST);
Map<String, String> userAttributes = (Map<String, String>) saml.get(USER_ATTRIBUTES); Map<String, Object> attributeMappings = (Map<String, Object>) saml.get(ATTRIBUTE_MAPPINGS);
SamlIdentityProviderDefinition def = new SamlIdentityProviderDefinition(); SamlIdentityProviderDefinition def = new SamlIdentityProviderDefinition();
if (alias==null) { if (alias==null) {
throw new IllegalArgumentException("Invalid IDP - alias must not be null ["+metaDataLocation+"]"); throw new IllegalArgumentException("Invalid IDP - alias must not be null ["+metaDataLocation+"]");
Expand All @@ -369,7 +368,7 @@ public void setIdentityProviders(Map<String, Map<String, Object>> providers) {
def.setIconUrl(iconUrl); def.setIconUrl(iconUrl);
def.setEmailDomain(emailDomain); def.setEmailDomain(emailDomain);
def.setExternalGroupsWhitelist(externalGroupsWhitelist); def.setExternalGroupsWhitelist(externalGroupsWhitelist);
def.setUserAttributes(userAttributes); def.setAttributeMappings(attributeMappings);
def.setZoneId(StringUtils.hasText(zoneId) ? zoneId : IdentityZone.getUaa().getId()); def.setZoneId(StringUtils.hasText(zoneId) ? zoneId : IdentityZone.getUaa().getId());
toBeFetchedProviders.add(def); toBeFetchedProviders.add(def);
} }
Expand Down
Expand Up @@ -65,7 +65,7 @@ public SamlIdentityProviderDefinition(String metaDataLocation, String idpEntityA
public SamlIdentityProviderDefinition(String metaDataLocation, String idpEntityAlias, String nameID, int assertionConsumerIndex, public SamlIdentityProviderDefinition(String metaDataLocation, String idpEntityAlias, String nameID, int assertionConsumerIndex,
boolean metadataTrustCheck, boolean showSamlLink, String linkText, String iconUrl, boolean metadataTrustCheck, boolean showSamlLink, String linkText, String iconUrl,
String zoneId, boolean addShadowUserOnLogin, List<String> emailDomain, String zoneId, boolean addShadowUserOnLogin, List<String> emailDomain,
Map<String, List<String>> externalGroupsWhitelist, Map<String, String> userAttributes) { List<String> externalGroupsWhitelist, Map<String, Object> attributeMappings) {
this.metaDataLocation = metaDataLocation; this.metaDataLocation = metaDataLocation;
this.idpEntityAlias = idpEntityAlias; this.idpEntityAlias = idpEntityAlias;
this.nameID = nameID; this.nameID = nameID;
Expand All @@ -78,7 +78,7 @@ public SamlIdentityProviderDefinition(String metaDataLocation, String idpEntityA
this.addShadowUserOnLogin = addShadowUserOnLogin; this.addShadowUserOnLogin = addShadowUserOnLogin;
setEmailDomain(emailDomain); setEmailDomain(emailDomain);
setExternalGroupsWhitelist(externalGroupsWhitelist); setExternalGroupsWhitelist(externalGroupsWhitelist);
setUserAttributes(userAttributes); setAttributeMappings(attributeMappings);
} }


@JsonIgnore @JsonIgnore
Expand Down Expand Up @@ -217,7 +217,7 @@ public void setAddShadowUserOnLogin(boolean addShadowUserOnLogin) {
} }


public SamlIdentityProviderDefinition clone() { public SamlIdentityProviderDefinition clone() {
return new SamlIdentityProviderDefinition(metaDataLocation, idpEntityAlias, nameID, assertionConsumerIndex, metadataTrustCheck, showSamlLink, linkText, iconUrl, zoneId, addShadowUserOnLogin, getEmailDomain()!=null ? new ArrayList<>(getEmailDomain()) : null, getExternalGroupsWhitelist()!=null ? new LinkedHashMap(getExternalGroupsWhitelist()) : null, getUserAttributes()!=null ? new HashMap(getUserAttributes()) : null); return new SamlIdentityProviderDefinition(metaDataLocation, idpEntityAlias, nameID, assertionConsumerIndex, metadataTrustCheck, showSamlLink, linkText, iconUrl, zoneId, addShadowUserOnLogin, getEmailDomain()!=null ? new ArrayList<>(getEmailDomain()) : null, getExternalGroupsWhitelist()!=null ? new ArrayList<>(getExternalGroupsWhitelist()) : null, getAttributeMappings()!=null ? new HashMap(getAttributeMappings()) : null);
} }


@Override @Override
Expand Down
Expand Up @@ -32,6 +32,7 @@
import org.junit.Test; import org.junit.Test;
import org.springframework.mock.env.MockEnvironment; import org.springframework.mock.env.MockEnvironment;


import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
Expand All @@ -41,7 +42,7 @@


import static org.cloudfoundry.identity.uaa.AbstractIdentityProviderDefinition.EMAIL_DOMAIN_ATTR; import static org.cloudfoundry.identity.uaa.AbstractIdentityProviderDefinition.EMAIL_DOMAIN_ATTR;
import static org.cloudfoundry.identity.uaa.ExternalIdentityProviderDefinition.EXTERNAL_GROUPS_WHITELIST; import static org.cloudfoundry.identity.uaa.ExternalIdentityProviderDefinition.EXTERNAL_GROUPS_WHITELIST;
import static org.cloudfoundry.identity.uaa.ExternalIdentityProviderDefinition.USER_ATTRIBUTES; import static org.cloudfoundry.identity.uaa.ExternalIdentityProviderDefinition.ATTRIBUTE_MAPPINGS;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -81,13 +82,13 @@ public void testLdapBootstrap() throws Exception {
IdentityProviderBootstrap bootstrap = new IdentityProviderBootstrap(provisioning, new MockEnvironment()); IdentityProviderBootstrap bootstrap = new IdentityProviderBootstrap(provisioning, new MockEnvironment());
HashMap<String, Object> ldapConfig = new HashMap<>(); HashMap<String, Object> ldapConfig = new HashMap<>();
ldapConfig.put(EMAIL_DOMAIN_ATTR, Arrays.asList("test.domain")); ldapConfig.put(EMAIL_DOMAIN_ATTR, Arrays.asList("test.domain"));
Map<String, List<String>> attrMap = new LinkedHashMap<>(); List<String> attrMap = new ArrayList<>();
attrMap.put("key", Arrays.asList("value")); attrMap.add("value");
ldapConfig.put(EXTERNAL_GROUPS_WHITELIST, attrMap); ldapConfig.put(EXTERNAL_GROUPS_WHITELIST, attrMap);


Map<String, String> userAttributes = new HashMap<>(); Map<String, Object> attributeMappings = new HashMap<>();
userAttributes.put("given_name", "first_name"); attributeMappings.put("given_name", "first_name");
ldapConfig.put(USER_ATTRIBUTES, userAttributes); ldapConfig.put(ATTRIBUTE_MAPPINGS, attributeMappings);


bootstrap.setLdapConfig(ldapConfig); bootstrap.setLdapConfig(ldapConfig);
bootstrap.afterPropertiesSet(); bootstrap.afterPropertiesSet();
Expand All @@ -98,8 +99,8 @@ public void testLdapBootstrap() throws Exception {
assertNotNull(ldapProvider.getLastModified()); assertNotNull(ldapProvider.getLastModified());
assertEquals(Origin.LDAP, ldapProvider.getType()); assertEquals(Origin.LDAP, ldapProvider.getType());
assertEquals("test.domain", ldapProvider.getConfigValue(LdapIdentityProviderDefinition.class).getEmailDomain().get(0)); assertEquals("test.domain", ldapProvider.getConfigValue(LdapIdentityProviderDefinition.class).getEmailDomain().get(0));
assertEquals(Arrays.asList("value"), ldapProvider.getConfigValue(LdapIdentityProviderDefinition.class).getExternalGroupsWhitelist().get("key")); assertEquals(Arrays.asList("value"), ldapProvider.getConfigValue(LdapIdentityProviderDefinition.class).getExternalGroupsWhitelist());
assertEquals("first_name", ldapProvider.getConfigValue(LdapIdentityProviderDefinition.class).getUserAttributes().get("given_name")); assertEquals("first_name", ldapProvider.getConfigValue(LdapIdentityProviderDefinition.class).getAttributeMappings().get("given_name"));
} }


@Test @Test
Expand Down Expand Up @@ -225,13 +226,14 @@ public void testSamlBootstrap() throws Exception {
definition.setShowSamlLink(true); definition.setShowSamlLink(true);
definition.setMetadataTrustCheck(true); definition.setMetadataTrustCheck(true);
definition.setEmailDomain(Arrays.asList("test.domain")); definition.setEmailDomain(Arrays.asList("test.domain"));
Map<String, List<String>> externalGroupsWhitelist = new LinkedHashMap<>(); List<String> externalGroupsWhitelist = new ArrayList<>();
externalGroupsWhitelist.put("key", Arrays.asList("value1", "value2")); externalGroupsWhitelist.add("value1");
externalGroupsWhitelist.add("value2");
definition.setExternalGroupsWhitelist(externalGroupsWhitelist); definition.setExternalGroupsWhitelist(externalGroupsWhitelist);


Map<String,String> userAttributes = new HashMap<>(); Map<String, Object> attributeMappings = new HashMap<>();
userAttributes.put("given_name", "first_name"); attributeMappings.put("given_name", "first_name");
definition.setUserAttributes(userAttributes); definition.setAttributeMappings(attributeMappings);


SamlIdentityProviderConfigurator configurator = mock(SamlIdentityProviderConfigurator.class); SamlIdentityProviderConfigurator configurator = mock(SamlIdentityProviderConfigurator.class);
when(configurator.getIdentityProviderDefinitions()).thenReturn(Arrays.asList(definition)); when(configurator.getIdentityProviderDefinitions()).thenReturn(Arrays.asList(definition));
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;


import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
Expand Down Expand Up @@ -349,22 +350,22 @@ public void testSetEmailDomain() {
@Test @Test
public void set_external_groups_whitelist() { public void set_external_groups_whitelist() {
LdapIdentityProviderDefinition def = new LdapIdentityProviderDefinition(); LdapIdentityProviderDefinition def = new LdapIdentityProviderDefinition();
Map<String, List<String>> externalGroupsWhitelist = new LinkedHashMap<>(); List<String> externalGroupsWhitelist = new ArrayList<>();
externalGroupsWhitelist.put("key", Arrays.asList("value")); externalGroupsWhitelist.add("value");
def.setExternalGroupsWhitelist(externalGroupsWhitelist); def.setExternalGroupsWhitelist(externalGroupsWhitelist);
assertEquals(Arrays.asList("value"), def.getExternalGroupsWhitelist().get("key")); assertEquals(Arrays.asList("value"), def.getExternalGroupsWhitelist());
def = JsonUtils.readValue(JsonUtils.writeValueAsString(def), LdapIdentityProviderDefinition.class); def = JsonUtils.readValue(JsonUtils.writeValueAsString(def), LdapIdentityProviderDefinition.class);
assertEquals(Arrays.asList("value"), def.getExternalGroupsWhitelist().get("key")); assertEquals(Arrays.asList("value"), def.getExternalGroupsWhitelist());
} }


@Test @Test
public void set_user_attributes() { public void set_user_attributes() {
LdapIdentityProviderDefinition def = new LdapIdentityProviderDefinition(); LdapIdentityProviderDefinition def = new LdapIdentityProviderDefinition();
Map<String, String> userAttributes = new HashMap<>(); Map<String, Object> attributeMappings = new HashMap<>();
userAttributes.put("given_name", "first_name"); attributeMappings.put("given_name", "first_name");
def.setUserAttributes(userAttributes); def.setAttributeMappings(attributeMappings);
assertEquals("first_name", def.getUserAttributes().get("given_name")); assertEquals("first_name", def.getAttributeMappings().get("given_name"));
def = JsonUtils.readValue(JsonUtils.writeValueAsString(def), LdapIdentityProviderDefinition.class); def = JsonUtils.readValue(JsonUtils.writeValueAsString(def), LdapIdentityProviderDefinition.class);
assertEquals("first_name", def.getUserAttributes().get("given_name")); assertEquals("first_name", def.getAttributeMappings().get("given_name"));
} }
} }
Expand Up @@ -34,7 +34,6 @@
import org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory; import org.springframework.security.saml.trust.httpclient.TLSProtocolSocketFactory;


import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
Expand Down Expand Up @@ -98,11 +97,12 @@ public static void initializeOpenSAML() throws Exception {
" - test.org\n" + " - test.org\n" +
" - test.com\n" + " - test.com\n" +
" externalGroupsWhitelist:\n" + " externalGroupsWhitelist:\n" +
" roles:\n" + " - admin\n" +
" - admin\n" + " - user\n" +
" - user\n" + " attributeMappings:\n" +
" userAttributes:\n" +
" given_name: first_name\n" + " given_name: first_name\n" +
" external_groups:\n" +
" - roles\n" +
" okta-local-2:\n" + " okta-local-2:\n" +
" idpMetadata: |\n" + " idpMetadata: |\n" +
" <?xml version=\"1.0\" encoding=\"UTF-8\"?><md:EntityDescriptor xmlns:md=\"urn:oasis:names:tc:SAML:2.0:metadata\" entityID=\"http://www.okta.com/k2lw4l5bPODCMIIDBRYZ\"><md:IDPSSODescriptor WantAuthnRequestsSigned=\"true\" protocolSupportEnumeration=\"urn:oasis:names:tc:SAML:2.0:protocol\"><md:KeyDescriptor use=\"signing\"><ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"><ds:X509Data><ds:X509Certificate>MIICmTCCAgKgAwIBAgIGAUPATqmEMA0GCSqGSIb3DQEBBQUAMIGPMQswCQYDVQQGEwJVUzETMBEG\n" + " <?xml version=\"1.0\" encoding=\"UTF-8\"?><md:EntityDescriptor xmlns:md=\"urn:oasis:names:tc:SAML:2.0:metadata\" entityID=\"http://www.okta.com/k2lw4l5bPODCMIIDBRYZ\"><md:IDPSSODescriptor WantAuthnRequestsSigned=\"true\" protocolSupportEnumeration=\"urn:oasis:names:tc:SAML:2.0:protocol\"><md:KeyDescriptor use=\"signing\"><ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"><ds:X509Data><ds:X509Certificate>MIICmTCCAgKgAwIBAgIGAUPATqmEMA0GCSqGSIb3DQEBBQUAMIGPMQswCQYDVQQGEwJVUzETMBEG\n" +
Expand Down Expand Up @@ -338,8 +338,11 @@ protected void testGetIdentityProviderDefinitions(int count, boolean addData) th
assertEquals(0, idp.getAssertionConsumerIndex()); assertEquals(0, idp.getAssertionConsumerIndex());
assertEquals("Okta Preview 1", idp.getLinkText()); assertEquals("Okta Preview 1", idp.getLinkText());
assertEquals("http://link.to/icon.jpg", idp.getIconUrl()); assertEquals("http://link.to/icon.jpg", idp.getIconUrl());
assertEquals(singletonMap("given_name", "first_name"), idp.getUserAttributes()); Map<String, Object> attributeMappings = new HashMap<>();
assertEquals(singletonMap("roles", asList("admin", "user")), idp.getExternalGroupsWhitelist()); attributeMappings.put("given_name", "first_name");
attributeMappings.put("external_groups", asList("roles"));
assertEquals(attributeMappings, idp.getAttributeMappings());
assertEquals(asList("admin", "user"), idp.getExternalGroupsWhitelist());
assertTrue(idp.isShowSamlLink()); assertTrue(idp.isShowSamlLink());
assertTrue(idp.isMetadataTrustCheck()); assertTrue(idp.isMetadataTrustCheck());
assertTrue(idp.getEmailDomain().containsAll(asList("test.com", "test.org"))); assertTrue(idp.getEmailDomain().containsAll(asList("test.com", "test.org")));
Expand Down
Expand Up @@ -41,6 +41,7 @@
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;


import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
Expand Down Expand Up @@ -108,12 +109,12 @@ public void testCreateSamlProvider() throws Exception {
provider.setOriginKey(origin); provider.setOriginKey(origin);
SamlIdentityProviderDefinition samlDefinition = new SamlIdentityProviderDefinition(metadata, null, null, 0, false, true, "Test SAML Provider", null, null); SamlIdentityProviderDefinition samlDefinition = new SamlIdentityProviderDefinition(metadata, null, null, 0, false, true, "Test SAML Provider", null, null);
samlDefinition.setEmailDomain(Arrays.asList("test.com", "test2.com")); samlDefinition.setEmailDomain(Arrays.asList("test.com", "test2.com"));
Map<String,List<String>> externalGroupsWhitelist = new LinkedHashMap<>(); List<String> externalGroupsWhitelist = new ArrayList<>();
externalGroupsWhitelist.put("key", Arrays.asList("value")); externalGroupsWhitelist.add("value");
Map<String,String> userAttributes = new HashMap<>(); Map<String, Object> attributeMappings = new HashMap<>();
userAttributes.put("given_name", "first_name"); attributeMappings.put("given_name", "first_name");
samlDefinition.setExternalGroupsWhitelist(externalGroupsWhitelist); samlDefinition.setExternalGroupsWhitelist(externalGroupsWhitelist);
samlDefinition.setUserAttributes(userAttributes); samlDefinition.setAttributeMappings(attributeMappings);


provider.setConfig(JsonUtils.writeValueAsString(samlDefinition)); provider.setConfig(JsonUtils.writeValueAsString(samlDefinition));


Expand All @@ -123,7 +124,7 @@ public void testCreateSamlProvider() throws Exception {
SamlIdentityProviderDefinition samlCreated = created.getConfigValue(SamlIdentityProviderDefinition.class); SamlIdentityProviderDefinition samlCreated = created.getConfigValue(SamlIdentityProviderDefinition.class);
assertEquals(Arrays.asList("test.com", "test2.com"), samlCreated.getEmailDomain()); assertEquals(Arrays.asList("test.com", "test2.com"), samlCreated.getEmailDomain());
assertEquals(externalGroupsWhitelist, samlCreated.getExternalGroupsWhitelist()); assertEquals(externalGroupsWhitelist, samlCreated.getExternalGroupsWhitelist());
assertEquals(userAttributes, samlCreated.getUserAttributes()); assertEquals(attributeMappings, samlCreated.getAttributeMappings());
assertEquals(IdentityZone.getUaa().getId(), samlCreated.getZoneId()); assertEquals(IdentityZone.getUaa().getId(), samlCreated.getZoneId());
assertEquals(provider.getOriginKey(), samlCreated.getIdpEntityAlias()); assertEquals(provider.getOriginKey(), samlCreated.getIdpEntityAlias());
} }
Expand Down

0 comments on commit 3abfcb2

Please sign in to comment.