[java-identity-provider] 01/01: Extend unit test.
Scott Cantor
cantor.2 at osu.edu
Mon May 6 14:57:55 EDT 2019
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch IDP-1434
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=e56267a4e0593f3e04708da15d8ae6b3edf0a6af
commit e56267a4e0593f3e04708da15d8ae6b3edf0a6af
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon May 6 14:57:50 2019 -0400
Extend unit test.
---
.../resolver/spring/AttributeMapperTest.java | 75 +++++++++++-----------
1 file changed, 37 insertions(+), 38 deletions(-)
diff --git a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMapperTest.java b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMapperTest.java
index e80df89..7be38ab 100644
--- a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMapperTest.java
+++ b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/AttributeMapperTest.java
@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Properties;
import org.opensaml.core.OpenSAMLInitBaseTestCase;
+import org.opensaml.saml.saml1.core.AttributeDesignator;
import org.opensaml.saml.saml2.core.Attribute;
import org.springframework.context.support.ConversionServiceFactoryBean;
import org.springframework.context.support.GenericApplicationContext;
@@ -36,8 +37,12 @@ import net.shibboleth.ext.spring.util.SchemaTypeAwareXMLBeanDefinitionReader;
import net.shibboleth.idp.attribute.IdPAttribute;
import net.shibboleth.idp.attribute.resolver.ResolutionException;
import net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry;
+import net.shibboleth.idp.saml.attribute.transcoding.AbstractSAML1AttributeTranscoder;
import net.shibboleth.idp.saml.attribute.transcoding.AbstractSAML2AttributeTranscoder;
+import net.shibboleth.idp.saml.attribute.transcoding.impl.SAML1ScopedStringAttributeTranscoder;
+import net.shibboleth.idp.saml.attribute.transcoding.impl.SAML1StringAttributeTranscoder;
import net.shibboleth.idp.saml.attribute.transcoding.impl.SAML2ScopedStringAttributeTranscoder;
+import net.shibboleth.idp.saml.attribute.transcoding.impl.SAML2StringAttributeTranscoder;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.service.ReloadableService;
import net.shibboleth.utilities.java.support.service.ServiceException;
@@ -91,51 +96,45 @@ public class AttributeMapperTest extends OpenSAMLInitBaseTestCase {
Collection<Properties> rulesets = serviceableComponent.getComponent().getTranscodingProperties(
new IdPAttribute("eduPersonScopedAffiliation"), Attribute.class);
assertEquals(rulesets.size(), 1);
- final Properties rule = rulesets.iterator().next();
+ Properties rule = rulesets.iterator().next();
assertEquals(rule.get(AbstractSAML2AttributeTranscoder.PROP_NAME), "urn:oid:1.3.6.1.4.1.5923.1.1.1.9");
assertNull(rule.get(AbstractSAML2AttributeTranscoder.PROP_NAME_FORMAT));
assertEquals(rule.get(AbstractSAML2AttributeTranscoder.PROP_FRIENDLY_NAME), "feduPersonScopedAffiliation");
assertTrue(rule.get(AttributeTranscoderRegistry.PROP_TRANSCODER) instanceof SAML2ScopedStringAttributeTranscoder);
assertEquals(rule.get(SAML2ScopedStringAttributeTranscoder.PROP_SCOPE_DELIMITER), "#");
+
+ rulesets = serviceableComponent.getComponent().getTranscodingProperties(
+ new IdPAttribute("eduPersonScopedAffiliation"), AttributeDesignator.class);
+ assertEquals(rulesets.size(), 1);
+ rule = rulesets.iterator().next();
+ assertEquals(rule.get(AbstractSAML1AttributeTranscoder.PROP_NAME), "urn:mace:dir:attribute-def:eduPersonScopedAffiliation");
+ assertNull(rule.get(AbstractSAML1AttributeTranscoder.PROP_NAMESPACE));
+ assertTrue(rule.get(AttributeTranscoderRegistry.PROP_TRANSCODER) instanceof SAML1ScopedStringAttributeTranscoder);
+ assertNull(rule.get(SAML1ScopedStringAttributeTranscoder.PROP_SCOPE_DELIMITER));
+
+ rulesets = serviceableComponent.getComponent().getTranscodingProperties(
+ new IdPAttribute("eduPersonAssurance"), Attribute.class);
+ assertEquals(rulesets.size(), 2);
+ rule = rulesets.iterator().next();
+ String name = rule.getProperty(AbstractSAML2AttributeTranscoder.PROP_NAME);
+ assertTrue("urn:oid:1.3.6.1.4.1.5923.1.1.1.11".equals(name) || "http://example.org/name/for/Attribute".equals(name));
+ String nameFormat = rule.getProperty(AbstractSAML2AttributeTranscoder.PROP_NAME_FORMAT);
+ assertTrue(nameFormat == null || "http://example.org/Format".equals(nameFormat));
+ String friendlyName = rule.getProperty(AbstractSAML2AttributeTranscoder.PROP_FRIENDLY_NAME);
+ assertTrue("feduPersonAssurance".equals(friendlyName) || "fotherSAMLName".equals(friendlyName));
+ assertTrue(rule.get(AttributeTranscoderRegistry.PROP_TRANSCODER) instanceof SAML2StringAttributeTranscoder);
+
+ rulesets = serviceableComponent.getComponent().getTranscodingProperties(
+ new IdPAttribute("eduPersonAssurance"), AttributeDesignator.class);
+ assertEquals(rulesets.size(), 1);
+ rule = rulesets.iterator().next();
+ assertEquals(rule.get(AbstractSAML1AttributeTranscoder.PROP_NAME), "urn:mace:dir:attribute-def:eduPersonAssurance");
+ assertNull(rule.get(AbstractSAML1AttributeTranscoder.PROP_NAMESPACE));
+ assertTrue(rule.get(AttributeTranscoderRegistry.PROP_TRANSCODER) instanceof SAML1StringAttributeTranscoder);
+
} finally {
serviceableComponent.unpinComponent();
- }
-
- /*
- for (AttributeMapper<RequestedAttribute, IdPRequestedAttribute> mapper : mappers) {
- AbstractSAMLAttributeMapper sMappers = (AbstractSAMLAttributeMapper) mapper;
- if (mapper.getId().equals("MapperForfeduPersonScopedAffiliation")) {
- } else if (mapper.getId().equals("MapperForfeduPersonAssurance")) {
- assertEquals(sMappers.getSAMLName(), "urn:oid:1.3.6.1.4.1.5923.1.1.1.11");
- assertEquals(sMappers.getAttributeFormat(), Attribute.URI_REFERENCE);
- assertEquals(sMappers.getAttributeIds().size(), 2);
- assertEquals(sMappers.getAttributeIds().get(0), "eduPersonAssurance");
- assertEquals(sMappers.getAttributeIds().get(1), "otherPersonAssurance");
- assertTrue(sMappers.getValueMapper() instanceof StringAttributeValueMapper);
- } else if (mapper.getId().equals("MapperForfOeduPersonAssurance")) {
- assertEquals(sMappers.getSAMLName(), "urn:oid:1.3.6.1.4.1.5923.1.1.1.11");
- assertEquals(sMappers.getAttributeFormat(), "http://example.org/Format");
- assertEquals(sMappers.getAttributeIds().size(), 1);
- assertEquals(sMappers.getAttributeIds().get(0), "otherFormatPersonAssurance");
- assertTrue(sMappers.getValueMapper() instanceof StringAttributeValueMapper);
- } else if (mapper.getId().equals("MapperForfotherSAMLName")) {
- assertEquals(sMappers.getSAMLName(), "http://example.org/name/for/Attribute");
- assertEquals(sMappers.getAttributeFormat(), "http://example.org/Format");
- assertEquals(sMappers.getAttributeIds().size(), 1);
- assertEquals(sMappers.getAttributeIds().get(0), "eduPersonAssurance");
- assertTrue(sMappers.getValueMapper() instanceof StringAttributeValueMapper);
- } else if (mapper.getId().equals("MapperForfeduPersonTargetedID")) {
- assertEquals(sMappers.getSAMLName(), "urn:oid:1.3.6.1.4.1.5923.1.1.1.10");
- assertEquals(sMappers.getAttributeFormat(), Attribute.URI_REFERENCE);
- assertEquals(sMappers.getAttributeIds().size(), 1);
- assertEquals(sMappers.getAttributeIds().get(0), "eduPersonTID");
- assertTrue(sMappers.getValueMapper() instanceof XMLObjectAttributeValueMapper);
- } else {
- fail();
- }
- }
- */
-
+ }
}
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list