OAuth2 client secret property should not be required

This commit is contained in:
artsiom 2018-08-21 12:24:41 +03:00 committed by Madhura Bhave
parent caf7221485
commit 6be4307712
2 changed files with 3 additions and 6 deletions

View File

@ -30,6 +30,7 @@ import org.springframework.util.StringUtils;
*
* @author Madhura Bhave
* @author Phillip Webb
* @author Artsiom Yudovin
*/
@ConfigurationProperties(prefix = "spring.security.oauth2.client")
public class OAuth2ClientProperties {
@ -61,9 +62,6 @@ public class OAuth2ClientProperties {
if (!StringUtils.hasText(registration.getClientId())) {
throw new IllegalStateException("Client id must not be empty.");
}
if (!StringUtils.hasText(registration.getClientSecret())) {
throw new IllegalStateException("Client secret must not be empty.");
}
}
/**

View File

@ -24,6 +24,7 @@ import org.junit.rules.ExpectedException;
* Tests for {@link OAuth2ClientProperties}.
*
* @author Madhura Bhave
* @author Artsiom Yudovin
*/
public class OAuth2ClientPropertiesTests {
@ -44,13 +45,11 @@ public class OAuth2ClientPropertiesTests {
}
@Test
public void clientSecretAbsentThrowsException() {
public void clientSecretAbsentNotThrowsException() {
OAuth2ClientProperties.Registration registration = new OAuth2ClientProperties.Registration();
registration.setClientId("foo");
registration.setProvider("google");
this.properties.getRegistration().put("foo", registration);
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage("Client secret must not be empty.");
this.properties.validate();
}