Skip to content

Commit 3f52c35

Browse files
committed
Merge pull request #330 from arjantijms/master
Updated JASPIC and JACC tests for better Liberty compatibility
2 parents 5f53c52 + dae0efe commit 3f52c35

File tree

11 files changed

+43
-39
lines changed

11 files changed

+43
-39
lines changed

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,20 @@ There are 5 available container profiles:
5252

5353
``-DlibertyManagedArquillian_wlpHome=/opt/wlp``
5454

55-
This profile also requires the localConnector feature to be configured in server.xml, and if all tests are to be run at least the
56-
javaee-7.0 feature and jaspic-1.1 (even though this is part of Java EE 7 already). E.g.
55+
This profile also requires the localConnector feature to be configured in server.xml, and if all tests are to be run the
56+
javaee-7.0 feature E.g.
5757

5858
```xml
5959
<featureManager>
6060
<feature>javaee-7.0</feature>
61-
<feature>jaspic-1.1</feature>
6261
<feature>localConnector-1.0</feature>
6362
</featureManager>
6463
```
6564

66-
For the JASPIC tests to even be attempted to be executed a cheat is needed that creates a user in Liberty's internal user registry:
65+
For the JASPIC tests to even be attempted to be executed a cheat is needed that creates a group in Liberty's internal user registry:
6766

6867
```xml
6968
<basicRegistry id="basic">
70-
<user name="test" password="not needed"/>
7169
<group name="architect"/>
7270
</basicRegistry>
7371
```

