@@ -117,6 +117,52 @@ internal class IntrospectTest {
117117 }
118118 }
119119
120+ @Test
121+ fun `introspect should return single audience as string` () {
122+ val issuerUrl = " http://localhost/default"
123+ val tokenProvider = OAuth2TokenProvider ()
124+ val claims =
125+ mapOf (
126+ " iss" to issuerUrl,
127+ " client_id" to " yolo" ,
128+ " token_type" to " token" ,
129+ " sub" to " foo" ,
130+ " aud" to " some-audience" ,
131+ )
132+ val token = tokenProvider.jwt(claims)
133+ val request = request(" $issuerUrl$INTROSPECT " , token.serialize())
134+
135+ routes { introspect(tokenProvider) }.invoke(request).asClue {
136+ it.status shouldBe 200
137+ val response = it.parse<Map <String , Any >>()
138+ response shouldContainAll claims
139+ response shouldContain (" active" to true )
140+ }
141+ }
142+
143+ @Test
144+ fun `introspect should return multiple audiences as array of strings` () {
145+ val issuerUrl = " http://localhost/default"
146+ val tokenProvider = OAuth2TokenProvider ()
147+ val claims =
148+ mapOf (
149+ " iss" to issuerUrl,
150+ " client_id" to " yolo" ,
151+ " token_type" to " token" ,
152+ " sub" to " foo" ,
153+ " aud" to listOf (" audience1" , " audience2" ),
154+ )
155+ val token = tokenProvider.jwt(claims)
156+ val request = request(" $issuerUrl$INTROSPECT " , token.serialize())
157+
158+ routes { introspect(tokenProvider) }.invoke(request).asClue {
159+ it.status shouldBe 200
160+ val response = it.parse<Map <String , Any >>()
161+ response shouldContainAll claims
162+ response shouldContain (" active" to true )
163+ }
164+ }
165+
120166 @Test
121167 fun `introspect should return active false when token is missing` () {
122168 val url = " http://localhost/default$INTROSPECT "
0 commit comments