0
Fork 0
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:
wangsijie 2024-08-22 14:41:55 +08:00 committed by GitHub
parent 55cf84bbea
commit 50bbcb69ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 () => {