mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-25 21:42:17 +00:00
Make user info response status check error only
Closes gh-9336
This commit is contained in:
parent
76657631fd
commit
f6b678f137
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -108,7 +108,7 @@ public class DefaultReactiveOAuth2UserService implements ReactiveOAuth2UserServi
|
|||||||
authenticationMethod);
|
authenticationMethod);
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
Mono<Map<String, Object>> userAttributes = requestHeadersSpec.retrieve()
|
Mono<Map<String, Object>> userAttributes = requestHeadersSpec.retrieve()
|
||||||
.onStatus((s) -> s != HttpStatus.OK, (response) ->
|
.onStatus(HttpStatus::isError, (response) ->
|
||||||
parse(response)
|
parse(response)
|
||||||
.map((userInfoErrorResponse) -> {
|
.map((userInfoErrorResponse) -> {
|
||||||
String description = userInfoErrorResponse.getErrorObject().getDescription();
|
String description = userInfoErrorResponse.getErrorObject().getDescription();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -51,6 +51,7 @@ import org.springframework.web.reactive.function.client.WebClient;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@ -144,6 +145,24 @@ public class DefaultReactiveOAuth2UserServiceTests {
|
|||||||
assertThat(userAuthority.getAttributes()).isEqualTo(user.getAttributes());
|
assertThat(userAuthority.getAttributes()).isEqualTo(user.getAttributes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gh-9336
|
||||||
|
@Test
|
||||||
|
public void loadUserWhenUserInfo201CreatedResponseThenReturnUser() {
|
||||||
|
// @formatter:off
|
||||||
|
String userInfoResponse = "{\n"
|
||||||
|
+ " \"id\": \"user1\",\n"
|
||||||
|
+ " \"first-name\": \"first\",\n"
|
||||||
|
+ " \"last-name\": \"last\",\n"
|
||||||
|
+ " \"middle-name\": \"middle\",\n"
|
||||||
|
+ " \"address\": \"address\",\n"
|
||||||
|
+ " \"email\": \"user1@example.com\"\n"
|
||||||
|
+ "}\n";
|
||||||
|
// @formatter:on
|
||||||
|
this.server.enqueue(new MockResponse().setResponseCode(201)
|
||||||
|
.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).setBody(userInfoResponse));
|
||||||
|
assertThatNoException().isThrownBy(() -> this.userService.loadUser(oauth2UserRequest()).block());
|
||||||
|
}
|
||||||
|
|
||||||
// gh-5500
|
// gh-5500
|
||||||
@Test
|
@Test
|
||||||
public void loadUserWhenAuthenticationMethodHeaderSuccessResponseThenHttpMethodGet() throws Exception {
|
public void loadUserWhenAuthenticationMethodHeaderSuccessResponseThenHttpMethodGet() throws Exception {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user