@@ -1283,7 +1283,7 @@ public void testLogin() throws IOException, SettingsException, URISyntaxExceptio
12831283 HttpServletResponse response = mock (HttpServletResponse .class );
12841284 when (request .getScheme ()).thenReturn ("http" );
12851285 when (request .getServerPort ()).thenReturn (8080 );
1286- when (request .getServerName ()).thenReturn ("localhost" );
1286+ when (request .getServerName ()).thenReturn ("localhost" );
12871287 when (request .getRequestURI ()).thenReturn ("/initial.jsp" );
12881288
12891289 Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.my.properties" ).build ();
@@ -1311,7 +1311,7 @@ public void testLoginWithRelayState() throws IOException, SettingsException, URI
13111311 HttpServletResponse response = mock (HttpServletResponse .class );
13121312 when (request .getScheme ()).thenReturn ("http" );
13131313 when (request .getServerPort ()).thenReturn (8080 );
1314- when (request .getServerName ()).thenReturn ("localhost" );
1314+ when (request .getServerName ()).thenReturn ("localhost" );
13151315 when (request .getRequestURI ()).thenReturn ("/initial.jsp" );
13161316
13171317 Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.my.properties" ).build ();
@@ -1354,6 +1354,37 @@ public void testLoginWithoutRelayState() throws IOException, SettingsException,
13541354 assertThat (urlCaptor .getValue (), not (containsString ("&RelayState=" )));
13551355 }
13561356
1357+ /**
1358+ * Tests the login method of Auth
1359+ * Case: Login with extra parameters
1360+ *
1361+ * @throws SettingsException
1362+ * @throws IOException
1363+ * @throws URISyntaxException
1364+ * @throws Error
1365+ *
1366+ * @see com.onelogin.saml2.Auth#login
1367+ */
1368+ @ Test
1369+ public void testLoginWithExtraParameters () throws IOException , SettingsException , URISyntaxException , Error {
1370+ HttpServletRequest request = mock (HttpServletRequest .class );
1371+ HttpServletResponse response = mock (HttpServletResponse .class );
1372+ when (request .getScheme ()).thenReturn ("http" );
1373+ when (request .getServerPort ()).thenReturn (8080 );
1374+ when (request .getServerName ()).thenReturn ("localhost" );
1375+ when (request .getRequestURI ()).thenReturn ("/initial.jsp" );
1376+
1377+ Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.my.properties" ).build ();
1378+ settings .setAuthnRequestsSigned (false );
1379+
1380+ Auth auth = new Auth (settings , request , response );
1381+ Map <String , String > extraParameters = new HashMap <String , String >();
1382+ extraParameters .put ("parameter1" , "xxx" );
1383+ String target = auth .login ("" , false , false , false , true , null , extraParameters );
1384+ assertThat (target , startsWith ("https://pitbulk.no-ip.org/simplesaml/saml2/idp/SSOService.php?SAMLRequest=" ));
1385+ assertThat (target , containsString ("¶meter1=xxx" ));
1386+ }
1387+
13571388 /**
13581389 * Tests the login method of Auth
13591390 * Case: Login with stay enabled
@@ -1454,7 +1485,7 @@ public void testLoginSignedFail() throws IOException, SettingsException, URISynt
14541485 HttpServletResponse response = mock (HttpServletResponse .class );
14551486 when (request .getScheme ()).thenReturn ("http" );
14561487 when (request .getServerPort ()).thenReturn (8080 );
1457- when (request .getServerName ()).thenReturn ("localhost" );
1488+ when (request .getServerName ()).thenReturn ("localhost" );
14581489 when (request .getRequestURI ()).thenReturn ("/initial.jsp" );
14591490
14601491 Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.min.properties" ).build ();
@@ -1483,7 +1514,7 @@ public void testLoginSigned() throws IOException, SettingsException, URISyntaxEx
14831514 HttpServletResponse response = mock (HttpServletResponse .class );
14841515 when (request .getScheme ()).thenReturn ("http" );
14851516 when (request .getServerPort ()).thenReturn (8080 );
1486- when (request .getServerName ()).thenReturn ("localhost" );
1517+ when (request .getServerName ()).thenReturn ("localhost" );
14871518 when (request .getRequestURI ()).thenReturn ("/initial.jsp" );
14881519
14891520 Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.my.properties" ).build ();
@@ -1517,7 +1548,7 @@ public void testLogout() throws IOException, SettingsException, XMLEntityExcepti
15171548 HttpServletResponse response = mock (HttpServletResponse .class );
15181549 when (request .getScheme ()).thenReturn ("http" );
15191550 when (request .getServerPort ()).thenReturn (8080 );
1520- when (request .getServerName ()).thenReturn ("localhost" );
1551+ when (request .getServerName ()).thenReturn ("localhost" );
15211552 when (request .getRequestURI ()).thenReturn ("/initial.jsp" );
15221553
15231554 Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.my.properties" ).build ();
@@ -1529,6 +1560,36 @@ public void testLogout() throws IOException, SettingsException, XMLEntityExcepti
15291560 assertThat (auth .getLastRequestId (), startsWith (Util .UNIQUE_ID_PREFIX ));
15301561 }
15311562
1563+ /**
1564+ * Tests the logout method of Auth
1565+ * Case: Logout with no parameters
1566+ *
1567+ * @throws IOException
1568+ * @throws SettingsException
1569+ * @throws XMLEntityException
1570+ * @throws Error
1571+ *
1572+ * @see com.onelogin.saml2.Auth#logout
1573+ */
1574+ @ Test
1575+ public void testLogoutWithExtraParameters () throws IOException , SettingsException , XMLEntityException , Error {
1576+ HttpServletRequest request = mock (HttpServletRequest .class );
1577+ HttpServletResponse response = mock (HttpServletResponse .class );
1578+ when (request .getScheme ()).thenReturn ("http" );
1579+ when (request .getServerPort ()).thenReturn (8080 );
1580+ when (request .getServerName ()).thenReturn ("localhost" );
1581+ when (request .getRequestURI ()).thenReturn ("/initial.jsp" );
1582+
1583+ Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.my.properties" ).build ();
1584+ settings .setLogoutRequestSigned (false );
1585+ Auth auth = new Auth (settings , request , response );
1586+ Map <String , String > extraParameters = new HashMap <String , String >();
1587+ extraParameters .put ("parameter1" , "xxx" );
1588+ String target = auth .logout ("" , null , null , true , null , null , null , extraParameters );
1589+ assertThat (target , startsWith ("https://pitbulk.no-ip.org/simplesaml/saml2/idp/SingleLogoutService.php?SAMLRequest=" ));
1590+ assertThat (target , containsString ("¶meter1=xxx" ));
1591+ }
1592+
15321593 /**
15331594 * Tests the logout method of Auth
15341595 * Case: Logout with RelayState
@@ -1546,7 +1607,7 @@ public void testLogoutWithRelayState() throws IOException, SettingsException, XM
15461607 HttpServletResponse response = mock (HttpServletResponse .class );
15471608 when (request .getScheme ()).thenReturn ("http" );
15481609 when (request .getServerPort ()).thenReturn (8080 );
1549- when (request .getServerName ()).thenReturn ("localhost" );
1610+ when (request .getServerName ()).thenReturn ("localhost" );
15501611 when (request .getRequestURI ()).thenReturn ("/initial.jsp" );
15511612
15521613 Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.my.properties" ).build ();
@@ -1608,7 +1669,7 @@ public void testLogoutStay() throws IOException, SettingsException, XMLEntityExc
16081669 HttpServletResponse response = mock (HttpServletResponse .class );
16091670 when (request .getScheme ()).thenReturn ("http" );
16101671 when (request .getServerPort ()).thenReturn (8080 );
1611- when (request .getServerName ()).thenReturn ("localhost" );
1672+ when (request .getServerName ()).thenReturn ("localhost" );
16121673 when (request .getRequestURI ()).thenReturn ("/initial.jsp" );
16131674
16141675 Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.my.properties" ).build ();
@@ -1642,7 +1703,7 @@ public void testLogoutSignedFail() throws IOException, SettingsException, XMLEnt
16421703 HttpServletResponse response = mock (HttpServletResponse .class );
16431704 when (request .getScheme ()).thenReturn ("http" );
16441705 when (request .getServerPort ()).thenReturn (8080 );
1645- when (request .getServerName ()).thenReturn ("localhost" );
1706+ when (request .getServerName ()).thenReturn ("localhost" );
16461707 when (request .getRequestURI ()).thenReturn ("/initial.jsp" );
16471708
16481709 Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.min.properties" ).build ();
@@ -1671,7 +1732,7 @@ public void testLogoutSigned() throws IOException, SettingsException, XMLEntityE
16711732 HttpServletResponse response = mock (HttpServletResponse .class );
16721733 when (request .getScheme ()).thenReturn ("http" );
16731734 when (request .getServerPort ()).thenReturn (8080 );
1674- when (request .getServerName ()).thenReturn ("localhost" );
1735+ when (request .getServerName ()).thenReturn ("localhost" );
16751736 when (request .getRequestURI ()).thenReturn ("/initial.jsp" );
16761737
16771738 Saml2Settings settings = new SettingsBuilder ().fromFile ("config/config.my.properties" ).build ();
0 commit comments