vendredi 16 octobre 2015

Java rest testing with rest-assured multiple GET requests

I have a Spring-boot application and it's a REST service for my AngularJS app. I'm trying to write some unit tests for it, and this is sample code from one of it.

    given().
            auth().basic(USER_LOGIN, "X").
            get("http://myservice/login").
            then().assertThat().statusCode(HttpStatus.UNAUTHORIZED.value());
    given().
            auth().basic(USER_LOGIN, PASSWORD).
            get("http://myservice/login").
            then().assertThat().statusCode(HttpStatus.OK.value());

The problem is that my second assertion is not passed. But when I'm trying to swap their places, assertion with UNAUTHORIZED status not passing. If I'll try to reproduce this test case with SoapUI, it will work fine, both assertions are done. Probably, it's caching results of requests somehow?

p.s. The security provider I'm using is Spring security.

Aucun commentaire:

Enregistrer un commentaire