Skip to content

Commit b024deb

Browse files
committed
Place the throw exception check before the Auth constructor since it raises the error
1 parent e27901c commit b024deb

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

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

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -868,14 +868,10 @@ public void testGetNameIDEncWithNoKey() throws Exception {
868868
when(request.getParameterMap()).thenReturn(singletonMap("SAMLResponse", new String[]{samlResponseEncoded}));
869869
when(request.getRequestURL()).thenReturn(new StringBuffer("https://pitbulk.no-ip.org/newonelogin/demo1/index.php?acs"));
870870
settings.setStrict(false);
871-
Auth auth = new Auth(settings, request, response);
872-
873-
expectedEx.expect(SettingsException.class); // TODO check; new Auth() above throws, the code below is not called and does not test getNameId()
871+
872+
expectedEx.expect(SettingsException.class);
874873
expectedEx.expectMessage("Invalid settings: idp_cert_not_found_and_required");
875-
assertNull(auth.getNameId());
876-
auth.processResponse();
877-
assertFalse(auth.isAuthenticated());
878-
assertNull(auth.getNameId());
874+
Auth auth = new Auth(settings, request, response);
879875
}
880876

881877
/**
@@ -894,13 +890,10 @@ public void testOnlyRetrieveAssertionWithIDThatMatchesSignatureReference() throw
894890
when(request.getRequestURL()).thenReturn(new StringBuffer("http://localhost:8080/java-saml-jspsample/acs.jsp"));
895891

896892
Saml2Settings settings = new SettingsBuilder().fromFile("config/config.my.properties").build();
897-
Auth auth = new Auth(settings, request, response);
898893

899-
expectedEx.expect(ValidationError.class); // TODO check; processResponse() throws, the asserts below are not called
894+
expectedEx.expect(ValidationError.class);
900895
expectedEx.expectMessage("SAML Response could not be processed");
901-
auth.processResponse();
902-
// assertFalse(auth.isAuthenticated());
903-
// assertFalse("root@example.com".equals(auth.getNameId()));
896+
Auth auth = new Auth(settings, request, response);
904897
}
905898

906899
/**
@@ -1126,12 +1119,10 @@ public void testLoginSignedFail() throws IOException, SettingsException, URISynt
11261119
Saml2Settings settings = new SettingsBuilder().fromFile("config/config.min.properties").build();
11271120
settings.setAuthnRequestsSigned(true);
11281121
settings.setSignatureAlgorithm(Constants.RSA_SHA1);
1129-
Auth auth = new Auth(settings, request, response);
1130-
String relayState = "http://localhost:8080/expected.jsp";
1131-
1132-
expectedEx.expect(SettingsException.class); // TODO check; the login() below is not called because new Auth() above throws
1122+
1123+
expectedEx.expect(SettingsException.class);
11331124
expectedEx.expectMessage("Invalid settings: sp_cert_not_found_and_required");
1134-
auth.login(relayState);
1125+
Auth auth = new Auth(settings, request, response);
11351126
}
11361127

11371128
/**
@@ -1316,12 +1307,10 @@ public void testLogoutSignedFail() throws IOException, SettingsException, XMLEnt
13161307
Saml2Settings settings = new SettingsBuilder().fromFile("config/config.min.properties").build();
13171308
settings.setLogoutRequestSigned(true);
13181309
settings.setSignatureAlgorithm(Constants.RSA_SHA1);
1319-
Auth auth = new Auth(settings, request, response);
1320-
String relayState = "http://localhost:8080/expected.jsp";
1321-
1322-
expectedEx.expect(SettingsException.class); // TODO check; auth.logout() below is not called because new Auth() above throws
1310+
1311+
expectedEx.expect(SettingsException.class);
13231312
expectedEx.expectMessage("Invalid settings: sp_cert_not_found_and_required");
1324-
auth.logout(relayState);
1313+
Auth auth = new Auth(settings, request, response);
13251314
}
13261315

13271316
/**

0 commit comments

Comments
 (0)