Skip to content

Provide a preprocessor that can modify existing headers #580

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
ghoonch4 opened this issue Feb 15, 2019 · 3 comments
Closed

Provide a preprocessor that can modify existing headers #580

ghoonch4 opened this issue Feb 15, 2019 · 3 comments
Labels
status: superseded Superseded by another issue type: enhancement Enhancement that adds a new feature

Comments

@ghoonch4
Copy link
Contributor

I know there is a preprocessor to remove the header. But I could not find a preprocessor that could add or modify headers. How about providing a preprocessor that supports add, set, and remove headers like a modifyParameters on Preprocessors? If you do not mind, I want PR.

For example, it might be useful in the following case:

@Test
public void test() throws Exception {
    this.mockMvc
        .perform(get("/test").header("Authorization", "Basic dXNlcjpzZWNyZXQ="))
        .andExpect(status().isOk())
        .andDo(document("test"));
}

Below is one of the generated .adoc files by the test code.

http-request.adoc

[source,http,options="nowrap"]
----
GET /test HTTP/1.1
Host: localhost:8080
Authorization: Basic dXNlcjpzZWNyZXQ=

----

The value of the Authorization header must be valid to pass the test. But, documents should not expose valid Authorization header value. In this case, I want to modify the value of the Authorization header to an invalid value through preprocessor.

@wilkinsona wilkinsona changed the title Suggestion for providing a preprocessor that can modify headers Provide a preprocessor that can modify existing headers Feb 15, 2019
@wilkinsona
Copy link
Member

Sounds like a good idea to me. Thanks for the suggestion. A pull request would be most welcome.

@wilkinsona wilkinsona added the type: enhancement Enhancement that adds a new feature label Feb 15, 2019
ghoonch4 pushed a commit to ghoonch4/spring-restdocs that referenced this issue Feb 18, 2019
@ghoonch4
Copy link
Contributor Author

I wrote PR #584

@wilkinsona
Copy link
Member

Thank you. Closing in favour of PR #584.

@wilkinsona wilkinsona added the status: superseded Superseded by another issue label Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded Superseded by another issue type: enhancement Enhancement that adds a new feature
Projects
None yet
Development

No branches or pull requests

2 participants