Skip to content

Commit 0146ad2

Browse files
author
Nicolo
committed
#80 Junit to verify a null logout response url will return the default logout url by default
1 parent cf0af5c commit 0146ad2

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

toolkit/src/test/java/com/onelogin/saml2/test/AuthTest.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,10 @@ public void testGetSLOurl() throws URISyntaxException, IOException, SettingsExce
299299
* @throws URISyntaxException
300300
* @throws SettingsException
301301
*
302-
* @see com.onelogin.saml2.Auth#getSLOurl
302+
* @see com.onelogin.saml2.Auth#getSLOResponseUrl
303303
*/
304304
@Test
305-
public void testGetSLOResponseurl() throws URISyntaxException, IOException, SettingsException {
305+
public void testGetSLOResponseUrl() throws URISyntaxException, IOException, SettingsException {
306306
HttpServletRequest request = mock(HttpServletRequest.class);
307307
HttpServletResponse response = mock(HttpServletResponse.class);
308308
String samlResponseEncoded = Util.getFileAsString("data/responses/response1.xml.base64");
@@ -314,6 +314,28 @@ public void testGetSLOResponseurl() throws URISyntaxException, IOException, Sett
314314
assertEquals("http://idp.example.com/simplesaml/saml2/idp/SingleLogoutServiceResponse.php", auth.getSLOResponseUrl());
315315
}
316316

317+
/**
318+
* Tests the getSLOResponseUrl method of Auth. Verifies a null value will return the same output as getSLOurl()
319+
*
320+
* @throws IOException
321+
* @throws URISyntaxException
322+
* @throws SettingsException
323+
*
324+
* @see com.onelogin.saml2.Auth#getSLOResponseUrl
325+
*/
326+
@Test
327+
public void testGetSLOResponseUrlNull() throws URISyntaxException, IOException, SettingsException {
328+
HttpServletRequest request = mock(HttpServletRequest.class);
329+
HttpServletResponse response = mock(HttpServletResponse.class);
330+
String samlResponseEncoded = Util.getFileAsString("data/responses/response1.xml.base64");
331+
when(request.getParameterMap()).thenReturn(singletonMap("SAMLResponse", new String[]{samlResponseEncoded}));
332+
333+
Saml2Settings settings = new SettingsBuilder().fromFile("config/config.min.properties").build();
334+
335+
Auth auth = new Auth(settings, request, response);
336+
assertEquals("http://idp.example.com/simplesaml/saml2/idp/SingleLogoutService.php", auth.getSLOResponseUrl());
337+
}
338+
317339
/**
318340
* Tests the processResponse method of Auth
319341
*

0 commit comments

Comments
 (0)