|
@@ -15,9 +15,20 @@
|
|
|
*/
|
|
|
package org.springframework.security.oauth2.server.authorization.web;
|
|
|
|
|
|
+import java.time.Duration;
|
|
|
+import java.time.Instant;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.function.Consumer;
|
|
|
+
|
|
|
+import javax.servlet.FilterChain;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
import org.junit.After;
|
|
|
import org.junit.Before;
|
|
|
import org.junit.Test;
|
|
|
+
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
|
import org.springframework.mock.http.client.MockClientHttpResponse;
|
|
@@ -30,23 +41,14 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
import org.springframework.security.oauth2.core.OAuth2AccessToken;
|
|
|
import org.springframework.security.oauth2.core.OAuth2Error;
|
|
|
import org.springframework.security.oauth2.core.OAuth2ErrorCodes;
|
|
|
-import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames2;
|
|
|
-import org.springframework.security.oauth2.core.http.converter.OAuth2ErrorHttpMessageConverter;
|
|
|
import org.springframework.security.oauth2.core.OAuth2TokenType;
|
|
|
+import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames;
|
|
|
+import org.springframework.security.oauth2.core.http.converter.OAuth2ErrorHttpMessageConverter;
|
|
|
import org.springframework.security.oauth2.server.authorization.authentication.OAuth2ClientAuthenticationToken;
|
|
|
import org.springframework.security.oauth2.server.authorization.authentication.OAuth2TokenRevocationAuthenticationToken;
|
|
|
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
|
|
|
import org.springframework.security.oauth2.server.authorization.client.TestRegisteredClients;
|
|
|
|
|
|
-import javax.servlet.FilterChain;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.time.Duration;
|
|
|
-import java.time.Instant;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.function.Consumer;
|
|
|
-
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
|
import static org.mockito.ArgumentMatchers.any;
|
|
@@ -122,25 +124,25 @@ public class OAuth2TokenRevocationEndpointFilterTests {
|
|
|
@Test
|
|
|
public void doFilterWhenTokenRevocationRequestMissingTokenThenInvalidRequestError() throws Exception {
|
|
|
doFilterWhenTokenRevocationRequestInvalidParameterThenError(
|
|
|
- OAuth2ParameterNames2.TOKEN,
|
|
|
+ OAuth2ParameterNames.TOKEN,
|
|
|
OAuth2ErrorCodes.INVALID_REQUEST,
|
|
|
- request -> request.removeParameter(OAuth2ParameterNames2.TOKEN));
|
|
|
+ request -> request.removeParameter(OAuth2ParameterNames.TOKEN));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void doFilterWhenTokenRevocationRequestMultipleTokenThenInvalidRequestError() throws Exception {
|
|
|
doFilterWhenTokenRevocationRequestInvalidParameterThenError(
|
|
|
- OAuth2ParameterNames2.TOKEN,
|
|
|
+ OAuth2ParameterNames.TOKEN,
|
|
|
OAuth2ErrorCodes.INVALID_REQUEST,
|
|
|
- request -> request.addParameter(OAuth2ParameterNames2.TOKEN, "token-2"));
|
|
|
+ request -> request.addParameter(OAuth2ParameterNames.TOKEN, "token-2"));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void doFilterWhenTokenRevocationRequestMultipleTokenTypeHintThenInvalidRequestError() throws Exception {
|
|
|
doFilterWhenTokenRevocationRequestInvalidParameterThenError(
|
|
|
- OAuth2ParameterNames2.TOKEN_TYPE_HINT,
|
|
|
+ OAuth2ParameterNames.TOKEN_TYPE_HINT,
|
|
|
OAuth2ErrorCodes.INVALID_REQUEST,
|
|
|
- request -> request.addParameter(OAuth2ParameterNames2.TOKEN_TYPE_HINT, OAuth2TokenType.ACCESS_TOKEN.getValue()));
|
|
|
+ request -> request.addParameter(OAuth2ParameterNames.TOKEN_TYPE_HINT, OAuth2TokenType.ACCESS_TOKEN.getValue()));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -202,8 +204,8 @@ public class OAuth2TokenRevocationEndpointFilterTests {
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("POST", requestUri);
|
|
|
request.setServletPath(requestUri);
|
|
|
|
|
|
- request.addParameter(OAuth2ParameterNames2.TOKEN, "token");
|
|
|
- request.addParameter(OAuth2ParameterNames2.TOKEN_TYPE_HINT, OAuth2TokenType.ACCESS_TOKEN.getValue());
|
|
|
+ request.addParameter(OAuth2ParameterNames.TOKEN, "token");
|
|
|
+ request.addParameter(OAuth2ParameterNames.TOKEN_TYPE_HINT, OAuth2TokenType.ACCESS_TOKEN.getValue());
|
|
|
|
|
|
return request;
|
|
|
}
|