[java-identity-provider COMMIT] /trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/profile/impl/PopulateBindi...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Aug 20 10:55:47 EDT 2014
Author: scantor
Date: Wed Aug 20 10:55:47 2014
New Revision: 6448
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=6448&view=rev
Log:
Fix tests by aligning anonymity checking to state of context in real flow.
Modified:
trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/profile/impl/PopulateBindingAndEndpointContextsTest.java
Modified: trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/profile/impl/PopulateBindingAndEndpointContextsTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/profile/impl/PopulateBindingAndEndpointContextsTest.java?rev=6448&r1=6447&r2=6448&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/profile/impl/PopulateBindingAndEndpointContextsTest.java (original)
+++ trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/profile/impl/PopulateBindingAndEndpointContextsTest.java Wed Aug 20 10:55:47 2014
@@ -29,6 +29,7 @@
import net.shibboleth.idp.profile.ActionTestingSupport;
import net.shibboleth.idp.profile.RequestContextBuilder;
+import net.shibboleth.idp.profile.context.RelyingPartyContext;
import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
@@ -48,8 +49,7 @@
import org.opensaml.saml.common.profile.SAMLEventIds;
import org.opensaml.saml.common.xml.SAMLConstants;
import org.opensaml.saml.saml2.core.AuthnRequest;
-import org.opensaml.saml.saml2.metadata.RoleDescriptor;
-import org.opensaml.saml.saml2.metadata.SPSSODescriptor;
+import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.opensaml.saml.saml2.profile.SAML2ActionTestingSupport;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
@@ -83,6 +83,11 @@
rc = new RequestContextBuilder().setInboundMessage(request).buildRequestContext();
prc = new WebflowRequestContextProfileRequestContextLookup().apply(rc);
prc.getInboundMessageContext().getSubcontext(SAMLBindingContext.class, true).setRelayState(RELAY_STATE);
+
+ // Set these up so the context will be seen as anonymous or not based on metadata in the outbound context.
+ prc.getSubcontext(RelyingPartyContext.class).setAnonymityLookupStrategy(new SAMLAnonymityLookupStrategy());
+ prc.getSubcontext(RelyingPartyContext.class).setRelyingPartyIdContextTree(
+ prc.getOutboundMessageContext().getSubcontext(SAMLPeerEntityContext.class, true));
action = new PopulateBindingAndEndpointContexts();
action.setEndpointResolver(new DefaultEndpointResolver());
@@ -133,15 +138,29 @@
@Test
public void testNoMetadata() {
final Event event = action.execute(rc);
- ActionTestingSupport.assertEvent(event, SAMLEventIds.ENDPOINT_RESOLUTION_FAILED);
+ ActionTestingSupport.assertProceedEvent(event);
+
+ final SAMLBindingContext bindingCtx = prc.getOutboundMessageContext().getSubcontext(SAMLBindingContext.class);
+ Assert.assertNotNull(bindingCtx);
+ Assert.assertNotNull(bindingCtx.getBindingDescriptor());
+ Assert.assertEquals(bindingCtx.getRelayState(), RELAY_STATE);
+ Assert.assertEquals(bindingCtx.getBindingUri(), SAMLConstants.SAML2_POST_BINDING_URI);
+
+ final SAMLEndpointContext epCtx = prc.getOutboundMessageContext().getSubcontext(
+ SAMLPeerEntityContext.class, false).getSubcontext(SAMLEndpointContext.class, false);
+ Assert.assertNotNull(epCtx);
+ Assert.assertNotNull(epCtx.getEndpoint());
+ Assert.assertEquals(epCtx.getEndpoint().getBinding(), SAMLConstants.SAML2_POST_BINDING_URI);
+ Assert.assertEquals(epCtx.getEndpoint().getLocation(), LOCATION_POST);
}
/** An SP with no endpoints in metadata. */
@Test
public void testNoEndpoints() throws UnmarshallingException {
- final RoleDescriptor role = loadMetadata("/net/shibboleth/idp/saml/impl/profile/SPNoEndpoints.xml");
- final SAMLMetadataContext mdCtx = new SAMLMetadataContext();
- mdCtx.setRoleDescriptor(role);
+ final EntityDescriptor entity = loadMetadata("/net/shibboleth/idp/saml/impl/profile/SPNoEndpoints.xml");
+ final SAMLMetadataContext mdCtx = new SAMLMetadataContext();
+ mdCtx.setEntityDescriptor(entity);
+ mdCtx.setRoleDescriptor(entity.getSPSSODescriptor("required"));
prc.getOutboundMessageContext().getSubcontext(SAMLPeerEntityContext.class, true).addSubcontext(mdCtx);
final Event event = action.execute(rc);
@@ -151,9 +170,10 @@
/** No endpoint with the location requested. */
@Test
public void testBadLocation() throws UnmarshallingException {
[... 139 lines stripped ...]
More information about the commits
mailing list