Merge branch '3.2.x' into 3.3.x

Closes gh-42279
This commit is contained in:
Moritz Halbritter 2024-09-12 14:29:49 +02:00
commit 4e3360560a
2 changed files with 5 additions and 4 deletions

View File

@ -31,6 +31,7 @@ import org.springframework.util.StringUtils;
* @author Phillip Webb
* @author Artsiom Yudovin
* @author MyeongHyeon Lee
* @author Moritz Halbritter
* @since 2.0.0
*/
@ConfigurationProperties(prefix = "spring.security.oauth2.client")
@ -60,12 +61,12 @@ public class OAuth2ClientProperties implements InitializingBean {
}
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())) {
throw new IllegalStateException("Client id must not be empty.");
throw new IllegalStateException("Client id of registration '%s' must not be empty.".formatted(id));
}
}

View File

@ -37,7 +37,7 @@ class OAuth2ClientPropertiesTests {
registration.setProvider("google");
this.properties.getRegistration().put("foo", registration);
assertThatIllegalStateException().isThrownBy(this.properties::validate)
.withMessageContaining("Client id must not be empty.");
.withMessageContaining("Client id of registration 'foo' must not be empty.");
}
@Test