jacc/contexts/src/test/java/org/javaee7/jacc/contexts/SubjectFromPolicyContextTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static Archive<?> createDeployment() {
5656
@Test
5757
public void testCanObtainRequestInServlet() throws IOException, SAXException {
5858

59-
String response = getFromServerPath("subjectServlet?doLogin");
59+
String response = getFromServerPath("subjectServlet?doLogin=true");
6060

6161
assertTrue(response.contains("Obtained subject from context."));
6262
}
@@ -68,7 +68,7 @@ public void testCanObtainRequestInServlet() throws IOException, SAXException {
6868
@Test
6969
public void testCanObtainRolesFromSubjectInServlet() throws IOException, SAXException {
7070

71-
String response = getFromServerPath("subjectServlet?doLogin");
71+
String response = getFromServerPath("subjectServlet?doLogin=true");
7272

7373
// The role that was assigned to the user in TestServerAuthModule
7474
assertTrue(response.contains("User has role architect"));

jaspic/basic-authentication/src/test/java/org/javaee7/jaspic/basicauthentication/BasicAuthenticationPublicTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void testPublicPageLoggedin() throws IOException, SAXException {
4949

5050
// JASPIC has to be able to authenticate a user when accessing a public (non-protected) resource.
5151

52-
String response = getFromServerPath("public/servlet?doLogin");
52+
String response = getFromServerPath("public/servlet?doLogin=true");
5353

5454
// Now has to be logged-in
5555
assertTrue(

jaspic/basic-authentication/src/test/java/org/javaee7/jaspic/basicauthentication/BasicAuthenticationStatelessTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void testProtectedAccessIsStateless() throws IOException, SAXException {
5151
// we're not authenticated and it will deny further attempts to authenticate. This may happen when
5252
// the container does not correctly recognize the JASPIC protocol for "do nothing".
5353

54-
response = getFromServerPath("protected/servlet?doLogin");
54+
response = getFromServerPath("protected/servlet?doLogin=true");
5555

5656
// Now has to be logged-in so page is accessible
5757
assertTrue(
@@ -87,7 +87,7 @@ public void testProtectedAccessIsStateless2() throws IOException, SAXException {
8787
// -------------------- Request 1 ---------------------------
8888

8989
// Start with doing a login
90-
String response = getFromServerPath("protected/servlet?doLogin");
90+
String response = getFromServerPath("protected/servlet?doLogin=true");
9191

9292

9393
// -------------------- Request 2 ---------------------------
@@ -134,7 +134,7 @@ public void testPublicAccessIsStateless() throws IOException, SAXException {
134134

135135
// -------------------- Request 2 ---------------------------
136136

137-
response = getFromServerPath("public/servlet?doLogin");
137+
response = getFromServerPath("public/servlet?doLogin=true");
138138

139139
// Now has to be logged-in
140140
assertTrue(
@@ -173,7 +173,7 @@ public void testProtectedThenPublicAccessIsStateless() throws IOException, SAXEx
173173
// -------------------- Request 1 ---------------------------
174174

175175
// Accessing protected page with login
176-
String response = getFromServerPath("protected/servlet?doLogin");
176+
String response = getFromServerPath("protected/servlet?doLogin=true");
177177

178178

179179
// -------------------- Request 2 ---------------------------

jaspic/custom-principal/src/test/java/org/javaee7/jaspictest/customprincipal/CustomPrincipalPublicTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void testPublicPageLoggedin() throws IOException, SAXException {
3232

3333
// JASPIC has to be able to authenticate a user when accessing a public (non-protected) resource.
3434

35-
String response = getFromServerPath("public/servlet?doLogin");
35+
String response = getFromServerPath("public/servlet?doLogin=true");
3636

3737
// Has to be logged-in with the right principal
3838
assertTrue(

jaspic/custom-principal/src/test/java/org/javaee7/jaspictest/customprincipal/CustomPrincipalStatelessTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void testProtectedAccessIsStateless() throws IOException, SAXException {
5252
// we're not authenticated and it will deny further attempts to authenticate. This may happen when
5353
// the container does not correctly recognize the JASPIC protocol for "do nothing".
5454

55-
response = getFromServerPath("protected/servlet?doLogin");
55+
response = getFromServerPath("protected/servlet?doLogin=true");
5656

5757
// Now has to be logged-in so page is accessible
5858
assertTrue("Could not access protected page, but should be able to. "
@@ -83,7 +83,7 @@ public void testProtectedAccessIsStateless2() throws IOException, SAXException {
8383
// -------------------- Request 1 ---------------------------
8484

8585
// Start with doing a login
86-
String response = getFromServerPath("protected/servlet?doLogin");
86+
String response = getFromServerPath("protected/servlet?doLogin=true");
8787

8888
// -------------------- Request 2 ---------------------------
8989

@@ -116,7 +116,7 @@ public void testPublicAccessIsStateless() throws IOException, SAXException {
116116

117117
// -------------------- Request 2 ---------------------------
118118

119-
response = getFromServerPath("public/servlet?doLogin");
119+
response = getFromServerPath("public/servlet?doLogin=true");
120120

121121
// Now has to be logged-in
122122
assertTrue(
@@ -153,7 +153,7 @@ public void testProtectedThenPublicAccessIsStateless() throws IOException, SAXEx
153153
// -------------------- Request 1 ---------------------------
154154

155155
// Accessing protected page with login
156-
String response = getFromServerPath("protected/servlet?doLogin");
156+
String response = getFromServerPath("protected/servlet?doLogin=true");
157157

158158
// -------------------- Request 2 ---------------------------
159159

jaspic/dispatching/src/test/java/org/javaee7/jaspic/dispatching/BasicIncludeTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static Archive<?> createDeployment() {
2727
}
2828

2929
@Test
30-
public void testBasicForwardViaPublicResource() throws IOException, SAXException {
30+
public void testBasicIncludeViaPublicResource() throws IOException, SAXException {
3131

3232
String response = getFromServerPath("public/servlet?dispatch=include");
3333

jaspic/ejb-propagation/src/test/java/org/javaee7/jaspic/ejbpropagation/ProtectedEJBPropagationTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static Archive<?> createDeployment() {
3030
@Test
3131
public void testProtectedServletWithLoginCallingEJB() throws IOException, SAXException {
3232

33-
String response = getFromServerPath("protected/servlet-protected-ejb?doLogin");
33+
String response = getFromServerPath("protected/servlet-protected-ejb?doLogin=true");
3434

3535
// Both the web (HttpServletRequest) and EJB (EJBContext) should see the same
3636
// user name.
@@ -52,7 +52,7 @@ public void testProtectedServletWithLoginCallingEJB() throws IOException, SAXExc
5252
@Test
5353
public void testPublicServletWithLoginCallingEJB() throws IOException, SAXException {
5454

55-
String response = getFromServerPath("public/servlet-protected-ejb?doLogin");
55+
String response = getFromServerPath("public/servlet-protected-ejb?doLogin=true");
5656

5757
// Both the web (HttpServletRequest) and EJB (EJBContext) should see the same
5858
// user name.

jaspic/ejb-propagation/src/test/java/org/javaee7/jaspic/ejbpropagation/PublicEJBPropagationLogoutTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static Archive<?> createDeployment() {
3333
@Test
3434
public void testProtectedServletWithLoginCallingEJB() throws IOException, SAXException {
3535

36-
String response = getFromServerPath("public/servlet-public-ejb-logout?doLogin");
36+
String response = getFromServerPath("public/servlet-public-ejb-logout?doLogin=true");
3737

3838
System.out.println(response);
3939

jaspic/ejb-propagation/src/test/java/org/javaee7/jaspic/ejbpropagation/PublicEJBPropagationTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static Archive<?> createDeployment() {
3030
@Test
3131
public void testProtectedServletWithLoginCallingEJB() throws IOException, SAXException {
3232

33-
String response = getFromServerPath("protected/servlet-public-ejb?doLogin");
33+
String response = getFromServerPath("protected/servlet-public-ejb?doLogin=true");
3434

3535
// Both the web (HttpServletRequest) and EJB (EJBContext) should see the same
3636
// user name.

jaspic/register-session/src/test/java/org/javaee7/jaspic/registersession/RegisterSessionTest.java

+23-17
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ public void testRemembersSession() throws IOException, SAXException {
3636

3737
// We access the protected page again and now login
3838

39-
response = getFromServerPath("protected/servlet?doLogin");
39+
response = getFromServerPath("protected/servlet?doLogin=true");
4040

4141
// Now has to be logged-in so page is accessible
42-
assertTrue("Could not access protected page, but should be able to. "
43-
+ "Did the container remember the previously set 'unauthenticated identity'?",
44-
response.contains("This is a protected servlet"));
42+
assertTrue(
43+
"Could not access protected page, but should be able to. " +
44+
"Did the container remember the previously set 'unauthenticated identity'?",
45+
response.contains("This is a protected servlet")
46+
);
4547

4648
// -------------------- Request 3 ---------------------------
4749

@@ -51,9 +53,11 @@ public void testRemembersSession() throws IOException, SAXException {
5153
response = getFromServerPath("protected/servlet?continueSession");
5254

5355
// Logged-in thus should be accessible.
54-
assertTrue("Could not access protected page, but should be able to. "
55-
+ "Did the container not remember the authenticated identity via 'javax.servlet.http.registerSession'?",
56-
response.contains("This is a protected servlet"));
56+
assertTrue(
57+
"Could not access protected page, but should be able to. " +
58+
"Did the container not remember the authenticated identity via 'javax.servlet.http.registerSession'?",
59+
response.contains("This is a protected servlet")
60+
);
5761

5862
// Both the user name and roles/groups have to be restored
5963

@@ -87,12 +91,14 @@ public void testJoinSessionIsOptional() throws IOException, SAXException {
8791
// We access a protected page and login
8892
//
8993

90-
String response = getFromServerPath("protected/servlet?doLogin");
94+
String response = getFromServerPath("protected/servlet?doLogin=true");
9195

92-
// Now has to be logged-in so page is accessible
93-
assertTrue("Could not access protected page, but should be able to. "
94-
+ "Did the container remember the previously set 'unauthenticated identity'?",
95-
response.contains("This is a protected servlet"));
96+
// Now has to be logged-in so page is accessible
97+
assertTrue(
98+
"Could not access protected page, but should be able to. " +
99+
"Did the container remember the previously set 'unauthenticated identity'?",
100+
response.contains("This is a protected servlet")
101+
);
96102

97103
// -------------------- Request 2 ---------------------------
98104

@@ -102,9 +108,11 @@ public void testJoinSessionIsOptional() throws IOException, SAXException {
102108
response = getFromServerPath("protected/servlet?continueSession");
103109

104110
// Logged-in thus should be accessible.
105-
assertTrue("Could not access protected page, but should be able to. "
106-
+ "Did the container not remember the authenticated identity via 'javax.servlet.http.registerSession'?",
107-
response.contains("This is a protected servlet"));
111+
assertTrue(
112+
"Could not access protected page, but should be able to. " +
113+
"Did the container not remember the authenticated identity via 'javax.servlet.http.registerSession'?",
114+
response.contains("This is a protected servlet")
115+
);
108116

109117
// Both the user name and roles/groups have to be restored
110118

@@ -129,8 +137,6 @@ public void testJoinSessionIsOptional() throws IOException, SAXException {
129137
// Access to a public page is unaffected by joining or not joining the session, but if we do not join the
130138
// session we shouldn't see the user's name and roles.
131139

132-
// THIS NOW FAILS ON GLASSFISH 4.0. CHECKED WITH RON MONZILLO THAT THIS IS INDEED AN ERROR AND FILED A BUG
133-
134140
response = getFromServerPath("public/servlet");
135141

136142
assertTrue(response.contains("This is a public servlet"));

0 commit comments

Comments
 (0)