@@ -17,56 +17,56 @@ internal class OAuth2TokenCallbackTest {
17
17
RequestMappingTokenCallback (
18
18
issuerId = " issuer1" ,
19
19
requestMappings =
20
- listOf (
21
- RequestMapping (
22
- requestParam = " scope" ,
23
- match = " scope1" ,
24
- claims =
25
- mapOf (
26
- " sub" to " subByScope1" ,
27
- " aud" to listOf (" audByScope1" ),
28
- " custom" to " custom1" ,
29
- ),
20
+ listOf (
21
+ RequestMapping (
22
+ requestParam = " scope" ,
23
+ match = " scope1" ,
24
+ claims =
25
+ mapOf (
26
+ " sub" to " subByScope1" ,
27
+ " aud" to listOf (" audByScope1" ),
28
+ " custom" to " custom1" ,
30
29
),
31
- RequestMapping (
32
- requestParam = " scope " ,
33
- match = " scope2 " ,
34
- typeHeader = " JWT2 " ,
35
- claims =
36
- mapOf (
37
- " sub " to " subByScope2 " ,
38
- " aud " to listOf ( " audByScope2 " ) ,
39
- " custom " to " custom2 " ,
40
- ) ,
30
+ ),
31
+ RequestMapping (
32
+ requestParam = " scope " ,
33
+ match = " scope2 " ,
34
+ typeHeader = " JWT2 " ,
35
+ claims =
36
+ mapOf (
37
+ " sub " to " subByScope2 " ,
38
+ " aud " to listOf ( " audByScope2 " ) ,
39
+ " custom " to " custom2 " ,
41
40
),
42
- RequestMapping (
43
- requestParam = " audience " ,
44
- match = " https://myapp.com/jwt/aud/.* " ,
45
- claims =
46
- mapOf (
47
- " sub " to " \$ {clientId} " ,
48
- " aud " to listOf ( " \$ {audience} " ) ,
49
- ),
41
+ ),
42
+ RequestMapping (
43
+ requestParam = " audience " ,
44
+ match = " https://myapp.com/jwt/aud/.* " ,
45
+ claims =
46
+ mapOf (
47
+ " sub " to " \$ {clientId} " ,
48
+ " aud " to listOf ( " \$ {audience} " ),
50
49
),
51
- RequestMapping (
52
- requestParam = " grant_type " ,
53
- match = " authorization_code " ,
54
- claims =
55
- mapOf (
56
- " sub " to " defaultSub " ,
57
- " aud " to listOf ( " defaultAud " ) ,
58
- ),
50
+ ),
51
+ RequestMapping (
52
+ requestParam = " grant_type " ,
53
+ match = " authorization_code " ,
54
+ claims =
55
+ mapOf (
56
+ " sub " to " defaultSub " ,
57
+ " aud " to listOf ( " defaultAud " ),
59
58
),
60
- RequestMapping (
61
- requestParam = " grant_type " ,
62
- match = " * " ,
63
- claims =
64
- mapOf (
65
- " sub " to " \$ {clientId} " ,
66
- " aud " to listOf ( " defaultAud " ) ,
67
- ),
59
+ ),
60
+ RequestMapping (
61
+ requestParam = " grant_type " ,
62
+ match = " * " ,
63
+ claims =
64
+ mapOf (
65
+ " sub " to " \$ {clientId} " ,
66
+ " aud " to listOf ( " defaultAud " ),
68
67
),
69
68
),
69
+ ),
70
70
tokenExpiry = 120 ,
71
71
)
72
72
@@ -124,6 +124,31 @@ internal class OAuth2TokenCallbackTest {
124
124
issuer1.typeHeader(grantTypeShouldMatch) shouldBe " JWT"
125
125
}
126
126
}
127
+
128
+ @Test
129
+ fun `token request with custom parameters in token request should include claims with placeholder names` () {
130
+ val request = clientCredentialsRequest(
131
+ " scope" to " testscope:something" ,
132
+ " mock_token_type" to " custom" ,
133
+ )
134
+ RequestMappingTokenCallback (
135
+ issuerId = " issuer1" ,
136
+ requestMappings =
137
+ listOf (
138
+ RequestMapping (
139
+ requestParam = " scope" ,
140
+ match = " testscope:.*" ,
141
+ claims = mapOf (
142
+ " sub" to " \$ {clientId}" ,
143
+ " scope" to " \$ {scope}" ,
144
+ " mock_token_type" to " \$ {mock_token_type}" ,
145
+ ),
146
+ ),
147
+ )
148
+ ).addClaims(request).asClue {
149
+ it shouldContainAll mapOf (" sub" to clientId, " scope" to " testscope:something" , " mock_token_type" to " custom" )
150
+ }
151
+ }
127
152
}
128
153
129
154
@Nested
0 commit comments