-
Notifications
You must be signed in to change notification settings - Fork 131
Open
Description
Hello,
I have seen that the project gives a good example, but I do not see test cases written.
I have written a code for test cases.
I have written a test case for the home page, it is working fine.
but I face an issue that there is an issue related to function obtain tokens.
It returns status code 401 although it should return status code 200 Ok
`
private String obtainAccessToken(String username, String password) throws Exception {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("grant_type", "password");
params.add("client_id", "my-trusted-client");
params.add("username", "user");
params.add("password", "user");
ResultActions result
= mockMvcURLAuthenication.perform(post("/oauth/token")
.params(params)
.with(httpBasic("my-trusted-client",passwordEncoder.encode("secret")))
.accept("application/json;charset=UTF-8"))
.andExpect(status().isOk());
String resultString = result.andReturn().getResponse().getContentAsString();
JacksonJsonParser jsonParser = new JacksonJsonParser();
return jsonParser.parseMap(resultString).get("access_token").toString();
}
`
Thanks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels