Questions tagged [rest-assured]

REST Assured is a Java library that provides a domain-specific language (DSL) for writing powerful, maintainable tests for RESTful APIs.

REST Assured enables testing of REST services in Java.

It uses a fluid syntax inspired by similar libraries for and .

2207 questions
4
votes
1 answer

RestAssured testing without running Tomcat

I have REST web service which needs to be tested. I am using Mockito for mocking DAO classes and RestAssured for testing REST methods through URI. Is there any way to test REST service without running it separately with Tomcat? Or how to run…
Justinas Jakavonis
  • 8,220
  • 10
  • 69
  • 114
4
votes
1 answer

RestAssured JsonPath: flat array of elements in hierarchy

I'm writing a smoke test using rest-assured and want to traverse the api to make sure no unexpected errors occur. I have a data structure that looks like this: { ... "sites": [ { ... "groups": [ { ... …
Ranil Wijeyratne
  • 626
  • 7
  • 19
4
votes
1 answer

Integration test with rest assured and basic auth with CSRF

I have a working Spring Boot with AngularJs app based on https://spring.io/guides/tutorials/spring-security-and-angular-js/ I am using Basic Authentication and I would like to write an integration test for it. Currently, I always get a 403 status…
Wim Deblauwe
  • 25,113
  • 20
  • 133
  • 211
4
votes
1 answer

Htmlunitdriver conflicting with Rest Assured API

I am trying to use Htmlunitdriver but it looks like it is conflicting with Rest Assured API. If i remove rest assured library from the pom.xml, the below code works fine HtmlUnitDriver driver = new HtmlUnitDriver(); If i add rest assured library to…
aby
  • 95
  • 1
  • 11
4
votes
3 answers

Restassured CSRF protection with X-XSRF-TOKEN (like angularjs) header

I'm trying to write a web integration test with restassured spring security authentication. The application uses AngularJS and Spring Boot. Since I use AngularJS the CSRF protection is done with X-XSRF-TOKEN header and XSRF-TOKEN cookie (as I…
GrzegorzD
  • 73
  • 1
  • 6
4
votes
2 answers

How to validate nested response using REST Assured?

Need help to validate particular JSON parameter from below response using REST Assured library. I tried some of the options to validate other similar parameter as shown below but it didn't work. .then().body("value.value.value.name",…
Paresh
  • 1,140
  • 2
  • 12
  • 29
4
votes
3 answers

RestAssured oAuth2 http status code 401

I'm trying to implement integration test using RestAssured library and Spring MVC REST oAuth2 secured endpoint. This is my test: @Test public void testCreateDecision() throws Exception { File createDecisionJsonFile =…
alexanoid
  • 24,051
  • 54
  • 210
  • 410
4
votes
1 answer

Spring Mock mvc rest-assured test fails to get status

Getting error while trying to test while running RestAssuredMockMvc and Spring: INFO - Mapped "{[/mysql/hello],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String…
J.Olufsen
  • 13,415
  • 44
  • 120
  • 185
4
votes
2 answers

jsonpath find all object(restassured)

This is my JSON : [ { "id": 9741962, "name": "getName", "isActive": true }, { "id": 1, "name": "New", "isActive": true } ] I want to get all the object that has the name :getName using jsonPath how can I do it using…
Michael Biniashvili
  • 500
  • 1
  • 12
  • 24
4
votes
3 answers

Rest Assured Empty response body structure

I'd like to test a find rest service, if I find smth I want to delete from the database, otherwise do nothing I use it like this (where rs is the Response from find) JsonPath jsonPath = rs.getBody().jsonPath(); Object foundName=…
April
  • 435
  • 1
  • 5
  • 9
4
votes
2 answers

Connection reset in test using REST-assured

I have a test with the use of REST-assured. In this test when I pass full host and path to get() method, everything goes fine, test passes. But when I try to use RestAssured.baseURI and RestAssured.basePath like it's shown in this part of the…
Barbra
  • 93
  • 1
  • 2
  • 6
4
votes
2 answers

JAVA Rest-Assured DSL redirects not working

I am trying to configure my rest-assured tests to ignore redirects by using the following code: RestAssured.config = config().redirect(redirectConfig().followRedirects(true).and().maxRedirects(20)); Rest-Assured DSL I am doing a PUT on a REST…
user1684462
3
votes
1 answer

How to use query parameter with different combination in rest assured in Java?

I have 6 query parameters. All of them are optional. How should I use them with all combinations? I tried the following: do { Response searchbyfield = given() .headers("Cookie", cookies) .queryParam("search","test") …
3
votes
1 answer

How to invoke JUnit5 test runner / Junit tag expressions using Maven Surefire plugin?

We're building a Modular framework to run API tests. Tests themselevs are annoted using JUnit / JUnit5 @Test annotations. Option1: For running the tests together, I've created JUnit5 Test runner and tests are running fine using the runner locally…
user2451016
  • 1,857
  • 3
  • 20
  • 44
3
votes
2 answers

POST request fails (rest-assured test) Expected response body to be verified as JSON, HTML or XML but no content-type was defined in the response.?

I have problem with making POST request with rest-assured. @Test public void deleteBook(){ //Given Response response = given(). contentType("application/json"). body(" { \"Title\": \"Libro2\"}"). when(). …
DIP
  • 31
  • 1
  • 3