Polish "Add properties to support device grant"

See gh-34957
pull/35090/head
Andy Wilkinson 2 years ago
parent 25b582c822
commit 4eb7558707

@ -459,7 +459,7 @@ public class OAuth2AuthorizationServerProperties implements InitializingBean {
/**
* Time-to-live for a device code.
*/
private Duration deviceCodeTimeToLive;
private Duration deviceCodeTimeToLive = Duration.ofMinutes(5);
/**
* Whether refresh tokens are reused or a new refresh token is issued when

@ -66,6 +66,7 @@ class OAuth2AuthorizationServerPropertiesMapperTests {
assertThat(registeredClient.getTokenSettings().getAccessTokenFormat()).isEqualTo(OAuth2TokenFormat.REFERENCE);
assertThat(registeredClient.getTokenSettings().getAccessTokenTimeToLive()).isEqualTo(Duration.ofSeconds(300));
assertThat(registeredClient.getTokenSettings().getRefreshTokenTimeToLive()).isEqualTo(Duration.ofHours(24));
assertThat(registeredClient.getTokenSettings().getDeviceCodeTimeToLive()).isEqualTo(Duration.ofMinutes(30));
assertThat(registeredClient.getTokenSettings().isReuseRefreshTokens()).isEqualTo(true);
assertThat(registeredClient.getTokenSettings().getIdTokenSignatureAlgorithm())
.isEqualTo(SignatureAlgorithm.RS512);

@ -18,6 +18,9 @@ package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
import org.junit.jupiter.api.Test;
import org.springframework.security.oauth2.server.authorization.settings.TokenSettings;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
@ -69,4 +72,10 @@ class OAuth2AuthorizationServerPropertiesTests {
.withMessage("Authorization grant types must not be empty.");
}
@Test
void defaultDeviceCodeTimeToLiveMatchesBuilderDefault() {
assertThat(new OAuth2AuthorizationServerProperties.Client().getToken().getDeviceCodeTimeToLive())
.isEqualTo(TokenSettings.builder().build().getDeviceCodeTimeToLive());
}
}

Loading…
Cancel
Save