Skip to content

Rest-Assured - Query string is duplicated in generated snippets #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Zasch opened this issue Sep 7, 2016 · 5 comments
Closed

Rest-Assured - Query string is duplicated in generated snippets #298

Zasch opened this issue Sep 7, 2016 · 5 comments
Labels
status: invalid Suggestion or bug report that we don't feel is valid

Comments

@Zasch
Copy link

Zasch commented Sep 7, 2016

There seems to be a problem with curl- and http-snippet generation. The request params are doubled:

$ curl 'http://loclhost/tags/list?page=0&per_page=3?page=0&per_page=3' -i -H 'Accept: application/json'

GET /tags/list?page=0&per_page=3&page=0&per_page=3 HTTP/1.1 Accept: application/json Host: localhost

I use Rest-Assured:

given(this.spec)
                .accept("application/json")
                .filter(document("tag-list",
                preprocessRequest(prettyPrint(), modifyUris().scheme("http").host("loclhost").removePort()),
                preprocessResponse(prettyPrint()),
                requestParameters(
                        parameterWithName("page").description("Number of the page to retrieve").optional(),
                        parameterWithName("per_page").description("Entries per page").optional()
                ),
                responseFields(
                        fieldWithPath("content").description("Array of elements"),
                        fieldWithPath("totalPages").description("Total number of pages"),
                        fieldWithPath("totalElements").description("Total number of elements"),
                        fieldWithPath("first").description("Is this the first page?"),
                        fieldWithPath("last").description("Is this the last page?"),
                        fieldWithPath("numberOfElements").description("Number of elements on this page"),
                        fieldWithPath("sort").description("Sort order").ignored(),
                        fieldWithPath("size").description("Number of elements on each page"),
                        fieldWithPath("number").description("Page number")
                )))
                .when()
                .port(this.port)
                .get("/tags/list?page=0&per_page=3")
                .then()
                .log().ifValidationFails()
                .time(lessThan(2000L))
                .assertThat().statusCode(200)
                .and()
                .assertThat().contentType("application/json")

Maybe, this is related to #286 ?

@wilkinsona
Copy link
Member

I suspect it's a duplicate. What version are you using?

@wilkinsona wilkinsona added the status: waiting-for-feedback Feedback is required before progress can be made label Sep 7, 2016
@Zasch
Copy link
Author

Zasch commented Sep 7, 2016

I'm using 1.1.2.RELEASE

testCompile('org.springframework.restdocs:spring-restdocs-restassured:1.1.2.RELEASE')

@wilkinsona
Copy link
Member

wilkinsona commented Sep 7, 2016

Thanks. Are you using Spring Boot? If so, its dependency management will be forcing the core module (which is where the fix is) to be 1.1.1.RELEASE. If not, please provide a complete example that reproduces the problem.

@Zasch
Copy link
Author

Zasch commented Sep 7, 2016

Transitive dependency was in fact spring-restdocs-core:1.1.1.RELEASE.

So this fixes it:

testCompile("org.springframework.restdocs:spring-restdocs-restassured:1.1.2.RELEASE") {
    exclude group: "org.springframework.restdocs", module: "spring-restdocs-core"
}
testCompile("org.springframework.restdocs:spring-restdocs-core:1.1.2.RELEASE")

Thank you.

@wilkinsona
Copy link
Member

Great. Btw, there's no need for the exclude there. And if you're using Spring Boot you could just override spring-restdocs.version instead.

@wilkinsona wilkinsona added status: invalid Suggestion or bug report that we don't feel is valid and removed status: waiting-for-feedback Feedback is required before progress can be made labels Sep 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid Suggestion or bug report that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

2 participants