Skip to content

Commit

Permalink
test: add integration tests for pat token introspection (#6501)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangsijie authored Aug 22, 2024
1 parent 55cf84b commit 50bbcb6
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,32 @@ describe('Token Exchange (Personal Access Token)', () => {
grant_type: GrantType.TokenExchange,
subject_token: testToken,
subject_token_type: tokenType,
scope: 'openid profile',
}),
})
.json();
.json<{ access_token: string }>();

expect(body).toHaveProperty('access_token');
expect(body).toHaveProperty('token_type', 'Bearer');
expect(body).toHaveProperty('expires_in');
expect(body).toHaveProperty('scope', '');
expect(body).toHaveProperty('scope', 'openid profile');

const { access_token } = body;
// Send to introspection endpoint
const introspectionResponse = await oidcApi
.post('token/introspection', {
headers: {
...formUrlEncodedHeaders,
Authorization: authorizationHeader,
},
body: new URLSearchParams({
token: access_token,
token_type_hint: 'access_token',
}),
})
.json();
expect(introspectionResponse).toHaveProperty('active', true);
expect(introspectionResponse).toHaveProperty('sub', testUserId);
});

it('should be able to use for multiple times', async () => {
Expand Down

0 comments on commit 50bbcb6

Please sign in to comment.