0

I'm testing changePassword() method. I'm checking by giving a wrong password firstly, then giving parameters correctly on the second part. However, for the wrong password, it's giving me error for the body(). If I log().body() it doesn't print out anything, but the status code matches. If I do body("errors[0]",equalTo("Wrong password")) it shows me error for this line saying "Expected response body to be verified as JSON, HTML or XML but no content-type was defined in the response."

 given().
            contentType("application/json").
            header("ID", "2501").
            param("newPass", "pass2017").
            param("oldPass", "pass2015"). // wrong password
            when().
            put("/v1/password").
            then().
            statusCode(400).
            //log().body();
            body("errors[0]",equalTo("Wrong password"));

Also for correct parameters, it says Expected status code <200> doesn't match actual status code <400>. I don't know what parameters I could have given wrong, it seems everything is OK. Can anyone explain me what could be wrong in these pieces of code?

 given().
            contentType("application/json").
            header("ID", "2501").
            param("newPass", "pass2017").
            param("oldPass", "pass2016").
            when().
            put("/v1/password").
            then().
            statusCode(200).
            //log().body();
            body("content.response", equalTo(true)) ;

Thanks!

UPDATE: I checked this method on Swagger, it works fine.

kenkulan
  • 147
  • 4
  • 14
  • you wrote the code, you wrote it's configuration, you run the server, ... – Stultuske Oct 24 '17 at 06:55
  • @Stultuske I don't get you – kenkulan Oct 24 '17 at 06:59
  • 1
    kenkulan: I mean there's a lot more information you could/should provide. we don't know what is configured. 400 means "Bad request", so it looks like what you send as request doesn't match what is expected on the back-end – Stultuske Oct 24 '17 at 07:13

0 Answers0