В моих модульных тестов мы находимSpring REST Docs: как заменить Parameters
this.mockMvc
.perform(post("/authenticate")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.param("username", "[email protected]")
.param("password", "superSecretPassword"))
.andExpect(status().isOk())
.andDo(document("preprocessed-request",
preprocessRequest(replacePattern(Pattern.compile("superSecretPassword"), "XXX"))));
ср Spring REST Docs documentation
build/generated-snippets/preprocessed-request/http-request.adoc
Это создает с содержанием
[source,http]
----
POST /authenticate HTTP/1.1
Content-Type: application/x-www-form-urlencoded
username=user%40example.com&password=superSecretPassword
----
Но я ожидаю, что пароль будет замаскирована из-за replacePattern():
[source,http]
----
POST /authenticate HTTP/1.1
Content-Type: application/x-www-form-urlencoded
username=user%40example.com&password=XXX
----
Что я могу сделать?
Я считаю, что очень полезно, чтобы написать свои собственные 'OperationPreprocessor's. Можно ли добавить его в [Документацию документа Spring REST Docs] (http://docs.spring.io/spring-restdocs/docs/1.0.x/reference/html5/)? –
Да, это возможно. Я открыл [проблему] (https://github.com/spring-projects/spring-restdocs/issues/156). –