mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
test: add integration tests for pat token introspection (#6501)
This commit is contained in:
parent
55cf84bbea
commit
50bbcb69ee
1 changed files with 20 additions and 2 deletions
|
@ -80,14 +80,32 @@ describe('Token Exchange (Personal Access Token)', () => {
|
||||||
grant_type: GrantType.TokenExchange,
|
grant_type: GrantType.TokenExchange,
|
||||||
subject_token: testToken,
|
subject_token: testToken,
|
||||||
subject_token_type: tokenType,
|
subject_token_type: tokenType,
|
||||||
|
scope: 'openid profile',
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.json();
|
.json<{ access_token: string }>();
|
||||||
|
|
||||||
expect(body).toHaveProperty('access_token');
|
expect(body).toHaveProperty('access_token');
|
||||||
expect(body).toHaveProperty('token_type', 'Bearer');
|
expect(body).toHaveProperty('token_type', 'Bearer');
|
||||||
expect(body).toHaveProperty('expires_in');
|
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 () => {
|
it('should be able to use for multiple times', async () => {
|
||||||
|
|
Loading…
Reference in a new issue