forked from spring-projects/spring-authorization-server
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for OAuth 2.0 Device Authorization Grant
This commit adds tests for the following components: * AuthenticationConverters * AuthenticationProviders * Endpoint Filters Issue spring-projectsgh-44 Issue spring-projectsgh-1127
- Loading branch information
Showing
12 changed files
with
3,088 additions
and
0 deletions.
There are no files selected for viewing
405 changes: 405 additions & 0 deletions
405
...orization/authentication/OAuth2DeviceAuthorizationConsentAuthenticationProviderTests.java
Large diffs are not rendered by default.
Oops, something went wrong.
315 changes: 315 additions & 0 deletions
315
...orization/authentication/OAuth2DeviceAuthorizationRequestAuthenticationProviderTests.java
Large diffs are not rendered by default.
Oops, something went wrong.
424 changes: 424 additions & 0 deletions
424
...uth2/server/authorization/authentication/OAuth2DeviceCodeAuthenticationProviderTests.java
Large diffs are not rendered by default.
Oops, something went wrong.
305 changes: 305 additions & 0 deletions
305
...ver/authorization/authentication/OAuth2DeviceVerificationAuthenticationProviderTests.java
Large diffs are not rendered by default.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
...ramework/security/oauth2/server/authorization/authentication/OAuth2MetadataConsumers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.security.oauth2.server.authorization.authentication; | ||
|
||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
|
||
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization; | ||
|
||
/** | ||
* @author Steve Riesenberg | ||
*/ | ||
public final class OAuth2MetadataConsumers { | ||
private OAuth2MetadataConsumers() { | ||
} | ||
|
||
public static Consumer<Map<String, Object>> accessGranted() { | ||
return withTrueValue(OAuth2Authorization.Token.ACCESS_GRANTED_METADATA_NAME); | ||
} | ||
|
||
public static Consumer<Map<String, Object>> accessDenied() { | ||
return withTrueValue(OAuth2Authorization.Token.ACCESS_DENIED_METADATA_NAME); | ||
} | ||
|
||
public static Consumer<Map<String, Object>> invalidated() { | ||
return withTrueValue(OAuth2Authorization.Token.INVALIDATED_METADATA_NAME); | ||
} | ||
|
||
private static Consumer<Map<String, Object>> withTrueValue(String key) { | ||
return (metadata) -> metadata.put(key, true); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...rk/security/oauth2/server/authorization/authentication/OAuth2TokenMetadataExtractors.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.security.oauth2.server.authorization.authentication; | ||
|
||
import java.util.function.Function; | ||
|
||
import org.springframework.security.oauth2.core.OAuth2Token; | ||
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization; | ||
|
||
/** | ||
* @author Steve Riesenberg | ||
*/ | ||
public final class OAuth2TokenMetadataExtractors { | ||
private OAuth2TokenMetadataExtractors() { | ||
} | ||
|
||
public static Function<OAuth2Authorization.Token<? extends OAuth2Token>, Boolean> accessGranted() { | ||
return extractBooleanValue(OAuth2Authorization.Token.ACCESS_GRANTED_METADATA_NAME); | ||
} | ||
|
||
public static Function<OAuth2Authorization.Token<? extends OAuth2Token>, Boolean> accessDenied() { | ||
return extractBooleanValue(OAuth2Authorization.Token.ACCESS_DENIED_METADATA_NAME); | ||
} | ||
|
||
public static Function<OAuth2Authorization.Token<? extends OAuth2Token>, Boolean> invalidated() { | ||
return extractBooleanValue(OAuth2Authorization.Token.INVALIDATED_METADATA_NAME); | ||
} | ||
|
||
private static Function<OAuth2Authorization.Token<? extends OAuth2Token>, Boolean> extractBooleanValue(String key) { | ||
return (token) -> token.getMetadata(key); | ||
} | ||
} |
Oops, something went wrong.