[java-idp-integration-tests] branch master updated: IDP-1549 - Negative test for anti-csrf token

Phil Smart philip.smart at jisc.ac.uk
Fri Feb 21 06:47:56 EST 2020


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

philsmart pushed a commit to branch master
in repository java-idp-integration-tests.

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

The following commit(s) were added to refs/heads/master by this push:
       new  29d2201   IDP-1549 - Negative test for anti-csrf token
29d2201 is described below

commit 29d220173e486032c9883c0a230c169d428bd8b2
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Fri Feb 21 11:47:01 2020 +0000

    IDP-1549 - Negative test for anti-csrf token
    
     Make test available for v4 or greater only.
    
    https://issues.shibboleth.net/jira/browse/IDP-1549
---
 .../idp/test/ui/csrf/CSRFMitigationTest.java       | 28 ++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/test/java/net/shibboleth/idp/test/ui/csrf/CSRFMitigationTest.java b/src/test/java/net/shibboleth/idp/test/ui/csrf/CSRFMitigationTest.java
index ca990fa..856fc5c 100644
--- a/src/test/java/net/shibboleth/idp/test/ui/csrf/CSRFMitigationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/ui/csrf/CSRFMitigationTest.java
@@ -74,15 +74,15 @@ public class CSRFMitigationTest extends BaseIntegrationTest {
     /**
      * 
      * Check that a username/password login form submitted without an anti-csrf token renders the invalid CSRF token page.
-     * <p>Currently for v4 only</p>
+     * <p>Only runs for IdP v4 or greater</p>
      * 
      * @param browserData the browser data
      * @throws Exception on exception
      */
     @Test(dataProvider = "sauceOnDemandBrowserDataProvider")
     public void testCSRFTokenRemovedFromLoginPage(@Nullable final BrowserData browserData) throws Exception {
-
-        if (idpVersion.startsWith("4")) {
+        
+        if (getMajorIdPVersionAsInt() >= 4) {
          
             startSeleniumClient(browserData);
             
@@ -93,12 +93,32 @@ public class CSRFMitigationTest extends BaseIntegrationTest {
             
             startServer();
             startFlow();
-            waitForLoginPage();
+            waitForLoginPage(); 
             removeCSRFTokenAndlogin("jdoe","changeit");
             checkCSRFErrorPage();
         
         }
     }
+    
+    /**
+     * Get the IdP Major version from <code>idpVersion</code> as an int.
+     * 
+     * @return the IdP major version as an int.
+     * 
+     * @throws Exception if it could not be converted.
+     */
+    private int getMajorIdPVersionAsInt() throws Exception{
+        
+        if (idpVersion!=null) {
+            String[] splitVersion = idpVersion.split("\\.");
+            if (splitVersion.length>0) {
+                String majorVersionString = splitVersion[0];
+                return Integer.parseInt(majorVersionString);               
+            }
+        }
+        throw new Exception("Could not get IdP major version as int");
+        
+    }
 
     /**
      * <p>Check the CSRF error page is displayed.</p>

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


More information about the commits mailing list