0 Replies Latest reply on Nov 18, 2016 10:37 AM by Oleksii Danchuk

    Test REST api with Authentication

    Oleksii Danchuk Newbie

      Hi to everyone!


      Could you please suggest how can i write test for secured rest api?


      public class DataResource {
      public Response getData(@Context SecurityContext context,
      @NotNull(message = "Payload shouldn't not be null")
      Configuration configurationData) {


      The SecurityContext context is injected after AuthenticationFilter logic.

      Something like this...


      public class AuthenticationFilter {...}


      And my test looks like this…


      public void testGetData(@ArquillianResteasyResource("data_conf") ResteasyWebTarget webTarget) {
      Configuration request = getConfiguration();
      Response response = webTarget
      .request(MediaType.APPLICATION_JSON).header("Authorization", TOKEN)


      But i always get

      DEBUG [org.apache.http.impl.conn.DefaultClientConnection] Receiving response: HTTP/1.1 405 Method Not Allowed