Skip to content
Browse files

Change test to not rely on text in the error pages

  • Loading branch information...
1 parent b0a19b7 commit 1fbf1ef78e9e0682da9714a8a479eda3a2821437 @stuartwdouglas stuartwdouglas committed with kabir Mar 12, 2013
View
39 ...org/jboss/as/test/integration/ws/authentication/EJBEndpointSecuredWSDLAccessTestCase.java
@@ -62,7 +62,7 @@
.addAsResource(EJBEndpointSecuredWSDLAccessTestCase.class.getPackage(), "users.properties", "users.properties")
.addAsResource(EJBEndpointSecuredWSDLAccessTestCase.class.getPackage(), "roles.properties", "roles.properties")
.addClasses(EJBEndpointIface.class, EJBEndpointSecuredWSDLAccess.class);
-
+
return jar;
}
@@ -80,63 +80,66 @@ public void createService() throws Exception {
// failure is expected
}
}
-
+
@Test
public void accessWSDLWithValidUsernameAndPassord() throws Exception {
URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-ejb3-for-wsdl/EJB3ServiceForWSDL?wsdl");
String encoding = Base64Encoder.encode("user1:password1");
-
+
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(wsdlURL.toString());
httpget.setHeader("Authorization", "Basic " + encoding);
HttpResponse response = httpclient.execute(httpget);
String text = Utils.getContent(response);
Assert.assertTrue("Response doesn't contain wsdl file", text.contains("wsdl:binding"));
-
+
}
-
+
@Test
public void accessWSDLWithValidUsernameAndPassordButInvalidRole() throws Exception {
URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-ejb3-for-wsdl/EJB3ServiceForWSDL?wsdl");
String encoding = Base64Encoder.encode("user2:password2");
-
+
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(wsdlURL.toString());
httpget.setHeader("Authorization", "Basic " + encoding);
HttpResponse response = httpclient.execute(httpget);
+ Assert.assertEquals(403, response.getStatusLine().getStatusCode());
+
+ Utils.getContent(response);
+ //Assert.assertTrue("Response doesn't contain access denied message", text.contains("Access to the requested resource has been denied"));
- String text = Utils.getContent(response);
- Assert.assertTrue("Response doesn't contain access denied message", text.contains("Access to the requested resource has been denied"));
-
}
@Test
public void accessWSDLWithInvalidUsernameAndPassord() throws Exception {
URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-ejb3-for-wsdl/EJB3ServiceForWSDL?wsdl");
String encoding = Base64Encoder.encode("user1:password-XZY");
-
+
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(wsdlURL.toString());
httpget.setHeader("Authorization", "Basic " + encoding);
HttpResponse response = httpclient.execute(httpget);
+ Assert.assertEquals(401, response.getStatusLine().getStatusCode());
- String text = Utils.getContent(response);
- Assert.assertTrue("Response doesn't contain expected message.", text.contains("This request requires HTTP authentication"));
+ Utils.getContent(response);
+ //Assert.assertTrue("Response doesn't contain expected message.", text.contains("This request requires HTTP authentication"));
}
-
+
@Test
public void accessWSDLWithoutUsernameAndPassord() throws Exception {
URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-ejb3-for-wsdl/EJB3ServiceForWSDL?wsdl");
-
+
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(wsdlURL.toString());
HttpResponse response = httpclient.execute(httpget);
+ Assert.assertEquals(401, response.getStatusLine().getStatusCode());
- String text = Utils.getContent(response);
- Assert.assertTrue("Response doesn't contain expected message.", text.contains("This request requires HTTP authentication"));
+ Utils.getContent(response);
+ //Assert.assertTrue("Response doesn't contain expected message.", text.contains("This request requires HTTP authentication"));
}
-
-
+
+
}

0 comments on commit 1fbf1ef

Please sign in to comment.
Something went wrong with that request. Please try again.