[java-idp-integration-tests] 07/07: IDP-1708 Fix tests

Tom Zeller tzeller at dragonacea.biz
Wed May 5 20:46:45 UTC 2021


This is an automated email from the git hooks/post-receive script.

tzeller pushed a commit to branch main
in repository java-idp-integration-tests.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-integration-tests.git;a=commit;h=9c9f25418617c36d330c3b8a93edab2e6b79e80c

commit 9c9f25418617c36d330c3b8a93edab2e6b79e80c
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Wed May 5 15:14:45 2021 -0500

    IDP-1708 Fix tests
    
    https://issues.shibboleth.net/jira/browse/IDP-1708
---
 .../saml2/SAML2AttributeQueryIntegrationTest.java  | 59 +++++++++++-----------
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/src/test/java/net/shibboleth/idp/test/saml2/SAML2AttributeQueryIntegrationTest.java b/src/test/java/net/shibboleth/idp/test/saml2/SAML2AttributeQueryIntegrationTest.java
index a9b2d4b..5ceda81 100644
--- a/src/test/java/net/shibboleth/idp/test/saml2/SAML2AttributeQueryIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/saml2/SAML2AttributeQueryIntegrationTest.java
@@ -62,6 +62,9 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(SAML2AttributeQueryIntegrationTest.class);
 
+    /** Validator to use for empty responses. */
+    @Nullable private SAML2TestStatusResponseTypeValidator emptyValidator;
+
     /** Validator to use for error responses. */
     @Nullable private SAML2TestStatusResponseTypeValidator errorValidator;
 
@@ -105,6 +108,8 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
         errorValidator = new SAML2TestResponseValidator();
         errorValidator.statusCode = StatusCode.REQUESTER;
 
+        emptyValidator = new SAML2TestResponseValidator();
+
         ssoValidator = new SAML2TestResponseValidator();
         ssoValidator.spCredential = getSPCredential();
         ssoValidator.authnContextClassRef = AuthnContext.PPT_AUTHN_CTX;
@@ -295,10 +300,26 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
         waitForPageURLContains("/sp/SAML2/AttributeQuery");
     }
 
+    /**
+     * Validate 2 SSO {@link Response} with no assertions.
+     * 
+     * @throws Exception if the response is unable to be verified
+     */
+    protected void validateEmptyResponse() throws Exception {
+
+        log.debug("Empty response:\n{}", getPageSource());
+
+        final Response response = unmarshallResponse(getPageSource());
+
+        emptyValidator.validateResponse(response);
+
+        Assert.assertTrue(response.getAssertions().isEmpty());
+    }
+
     /**
      * Validate SAML error response.
      * 
-     * @throws Exception if something bad happens
+     * @throws Exception if the response is unable to be verified
      */
     protected void validateErrorResponse() throws Exception {
         
@@ -312,7 +333,7 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
     /**
      * Validate SAML 2 SSO {@link Response}.
      * 
-     * @throws Exception if something bad happens
+     * @throws Exception if the response is unable to be verified
      */
     protected void validateSSOResponse() throws Exception {
         ssoValidator.validateResponse(super.unmarshallResponse(getPageSource()));
@@ -562,13 +583,9 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
 
         setClientSigningPrivateKey(trustedSpKey);
 
-        // attribute query, should return an error since there are no consent storage records
-
         submitAttributeQueryForm();
 
-        errorValidator.statusCode = StatusCode.RESPONDER;
-
-        validateErrorResponse();
+        validateEmptyResponse();
     }
 
     @Test(dataProvider = "sauceOnDemandBrowserDataProvider")
@@ -588,13 +605,9 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
 
         setClientSigningPrivateKey(trustedSpKey);
 
-        // attribute query, should return an error since there are no consent storage records
-
         submitAttributeQueryForm();
 
-        errorValidator.statusCode = StatusCode.RESPONDER;
-
-        validateErrorResponse();
+        validateEmptyResponse();
 
         // start SSO
 
@@ -618,15 +631,13 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
 
         validateSSOResponse();
 
-        // attribute query, should return an error since there are no consent storage records
-
         getAndWaitForTestbedPage();
 
         adjustEndpointPort();
 
         submitAttributeQueryForm();
 
-        validateErrorResponse();
+        validateEmptyResponse();
     }
 
     @Test(dataProvider = "sauceOnDemandBrowserDataProvider")
@@ -646,13 +657,9 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
 
         setClientSigningPrivateKey(trustedSpKey);
 
-        // attribute query, should return an error since there are no consent storage records
-
         submitAttributeQueryForm();
 
-        errorValidator.statusCode = StatusCode.RESPONDER;
-
-        validateErrorResponse();
+        validateEmptyResponse();
 
         // start SSO
 
@@ -704,13 +711,9 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
 
         setClientSigningPrivateKey(trustedSpKey);
 
-        // attribute query, should return an error since there are no consent storage records
-
         submitAttributeQueryForm();
 
-        errorValidator.statusCode = StatusCode.RESPONDER;
-
-        validateErrorResponse();
+        validateEmptyResponse();
 
         // start SSO
 
@@ -764,13 +767,9 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
 
         setClientSigningPrivateKey(trustedSpKey);
 
-        // attribute query, should return an error since there are no consent storage records
-
         submitAttributeQueryForm();
 
-        errorValidator.statusCode = StatusCode.RESPONDER;
-
-        validateErrorResponse();
+        validateEmptyResponse();
 
         // start SSO
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list