浏览代码

Polish gh-1127

Joe Grandja 2 年之前
父节点
当前提交
213048b780

+ 2 - 2
oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2AuthorizationConsentAuthenticationContext.java

@@ -1,5 +1,5 @@
 /*
- * Copyright 2020-2022 the original author or authors.
+ * Copyright 2020-2023 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -162,8 +162,8 @@ public final class OAuth2AuthorizationConsentAuthenticationContext implements OA
 		public OAuth2AuthorizationConsentAuthenticationContext build() {
 			Assert.notNull(get(OAuth2AuthorizationConsent.Builder.class), "authorizationConsentBuilder cannot be null");
 			Assert.notNull(get(RegisteredClient.class), "registeredClient cannot be null");
-			Assert.notNull(get(OAuth2Authorization.class), "authorization cannot be null");
 			OAuth2Authorization authorization = get(OAuth2Authorization.class);
+			Assert.notNull(authorization, "authorization cannot be null");
 			if (authorization.getAuthorizationGrantType().equals(AuthorizationGrantType.AUTHORIZATION_CODE)) {
 				Assert.notNull(get(OAuth2AuthorizationRequest.class), "authorizationRequest cannot be null");
 			}

+ 1 - 1
oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2DeviceAuthorizationConsentAuthenticationProviderTests.java

@@ -124,7 +124,7 @@ public class OAuth2DeviceAuthorizationConsentAuthenticationProviderTests {
 	}
 
 	@Test
-	public void supportsWhenTypeOAuth2DeviceAuthorizationRequestAuthenticationTokenThenReturnTrue() {
+	public void supportsWhenTypeOAuth2DeviceAuthorizationConsentAuthenticationTokenThenReturnTrue() {
 		assertThat(this.authenticationProvider.supports(OAuth2DeviceAuthorizationConsentAuthenticationToken.class)).isTrue();
 	}
 

+ 1 - 1
oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2DeviceVerificationAuthenticationProviderTests.java

@@ -118,7 +118,7 @@ public class OAuth2DeviceVerificationAuthenticationProviderTests {
 	}
 
 	@Test
-	public void supportsWhenTypeOAuth2DeviceAuthorizationRequestAuthenticationTokenThenReturnTrue() {
+	public void supportsWhenTypeOAuth2DeviceVerificationAuthenticationTokenThenReturnTrue() {
 		assertThat(this.authenticationProvider.supports(OAuth2DeviceVerificationAuthenticationToken.class)).isTrue();
 	}
 

+ 1 - 2
oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/OAuth2DeviceVerificationEndpointFilterTests.java

@@ -75,7 +75,6 @@ public class OAuth2DeviceVerificationEndpointFilterTests {
 	private static final String VERIFICATION_URI = "/oauth2/device_verification";
 	private static final String CLIENT_ID = "client-1";
 	private static final String STATE = "12345";
-	private static final String DEVICE_CODE = "EfYu_0jEL";
 	private static final String USER_CODE = "BCDF-GHJK";
 
 	private AuthenticationManager authenticationManager;
@@ -95,7 +94,7 @@ public class OAuth2DeviceVerificationEndpointFilterTests {
 	}
 
 	@Test
-	public void constructorWhenAuthenticationMangerIsNullThenThrowIllegalArgumentException() {
+	public void constructorWhenAuthenticationManagerIsNullThenThrowIllegalArgumentException() {
 		// @formatter:off
 		assertThatIllegalArgumentException()
 				.isThrownBy(() -> new OAuth2DeviceVerificationEndpointFilter(null))

+ 3 - 3
oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/authentication/OAuth2DeviceAuthorizationConsentAuthenticationConverterTests.java

@@ -86,7 +86,7 @@ public class OAuth2DeviceAuthorizationConsentAuthenticationConverterTests {
 	}
 
 	@Test
-	public void convertWhenBlankClientIdThenInvalidRequestError() {
+	public void convertWhenEmptyClientIdThenInvalidRequestError() {
 		MockHttpServletRequest request = createRequest();
 		request.addParameter(OAuth2ParameterNames.STATE, STATE);
 		request.addParameter(OAuth2ParameterNames.CLIENT_ID, "");
@@ -132,7 +132,7 @@ public class OAuth2DeviceAuthorizationConsentAuthenticationConverterTests {
 	}
 
 	@Test
-	public void convertWhenBlankUserCodeThenInvalidRequestError() {
+	public void convertWhenEmptyUserCodeThenInvalidRequestError() {
 		MockHttpServletRequest request = createRequest();
 		request.addParameter(OAuth2ParameterNames.STATE, STATE);
 		request.addParameter(OAuth2ParameterNames.CLIENT_ID, CLIENT_ID);
@@ -165,7 +165,7 @@ public class OAuth2DeviceAuthorizationConsentAuthenticationConverterTests {
 	}
 
 	@Test
-	public void convertWhenBlankStateParameterThenInvalidRequestError() {
+	public void convertWhenEmptyStateParameterThenInvalidRequestError() {
 		MockHttpServletRequest request = createRequest();
 		request.addParameter(OAuth2ParameterNames.STATE, "");
 		request.addParameter(OAuth2ParameterNames.CLIENT_ID, CLIENT_ID);

+ 2 - 2
oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/authentication/OAuth2DeviceVerificationAuthenticationConverterTests.java

@@ -81,7 +81,7 @@ public class OAuth2DeviceVerificationAuthenticationConverterTests {
 	}
 
 	@Test
-	public void convertWhenBlankUserCodeParametersThenInvalidRequestError() {
+	public void convertWhenEmptyUserCodeParameterThenInvalidRequestError() {
 		MockHttpServletRequest request = createRequest();
 		request.addParameter(OAuth2ParameterNames.USER_CODE, "");
 		// @formatter:off
@@ -95,7 +95,7 @@ public class OAuth2DeviceVerificationAuthenticationConverterTests {
 	}
 
 	@Test
-	public void convertWhenMultipleUserCodeParametersThenInvalidRequestError() {
+	public void convertWhenMultipleUserCodeParameterThenInvalidRequestError() {
 		MockHttpServletRequest request = createRequest();
 		request.addParameter(OAuth2ParameterNames.USER_CODE, USER_CODE);
 		request.addParameter(OAuth2ParameterNames.USER_CODE, "another");