use of javax.xml.ws.Service in project wildfly by wildfly.
the class EJBEndpointAuthenticationTestCase method accessHelloWithoutUsernameAndPassord.
// ------------------------------------------------------------------------------
//
// Tests for hello method
//
@Test
public void accessHelloWithoutUsernameAndPassord() throws Exception {
URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-ejb3/EJB3AuthService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class);
try {
proxy.hello("World");
Assert.fail("Test should fail, HTTP response '401: Unauthorized' was expected");
} catch (WebServiceException e) {
// failure is expected
Assert.assertTrue("HTTPException '401: Unauthorized' was expected", e.getCause().getMessage().contains("401: Unauthorized"));
}
}
use of javax.xml.ws.Service in project wildfly by wildfly.
the class EJBEndpointNoClassLevelSecurityAnnotationAuthenticationTestCase method accessHelloForAllWithValidRole3.
@Test
public void accessHelloForAllWithValidRole3() throws Exception {
URL wsdlURL = new URL(baseUrl, deploymentWsdlURL);
Service service = Service.create(wsdlURL, serviceName);
EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class);
Map<String, Object> reqContext = ((BindingProvider) proxy).getRequestContext();
reqContext.put(BindingProvider.USERNAME_PROPERTY, "user3");
reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password3");
final String result = proxy.helloForAll("World");
Assert.assertEquals("Hello World!", result);
}
use of javax.xml.ws.Service in project wildfly by wildfly.
the class EJBEndpointNoClassLevelSecurityAnnotationAuthenticationTestCase method accessHelloForAllWithValidRole2.
@Test
public void accessHelloForAllWithValidRole2() throws Exception {
URL wsdlURL = new URL(baseUrl, deploymentWsdlURL);
Service service = Service.create(wsdlURL, serviceName);
EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class);
Map<String, Object> reqContext = ((BindingProvider) proxy).getRequestContext();
reqContext.put(BindingProvider.USERNAME_PROPERTY, "user2");
reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password2");
final String result = proxy.helloForAll("World");
Assert.assertEquals("Hello World!", result);
}
use of javax.xml.ws.Service in project wildfly by wildfly.
the class EJBEndpointNoClassLevelSecurityAnnotationAuthenticationTestCase method accessHelloForRolesWithValidRole2.
@Test
public void accessHelloForRolesWithValidRole2() throws Exception {
URL wsdlURL = new URL(baseUrl, deploymentWsdlURL);
Service service = Service.create(wsdlURL, serviceName);
EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class);
Map<String, Object> reqContext = ((BindingProvider) proxy).getRequestContext();
reqContext.put(BindingProvider.USERNAME_PROPERTY, "user2");
reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password2");
final String result = proxy.helloForRoles("World");
Assert.assertEquals("Hello World!", result);
}
use of javax.xml.ws.Service in project wildfly by wildfly.
the class EJBEndpointNoClassLevelSecurityAnnotationAuthenticationTestCase method accessHelloForRoleWithInvalidRole.
// ------------------------------------------------------------------------------
//
// Tests for helloForRole method
//
@Test
public void accessHelloForRoleWithInvalidRole() throws Exception {
URL wsdlURL = new URL(baseUrl, deploymentWsdlURL);
Service service = Service.create(wsdlURL, serviceName);
EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class);
Map<String, Object> reqContext = ((BindingProvider) proxy).getRequestContext();
reqContext.put(BindingProvider.USERNAME_PROPERTY, "user1");
reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password1");
try {
proxy.helloForRole("World");
Assert.fail("Test should fail, user shouldn't be allowed to invoke that method");
} catch (WebServiceException e) {
// failure is expected
Assert.assertEquals(getNotAllowedExceptionMessage("helloForRole"), e.getCause().getMessage());
}
}
Aggregations