I am able to log in a user and the response returns the token which I store in token variable then I try to pass the token that I received but the system returns 403 all the time. Where I got wrong or how it should look like?
@Test
public void givenCorrectRoomDataWhenPostRoomThenReturnListWithNewlyCreatedRoomTest() {
LoginEndpoint loginEndpoint = new LoginEndpoint();
RoomPojo roomPojo = new RoomPojo();
String token = loginEndpoint.createToken();
roomPojo.setAccessible(true);
roomPojo.setType("Single");
roomPojo.setDescription("The very first single room");
roomPojo.setImage("https://i.pinimg.com/originals/51/23/f0/5123f08b6e9c4441f27abf07cfee09c9.jpg");
roomPojo.setRoomId(12);
roomPojo.setRoomPrice(94);
//roomPojo.setFeatures()
roomPojo.setRoomNumber(22);
given().header("Authorization", "Bearer" + token)
.body(roomPojo)
.when().post("room/")
.then().statusCode(200);
}
}
public class LoginEndpoint {
public String createToken(){
AuthPojo authPayload = new AuthPojo("admin", "password");
return given()
.body(authPayload)
.post("https://automationintesting.online/auth/login")
.asString();
}
}
Aucun commentaire:
Enregistrer un commentaire