InMemoryOAuth2AuthorizationService uniquely identifies OAuth2Authorization

Closes gh-98
This commit is contained in:
Joe Grandja
2020-08-19 09:49:21 -04:00
parent 909aeace29
commit eeca3df66b
2 changed files with 41 additions and 31 deletions

View File

@@ -22,7 +22,6 @@ import org.springframework.security.oauth2.server.authorization.client.Registere
import org.springframework.security.oauth2.server.authorization.client.TestRegisteredClients;
import java.time.Instant;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -43,13 +42,6 @@ public class InMemoryOAuth2AuthorizationServiceTests {
this.authorizationService = new InMemoryOAuth2AuthorizationService();
}
@Test
public void constructorWhenAuthorizationListNullThenThrowIllegalArgumentException() {
assertThatThrownBy(() -> new InMemoryOAuth2AuthorizationService(null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("authorizations cannot be empty");
}
@Test
public void saveWhenAuthorizationNullThenThrowIllegalArgumentException() {
assertThatThrownBy(() -> this.authorizationService.save(null))
@@ -83,7 +75,7 @@ public class InMemoryOAuth2AuthorizationServiceTests {
.principalName(PRINCIPAL_NAME)
.attribute(OAuth2AuthorizationAttributeNames.CODE, AUTHORIZATION_CODE)
.build();
this.authorizationService = new InMemoryOAuth2AuthorizationService(Collections.singletonList(authorization));
this.authorizationService.save(authorization);
OAuth2Authorization result = this.authorizationService.findByToken(
AUTHORIZATION_CODE, TokenType.AUTHORIZATION_CODE);