commit
4e3360560a
|
|
@ -31,6 +31,7 @@ import org.springframework.util.StringUtils;
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Artsiom Yudovin
|
* @author Artsiom Yudovin
|
||||||
* @author MyeongHyeon Lee
|
* @author MyeongHyeon Lee
|
||||||
|
* @author Moritz Halbritter
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "spring.security.oauth2.client")
|
@ConfigurationProperties(prefix = "spring.security.oauth2.client")
|
||||||
|
|
@ -60,12 +61,12 @@ public class OAuth2ClientProperties implements InitializingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validate() {
|
public void validate() {
|
||||||
getRegistration().values().forEach(this::validateRegistration);
|
getRegistration().forEach(this::validateRegistration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateRegistration(Registration registration) {
|
private void validateRegistration(String id, Registration registration) {
|
||||||
if (!StringUtils.hasText(registration.getClientId())) {
|
if (!StringUtils.hasText(registration.getClientId())) {
|
||||||
throw new IllegalStateException("Client id must not be empty.");
|
throw new IllegalStateException("Client id of registration '%s' must not be empty.".formatted(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class OAuth2ClientPropertiesTests {
|
||||||
registration.setProvider("google");
|
registration.setProvider("google");
|
||||||
this.properties.getRegistration().put("foo", registration);
|
this.properties.getRegistration().put("foo", registration);
|
||||||
assertThatIllegalStateException().isThrownBy(this.properties::validate)
|
assertThatIllegalStateException().isThrownBy(this.properties::validate)
|
||||||
.withMessageContaining("Client id must not be empty.");
|
.withMessageContaining("Client id of registration 'foo' must not be empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue