Skip to content

Commit

Permalink
Changed login to doLogin=true for Liberty compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
arjantijms committed Nov 12, 2015
1 parent 7270296 commit fad4e9b
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static Archive<?> createDeployment() {
@Test
public void testCanObtainRequestInServlet() throws IOException, SAXException {

String response = getFromServerPath("subjectServlet?doLogin");
String response = getFromServerPath("subjectServlet?doLogin=true");

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

String response = getFromServerPath("subjectServlet?doLogin");
String response = getFromServerPath("subjectServlet?doLogin=true");

// The role that was assigned to the user in TestServerAuthModule
assertTrue(response.contains("User has role architect"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testPublicPageLoggedin() throws IOException, SAXException {

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

String response = getFromServerPath("public/servlet?doLogin");
String response = getFromServerPath("public/servlet?doLogin=true");

// Now has to be logged-in
assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void testProtectedAccessIsStateless() throws IOException, SAXException {
// we're not authenticated and it will deny further attempts to authenticate. This may happen when
// the container does not correctly recognize the JASPIC protocol for "do nothing".

response = getFromServerPath("protected/servlet?doLogin");
response = getFromServerPath("protected/servlet?doLogin=true");

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

// Start with doing a login
String response = getFromServerPath("protected/servlet?doLogin");
String response = getFromServerPath("protected/servlet?doLogin=true");


// -------------------- Request 2 ---------------------------
Expand Down Expand Up @@ -134,7 +134,7 @@ public void testPublicAccessIsStateless() throws IOException, SAXException {

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

response = getFromServerPath("public/servlet?doLogin");
response = getFromServerPath("public/servlet?doLogin=true");

// Now has to be logged-in
assertTrue(
Expand Down Expand Up @@ -173,7 +173,7 @@ public void testProtectedThenPublicAccessIsStateless() throws IOException, SAXEx
// -------------------- Request 1 ---------------------------

// Accessing protected page with login
String response = getFromServerPath("protected/servlet?doLogin");
String response = getFromServerPath("protected/servlet?doLogin=true");


// -------------------- Request 2 ---------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void testPublicPageLoggedin() throws IOException, SAXException {

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

String response = getFromServerPath("public/servlet?doLogin");
String response = getFromServerPath("public/servlet?doLogin=true");

// Has to be logged-in with the right principal
assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testProtectedAccessIsStateless() throws IOException, SAXException {
// we're not authenticated and it will deny further attempts to authenticate. This may happen when
// the container does not correctly recognize the JASPIC protocol for "do nothing".

response = getFromServerPath("protected/servlet?doLogin");
response = getFromServerPath("protected/servlet?doLogin=true");

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

// Start with doing a login
String response = getFromServerPath("protected/servlet?doLogin");
String response = getFromServerPath("protected/servlet?doLogin=true");

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

Expand Down Expand Up @@ -116,7 +116,7 @@ public void testPublicAccessIsStateless() throws IOException, SAXException {

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

response = getFromServerPath("public/servlet?doLogin");
response = getFromServerPath("public/servlet?doLogin=true");

// Now has to be logged-in
assertTrue(
Expand Down Expand Up @@ -153,7 +153,7 @@ public void testProtectedThenPublicAccessIsStateless() throws IOException, SAXEx
// -------------------- Request 1 ---------------------------

// Accessing protected page with login
String response = getFromServerPath("protected/servlet?doLogin");
String response = getFromServerPath("protected/servlet?doLogin=true");

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static Archive<?> createDeployment() {
@Test
public void testProtectedServletWithLoginCallingEJB() throws IOException, SAXException {

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

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

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

// Both the web (HttpServletRequest) and EJB (EJBContext) should see the same
// user name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static Archive<?> createDeployment() {
@Test
public void testProtectedServletWithLoginCallingEJB() throws IOException, SAXException {

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

System.out.println(response);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static Archive<?> createDeployment() {
@Test
public void testProtectedServletWithLoginCallingEJB() throws IOException, SAXException {

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

// Both the web (HttpServletRequest) and EJB (EJBContext) should see the same
// user name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ public void testRemembersSession() throws IOException, SAXException {

// We access the protected page again and now login

response = getFromServerPath("protected/servlet?doLogin");
response = getFromServerPath("protected/servlet?doLogin=true");

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

// -------------------- Request 3 ---------------------------

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

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

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

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

String response = getFromServerPath("protected/servlet?doLogin");
String response = getFromServerPath("protected/servlet?doLogin=true");

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

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

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

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

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

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

// THIS NOW FAILS ON GLASSFISH 4.0. CHECKED WITH RON MONZILLO THAT THIS IS INDEED AN ERROR AND FILED A BUG

response = getFromServerPath("public/servlet");

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

0 comments on commit fad4e9b

Please sign in to comment.