Polish JdbcOAuth2AuthorizationService
Issue gh-304
This commit is contained in:
@@ -29,7 +29,6 @@ import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -210,7 +209,7 @@ public class JdbcOAuth2AuthorizationServiceTests {
|
||||
.authorizationGrantType(AUTHORIZATION_GRANT_TYPE)
|
||||
.token(AUTHORIZATION_CODE)
|
||||
.build();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
RowMapper<OAuth2Authorization> authorizationRowMapper = spy(
|
||||
new JdbcOAuth2AuthorizationService.OAuth2AuthorizationRowMapper(
|
||||
this.registeredClientRepository));
|
||||
@@ -252,7 +251,7 @@ public class JdbcOAuth2AuthorizationServiceTests {
|
||||
AUTHORIZATION_CODE.getTokenValue(), AUTHORIZATION_CODE_TOKEN_TYPE);
|
||||
assertThat(authorization).isEqualTo(expectedAuthorization);
|
||||
|
||||
this.authorizationService.remove(expectedAuthorization);
|
||||
this.authorizationService.remove(authorization);
|
||||
authorization = this.authorizationService.findByToken(
|
||||
AUTHORIZATION_CODE.getTokenValue(), AUTHORIZATION_CODE_TOKEN_TYPE);
|
||||
assertThat(authorization).isNull();
|
||||
@@ -463,8 +462,7 @@ public class JdbcOAuth2AuthorizationServiceTests {
|
||||
|
||||
private static final String PK_FILTER = "id = ?";
|
||||
private static final String UNKNOWN_TOKEN_TYPE_FILTER = "state = ? OR authorizationCodeValue = ? OR " +
|
||||
"accessTokenValue = ? OR " +
|
||||
"refreshTokenValue = ?";
|
||||
"accessTokenValue = ? OR refreshTokenValue = ?";
|
||||
|
||||
// @formatter:off
|
||||
private static final String LOAD_AUTHORIZATION_SQL = "SELECT " + COLUMN_NAMES
|
||||
@@ -474,12 +472,12 @@ public class JdbcOAuth2AuthorizationServiceTests {
|
||||
|
||||
// @formatter:off
|
||||
private static final String SAVE_AUTHORIZATION_SQL = "INSERT INTO " + TABLE_NAME
|
||||
+ " (" + COLUMN_NAMES + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
+ " (" + COLUMN_NAMES + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
// @formatter:on
|
||||
|
||||
private static final String REMOVE_AUTHORIZATION_SQL = "DELETE FROM " + TABLE_NAME + " WHERE " + PK_FILTER;
|
||||
|
||||
CustomJdbcOAuth2AuthorizationService(JdbcOperations jdbcOperations,
|
||||
private CustomJdbcOAuth2AuthorizationService(JdbcOperations jdbcOperations,
|
||||
RegisteredClientRepository registeredClientRepository) {
|
||||
super(jdbcOperations, registeredClientRepository);
|
||||
setAuthorizationRowMapper(new CustomOAuth2AuthorizationRowMapper(registeredClientRepository));
|
||||
@@ -520,7 +518,7 @@ public class JdbcOAuth2AuthorizationServiceTests {
|
||||
|
||||
private static final class CustomOAuth2AuthorizationRowMapper extends JdbcOAuth2AuthorizationService.OAuth2AuthorizationRowMapper {
|
||||
|
||||
CustomOAuth2AuthorizationRowMapper(RegisteredClientRepository registeredClientRepository) {
|
||||
private CustomOAuth2AuthorizationRowMapper(RegisteredClientRepository registeredClientRepository) {
|
||||
super(registeredClientRepository);
|
||||
}
|
||||
|
||||
@@ -682,7 +680,6 @@ public class JdbcOAuth2AuthorizationServiceTests {
|
||||
if (token.getToken().getIssuedAt() != null) {
|
||||
tokenIssuedAt = Timestamp.from(token.getToken().getIssuedAt());
|
||||
}
|
||||
|
||||
if (token.getToken().getExpiresAt() != null) {
|
||||
tokenExpiresAt = Timestamp.from(token.getToken().getExpiresAt());
|
||||
}
|
||||
|
||||
@@ -4,24 +4,24 @@ CREATE TABLE oauth2Authorization (
|
||||
principalName varchar(200) NOT NULL,
|
||||
authorizationGrantType varchar(100) NOT NULL,
|
||||
attributes varchar(4000) DEFAULT NULL,
|
||||
state varchar(1000) DEFAULT NULL,
|
||||
state varchar(500) DEFAULT NULL,
|
||||
authorizationCodeValue varchar(1000) DEFAULT NULL,
|
||||
authorizationCodeIssuedAt timestamp DEFAULT NULL,
|
||||
authorizationCodeExpiresAt timestamp DEFAULT NULL,
|
||||
authorizationCodeMetadata varchar(1000) DEFAULT NULL,
|
||||
authorizationCodeMetadata varchar(2000) DEFAULT NULL,
|
||||
accessTokenValue varchar(1000) DEFAULT NULL,
|
||||
accessTokenIssuedAt timestamp DEFAULT NULL,
|
||||
accessTokenExpiresAt timestamp DEFAULT NULL,
|
||||
accessTokenMetadata varchar(1000) DEFAULT NULL,
|
||||
accessTokenMetadata varchar(2000) DEFAULT NULL,
|
||||
accessTokenType varchar(100) DEFAULT NULL,
|
||||
accessTokenScopes varchar(1000) DEFAULT NULL,
|
||||
oidcIdTokenValue varchar(1000) DEFAULT NULL,
|
||||
oidcIdTokenIssuedAt timestamp DEFAULT NULL,
|
||||
oidcIdTokenExpiresAt timestamp DEFAULT NULL,
|
||||
oidcIdTokenMetadata varchar(1000) DEFAULT NULL,
|
||||
oidcIdTokenMetadata varchar(2000) DEFAULT NULL,
|
||||
refreshTokenValue varchar(1000) DEFAULT NULL,
|
||||
refreshTokenIssuedAt timestamp DEFAULT NULL,
|
||||
refreshTokenExpiresAt timestamp DEFAULT NULL,
|
||||
refreshTokenMetadata varchar(1000) DEFAULT NULL,
|
||||
refreshTokenMetadata varchar(2000) DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user