Skip to content

Commit d5f38dc

Browse files
committed
Migrate OpaqueTokenDslTests
Signed-off-by: Andreas Svanberg <[email protected]>
1 parent 7d301f8 commit d5f38dc

File tree

1 file changed

+12
-10
lines changed
  • config/src/test/kotlin/org/springframework/security/config/annotation/web/oauth2/resourceserver

1 file changed

+12
-10
lines changed

config/src/test/kotlin/org/springframework/security/config/annotation/web/oauth2/resourceserver/OpaqueTokenDslTests.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.junit.jupiter.api.extension.ExtendWith
2424
import org.springframework.beans.factory.annotation.Autowired
2525
import org.springframework.context.annotation.Bean
2626
import org.springframework.context.annotation.Configuration
27+
import org.springframework.core.ParameterizedTypeReference
2728
import org.springframework.http.HttpHeaders
2829
import org.springframework.http.HttpStatus
2930
import org.springframework.http.MediaType
@@ -41,7 +42,6 @@ import org.springframework.security.oauth2.core.DefaultOAuth2AuthenticatedPrinci
4142
import org.springframework.security.oauth2.core.TestOAuth2AccessTokens
4243
import org.springframework.security.oauth2.jwt.JwtClaimNames
4344
import org.springframework.security.oauth2.server.resource.authentication.BearerTokenAuthentication
44-
import org.springframework.security.oauth2.server.resource.introspection.NimbusOpaqueTokenIntrospector
4545
import org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector
4646
import org.springframework.security.oauth2.server.resource.introspection.SpringOpaqueTokenIntrospector
4747
import org.springframework.security.web.SecurityFilterChain
@@ -84,14 +84,16 @@ class OpaqueTokenDslTests {
8484
val headers = HttpHeaders().apply {
8585
contentType = MediaType.APPLICATION_JSON
8686
}
87-
val entity = ResponseEntity("{\n" +
88-
" \"active\" : true,\n" +
89-
" \"sub\": \"test-subject\",\n" +
90-
" \"scope\": \"message:read\",\n" +
91-
" \"exp\": 4683883211\n" +
92-
"}", headers, HttpStatus.OK)
87+
val entity = ResponseEntity(
88+
mapOf<String, Any>(
89+
"active" to true,
90+
"sub" to "test-subject",
91+
"scope" to "message:read",
92+
"exp" to 4683883211
93+
), headers, HttpStatus.OK
94+
)
9395
every {
94-
DefaultOpaqueConfig.REST.exchange(any(), eq(String::class.java))
96+
DefaultOpaqueConfig.REST.exchange(any(), any(ParameterizedTypeReference::class))
9597
} returns entity
9698

9799
this.mockMvc.get("/authenticated") {
@@ -127,8 +129,8 @@ class OpaqueTokenDslTests {
127129
open fun rest(): RestOperations = REST
128130

129131
@Bean
130-
open fun tokenIntrospectionClient(): NimbusOpaqueTokenIntrospector {
131-
return NimbusOpaqueTokenIntrospector("https://example.org/introspect", REST)
132+
open fun tokenIntrospectionClient(): SpringOpaqueTokenIntrospector {
133+
return SpringOpaqueTokenIntrospector("https://example.org/introspect", REST)
132134
}
133135
}
134136

0 commit comments

Comments
 (0)