Skip to content

Commit 206c287

Browse files
committed
Put registration id in validation error message
Closes gh-42278
1 parent 5bddca8 commit 206c287

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientProperties.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* @author Phillip Webb
3232
* @author Artsiom Yudovin
3333
* @author MyeongHyeon Lee
34+
* @author Moritz Halbritter
3435
* @since 2.0.0
3536
*/
3637
@ConfigurationProperties(prefix = "spring.security.oauth2.client")
@@ -60,12 +61,12 @@ public void afterPropertiesSet() {
6061
}
6162

6263
public void validate() {
63-
getRegistration().values().forEach(this::validateRegistration);
64+
getRegistration().forEach(this::validateRegistration);
6465
}
6566

66-
private void validateRegistration(Registration registration) {
67+
private void validateRegistration(String id, Registration registration) {
6768
if (!StringUtils.hasText(registration.getClientId())) {
68-
throw new IllegalStateException("Client id must not be empty.");
69+
throw new IllegalStateException("Client id of registration '%s' must not be empty.".formatted(id));
6970
}
7071
}
7172

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void clientIdAbsentThrowsException() {
3737
registration.setProvider("google");
3838
this.properties.getRegistration().put("foo", registration);
3939
assertThatIllegalStateException().isThrownBy(this.properties::validate)
40-
.withMessageContaining("Client id must not be empty.");
40+
.withMessageContaining("Client id of registration 'foo' must not be empty.");
4141
}
4242

4343
@Test

0 commit comments

Comments
 (0)