mirror of
https://github.com/logto-io/logto.git
synced 2025-02-03 21:48:55 -05:00
fix(core): fix did not mock request error which results in timeouts (#471)
This commit is contained in:
parent
0444efd844
commit
84f30fe04b
1 changed files with 10 additions and 3 deletions
|
@ -97,8 +97,11 @@ describe('getUserInfo', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws SocialAccessTokenInvalid error if remote response code is 40001', async () => {
|
it('throws SocialAccessTokenInvalid error if errcode is 40001', async () => {
|
||||||
nock(userInfoEndpointUrl.origin).get(userInfoEndpointUrl.pathname).query(parameters).reply(401);
|
nock(userInfoEndpointUrl.origin)
|
||||||
|
.get(userInfoEndpointUrl.pathname)
|
||||||
|
.query(parameters)
|
||||||
|
.reply(200, { errcode: 40_001 });
|
||||||
await expect(
|
await expect(
|
||||||
getUserInfo({ accessToken: 'accessToken', openid: 'openid' })
|
getUserInfo({ accessToken: 'accessToken', openid: 'openid' })
|
||||||
).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid));
|
).rejects.toMatchError(new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid));
|
||||||
|
@ -119,7 +122,11 @@ describe('getUserInfo', () => {
|
||||||
).rejects.toMatchError(new Error('invalid openid'));
|
).rejects.toMatchError(new Error('invalid openid'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws SocialAccessTokenInvalid error if openid is missing', async () => {
|
it('throws SocialAccessTokenInvalid error if response code is 401', async () => {
|
||||||
|
nock(userInfoEndpointUrl.origin)
|
||||||
|
.get(userInfoEndpointUrl.pathname)
|
||||||
|
.query(new URLSearchParams({ access_token: 'accessToken' }))
|
||||||
|
.reply(401);
|
||||||
await expect(getUserInfo({ accessToken: 'accessToken' })).rejects.toMatchError(
|
await expect(getUserInfo({ accessToken: 'accessToken' })).rejects.toMatchError(
|
||||||
new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)
|
new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue