8000 Clearer messages for when denied test fails · javaee-samples/javaee7-samples@207fe5b · GitHub
[go: up one dir, main page]

Skip to content

Commit 207fe5b

Browse files
committed
Clearer messages for when denied test fails
Signed-off-by: arjantijms <arjan.tijms@gmail.com>
1 parent 8bdef70 commit 207fe5b

File tree

1 file changed

+8
-2
lines changed
  • servlet/security-deny-uncovered/src/test/java/org/javaee7/servlet/security/deny/uncovered

1 file changed

+8
-2
lines changed

servlet/security-deny-uncovered/src/test/java/org/javaee7/servlet/security/deny/uncovered/SecureServletTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.javaee7.ServerOperations.addUsersToContainerIdentityStore;
66
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
77
import static org.junit.Assert.assertEquals;
8+
import static org.junit.Assert.assertFalse;
89
import static org.junit.Assert.assertNotNull;
910
import static org.junit.Assert.fail;
1011

@@ -78,16 +79,21 @@ public void testPostMethod() throws Exception {
7879
webClient.setCredentialsProvider(correctCreds);
7980
WebRequest request = new WebRequest(new URL(base + "SecureServlet"), POST);
8081

82+
TextPage p = null;
8183
try {
82-
TextPage p = webClient.getPage(request);
84+
p = webClient.getPage(request);
8385
System.out.println(p.getContent());
86+
87+
assertFalse(
88+
"POST method could be called even with deny-uncovered-http-methods",
89+
p.getContent().contains("my POST"));
8490
} catch (FailingHttpStatusCodeException e) {
8591
assertNotNull(e);
8692
assertEquals(403, e.getStatusCode());
8793
return;
8894
}
8995

90-
fail("POST method could be called even with deny-uncovered-http-methods");
96+
fail("POST correctly not called, but wrong status code: " + (p != null ? p.getWebResponse().getStatusCode() : -1));
9197
}
9298

9399
@Test

0 commit comments

Comments
 (0)
0