Search in sources :

Example 66 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.

the class RunAsLoginModuleTestCase method testCleartextPassword1.

/**
     * Correct login
     *
     * @throws Exception
     */
@OperateOnDeployment(DEP1)
@Test
public void testCleartextPassword1(@ArquillianResource URL url) throws Exception {
    HttpResponse response;
    HttpGet httpget = new HttpGet(url.toString());
    String headerValue = Base64.getEncoder().encodeToString("anil:anil".getBytes());
    Assert.assertNotNull(headerValue);
    httpget.addHeader("Authorization", "Basic " + headerValue);
    String text;
    try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
        response = httpclient.execute(httpget);
        text = Utils.getContent(response);
    } catch (IOException e) {
        throw new RuntimeException("Servlet response IO exception", e);
    }
    assertTrue("An unexpected response: " + text, text.contains("anil"));
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) IOException(java.io.IOException) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 67 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.

the class WSTrustTestCase method testOnBehalfOf.

/**
     * Request a security token that allows it to act on behalf of somebody else.
     *
     * @throws Exception
     */
@Test
@RunAsClient
@OperateOnDeployment(ON_BEHALF_OF_SERVER_DEP)
@WrapThreadContextClassLoader
public void testOnBehalfOf() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/onbehalfofwssecuritypolicy", "OnBehalfOfService");
        final URL wsdlURL = new URL(serviceURL + "OnBehalfOfService?wsdl");
        Service service = Service.create(wsdlURL, serviceName);
        OnBehalfOfServiceIface proxy = (OnBehalfOfServiceIface) service.getPort(OnBehalfOfServiceIface.class);
        WSTrustTestUtils.setupWsseAndSTSClientOnBehalfOf((BindingProvider) proxy, bus);
        assertEquals("OnBehalfOf WS-Trust Hello World!", proxy.sayHello(serviceURL.getHost(), String.valueOf(serviceURL.getPort())));
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) OnBehalfOfServiceIface(org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface) URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) WrapThreadContextClassLoader(org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)

Example 68 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.

the class WSTrustTestCase method test.

/**
     * WS-Trust test with the STS information programmatically provided
     *
     * @throws Exception
     */
@Test
@RunAsClient
@OperateOnDeployment(SERVER_DEP)
@WrapThreadContextClassLoader
public void test() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService");
        final URL wsdlURL = new URL(serviceURL + "SecurityService?wsdl");
        Service service = Service.create(wsdlURL, serviceName);
        ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
        final QName stsServiceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService");
        final QName stsPortName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port");
        URL stsURL = new URL(serviceURL.getProtocol(), serviceURL.getHost(), serviceURL.getPort(), "/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl");
        WSTrustTestUtils.setupWsseAndSTSClient(proxy, bus, stsURL.toString(), stsServiceName, stsPortName);
        try {
            assertEquals("WS-Trust Hello World!", proxy.sayHello());
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) ActAsServiceIface(org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface) ServiceIface(org.jboss.as.test.integration.ws.wsse.trust.service.ServiceIface) OnBehalfOfServiceIface(org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) IOException(java.io.IOException) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) WrapThreadContextClassLoader(org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)

Example 69 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.

the class WSTrustTestCase method testBearer.

@Test
@RunAsClient
@OperateOnDeployment(BEARER_SERVER_DEP)
@WrapThreadContextClassLoader
public void testBearer() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/bearerwssecuritypolicy", "BearerService");
        Service service = Service.create(new URL(serviceURL + "BearerService?wsdl"), serviceName);
        BearerIface proxy = (BearerIface) service.getPort(BearerIface.class);
        WSTrustTestUtils.setupWsseAndSTSClientBearer((BindingProvider) proxy, bus);
        assertEquals("Bearer WS-Trust Hello World!", proxy.sayHello());
    } catch (Exception e) {
        throw e;
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) BearerIface(org.jboss.as.test.integration.ws.wsse.trust.bearer.BearerIface) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) IOException(java.io.IOException) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) WrapThreadContextClassLoader(org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)

Example 70 with OperateOnDeployment

use of org.jboss.arquillian.container.test.api.OperateOnDeployment in project wildfly by wildfly.

the class WSTrustTestCase method testPicketLink.

@Test
@RunAsClient
@OperateOnDeployment(SERVER_DEP)
@WrapThreadContextClassLoader
public void testPicketLink() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService");
        final URL wsdlURL = new URL(serviceURL + "SecurityService?wsdl");
        Service service = Service.create(wsdlURL, serviceName);
        ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
        final QName stsServiceName = new QName("urn:picketlink:identity-federation:sts", "PicketLinkSTS");
        final QName stsPortName = new QName("urn:picketlink:identity-federation:sts", "PicketLinkSTSPort");
        final URL stsURL = new URL(serviceURL.getProtocol(), serviceURL.getHost(), serviceURL.getPort(), "/jaxws-samples-wsse-policy-trustPicketLink-sts/PicketLinkSTS?wsdl");
        WSTrustTestUtils.setupWsseAndSTSClient(proxy, bus, stsURL.toString(), stsServiceName, stsPortName);
        try {
            assertEquals("WS-Trust Hello World!", proxy.sayHello());
        } catch (Exception e) {
            throw e;
        }
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) ActAsServiceIface(org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface) ServiceIface(org.jboss.as.test.integration.ws.wsse.trust.service.ServiceIface) OnBehalfOfServiceIface(org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) IOException(java.io.IOException) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) WrapThreadContextClassLoader(org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)

Aggregations

OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)94 Test (org.junit.Test)93 URL (java.net.URL)31 URI (java.net.URI)22 HttpGet (org.apache.http.client.methods.HttpGet)20 HttpResponse (org.apache.http.HttpResponse)17 InitialContext (javax.naming.InitialContext)15 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)13 QName (javax.xml.namespace.QName)11 Service (javax.xml.ws.Service)11 HttpEntity (org.apache.http.HttpEntity)10 Bus (org.apache.cxf.Bus)9 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)9 WrapThreadContextClassLoader (org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)9 ActAsServiceIface (org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface)6 OnBehalfOfServiceIface (org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface)6 GetMethodWebRequest (com.meterware.httpunit.GetMethodWebRequest)5 WebConversation (com.meterware.httpunit.WebConversation)5 WebForm (com.meterware.httpunit.WebForm)5 WebRequest (com.meterware.httpunit.WebRequest)5