arquillian / arquillian-extension-rest

Declarative REST testing extension
37 stars 20 forks source link

Test REST api with Authentication using Arquillian #32

Open Xilibit opened 8 years ago

Xilibit commented 8 years ago

Is it possible to test rest api with Authentication?

Do you have any docs about this?

Can you look at this stackoverflow post with code http://stackoverflow.com/questions/40704772/test-rest-api-with-authentication-using-arquillian

Console log is: 21:09:41,378 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 2) Initializing Mojarra 2.2.13.SP1 20160303-1204 for context '/test' 21:09:41,864 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 2) WFLYUT0021: Registered web context: /test 21:09:41,908 INFO [org.jboss.as.server] (management-handler-thread - 4) WFLYSRV0010: Deployed "test.war" (runtime-name : "test.war") DEBUG [org.xnio.nio] Started channel thread 'Remoting "endpoint" I/O-1', selector sun.nio.ch.KQueueSelectorImpl@140555bf DEBUG [org.jboss.remotingjmx.VersionedConectionFactory] Available version (Versions 0x00 0x01) DEBUG [org.jboss.remotingjmx.VersionedConectionFactory] Calling a stable server DEBUG [org.jboss.remotingjmx.VersionedConectionFactory] Selecting version 0x00 to receive full version list. DEBUG [org.jboss.remotingjmx.VersionedConectionFactory] Available version (Versions 0x01 0x02) DEBUG [org.jboss.remotingjmx.VersionedConectionFactory] Calling a stable server DEBUG [org.jboss.remotingjmx.VersionedConectionFactory] Server version 2.0.1.Final DEBUG [org.jboss.resteasy.resteasy_jaxrs.i18n] RESTEASY002330: Unable to retrieve config: expandEntityReferences defaults to false DEBUG [org.jboss.resteasy.resteasy_jaxrs.i18n] RESTEASY002335: Unable to retrieve config: enableSecureProcessingFeature defaults to true DEBUG [org.jboss.resteasy.resteasy_jaxrs.i18n] RESTEASY002325: Unable to retrieve config: disableDTDs defaults to true DEBUG [org.jboss.resteasy.resteasy_jaxrs.i18n] RESTEASY002330: Unable to retrieve config: expandEntityReferences defaults to false DEBUG [org.jboss.resteasy.resteasy_jaxrs.i18n] RESTEASY002335: Unable to retrieve config: enableSecureProcessingFeature defaults to true DEBUG [org.jboss.resteasy.resteasy_jaxrs.i18n] RESTEASY002325: Unable to retrieve config: disableDTDs defaults to true INFO [com.project.cm.api.configuration.service.TESTServiceImpl] @ArquillianResteasyResource("api/data_conf/getData") DEBUG [org.apache.http.impl.conn.BasicClientConnectionManager] Get connection for route {}->http://127.0.0.1:8080 DEBUG [org.apache.http.impl.conn.DefaultClientConnectionOperator] Connecting to 127.0.0.1:8080 DEBUG [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: default DEBUG [org.apache.http.client.protocol.RequestAuthCache] Auth cache not set in the context DEBUG [org.apache.http.client.protocol.RequestProxyAuthentication] Proxy auth state: UNCHALLENGED DEBUG [org.apache.http.impl.client.DefaultHttpClient] Attempt 1 to execute request DEBUG [org.apache.http.impl.conn.DefaultClientConnection] Sending request: POST /test/data_conf/getData HTTP/1.1 DEBUG [org.apache.http.wire] >> "POST /test/data_conf/getData HTTP/1.1[\r][\n]" DEBUG [org.apache.http.wire] >> "Accept: application/json[\r][\n]" DEBUG [org.apache.http.wire] >> "Accept-Encoding: gzip, deflate[\r][\n]" DEBUG [org.apache.http.wire] >> "Authorization: TOKEN[\r][\n]" DEBUG [org.apache.http.wire] >> "Content-Type: application/json[\r][\n]" DEBUG [org.apache.http.wire] >> "Content-Length: 180[\r][\n]" DEBUG [org.apache.http.wire] >> "Host: 127.0.0.1:8080[\r][\n]" DEBUG [org.apache.http.wire] >> "Connection: Keep-Alive[\r][\n]" DEBUG [org.apache.http.wire] >> "[\r][\n]" DEBUG [org.apache.http.headers] >> POST /test/data_conf/getData HTTP/1.1 DEBUG [org.apache.http.headers] >> Accept: application/json DEBUG [org.apache.http.headers] >> Accept-Encoding: gzip, deflate DEBUG [org.apache.http.headers] >> Authorization: TOKEN DEBUG [org.apache.http.headers] >> Content-Type: application/json DEBUG [org.apache.http.headers] >> Content-Length: 180 DEBUG [org.apache.http.headers] >> Host: 127.0.0.1:8080 DEBUG [org.apache.http.headers] >> Connection: Keep-Alive DEBUG [org.apache.http.wire] >> "{"info":{"os":"Test","osVer":"Test","type":"Test","prot":"Test","appVer":"Test","model":null,"carrier":"Test","lang":"Test","instId":"Test","cnfHash":null,"cnfId":null,"cnf":null}}" DEBUG [org.apache.http.wire] << "HTTP/1.1 405 Method Not Allowed[\r][\n]" DEBUG [org.apache.http.wire] << "Connection: keep-alive[\r][\n]" DEBUG [org.apache.http.wire] << "X-Powered-By: Undertow/1[\r][\n]" DEBUG [org.apache.http.wire] << "Server: WildFly/10[\r][\n]" DEBUG [org.apache.http.wire] << "Content-Type: text/html;charset=UTF-8[\r][\n]" DEBUG [org.apache.http.wire] << "Content-Length: 104[\r][\n]" DEBUG [org.apache.http.wire] << "Date: Sun, 27 Nov 2016 19:09:47 GMT[\r][\n]" DEBUG [org.apache.http.wire] << "[\r][\n]" DEBUG [org.apache.http.impl.conn.DefaultClientConnection] Receiving response: HTTP/1.1 405 Method Not Allowed DEBUG [org.apache.http.headers] << HTTP/1.1 405 Method Not Allowed DEBUG [org.apache.http.headers] << Connection: keep-alive DEBUG [org.apache.http.headers] << X-Powered-By: Undertow/1 DEBUG [org.apache.http.headers] << Server: WildFly/10 DEBUG [org.apache.http.headers] << Content-Type: text/html;charset=UTF-8 DEBUG [org.apache.http.headers] << Content-Length: 104 DEBUG [org.apache.http.headers] << Date: Sun, 27 Nov 2016 19:09:47 GMT DEBUG [org.apache.http.impl.client.DefaultHttpClient] Connection can be kept alive indefinitely INFO [com.project.cm.api.configuration.service.TESTServiceImpl] Response response = webTarget 21:09:47,730 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 2) WFLYUT0022: Unregistered web context: /test 21:09:47,751 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 61) WFLYJPA0011: Stopping Persistence Unit (phase 2 of 2) Service 'test.war#project-arquillian'