Testando custom GrantType
This commit is contained in:
parent
ee68092e23
commit
5209767d90
1 changed files with 29 additions and 0 deletions
|
@ -70,6 +70,35 @@ describe("lhisp-oauth-client", ()=>{
|
||||||
data: defaultGrantType,
|
data: defaultGrantType,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Shoud Get Access Token with Custom Grant Type", async ()=>{
|
||||||
|
const cli = getOauthClient({
|
||||||
|
...baseClientParams,
|
||||||
|
grantType: 'PermissaoCustom',
|
||||||
|
});
|
||||||
|
mockedAxios.request.mockReset();
|
||||||
|
mockedAxios.request.mockResolvedValueOnce({
|
||||||
|
data: mockedAccessToken
|
||||||
|
});
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
|
const accessToken = await cli.getAccessToken();
|
||||||
|
expect(accessToken).toBeDefined();
|
||||||
|
expect(accessToken.token_type).toBe(mockedAccessToken.token_type);
|
||||||
|
expect(accessToken.access_token).toBe(mockedAccessToken.access_token);
|
||||||
|
expect(accessToken.expires_in).toBe(mockedAccessToken.expires_in);
|
||||||
|
expect(accessToken.scope).toBe(mockedAccessToken.scope);
|
||||||
|
expect(accessToken.created_at).toBeGreaterThanOrEqual(now);
|
||||||
|
expect(mockedAxios.request).toBeCalledWith(expect.objectContaining({
|
||||||
|
url: authUrl,
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Authorization: basicAuth,
|
||||||
|
'Content-Type': contentTypeApplicationJson,
|
||||||
|
},
|
||||||
|
data: '{"grant_type":"PermissaoCustom"}',
|
||||||
|
}));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function getOauthClient(opt:LhispOauthClientConstructorParams=baseClientParams){
|
function getOauthClient(opt:LhispOauthClientConstructorParams=baseClientParams){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue