Adicionando grantType aos testes

This commit is contained in:
Leandro Costa 2023-01-26 23:06:09 -03:00
parent a72fe1d9c8
commit ee68092e23

View file

@ -13,9 +13,10 @@ const clientSecret = "testClientSecret";
const baseClientParams = { apiUrl, authUrl, clientId, clientSecret }; const baseClientParams = { apiUrl, authUrl, clientId, clientSecret };
const basicAuth = `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString('base64')}`; const basicAuth = `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString('base64')}`;
const contentTypeApplicationJson = "application/json"; const contentTypeApplicationJson = "application/json";
const defaultGrantType='{"grant_type":"client_credentials"}';
describe("lhisp-oauth-client", ()=>{ describe("lhisp-oauth-client", ()=>{
it("Shout Get Access Token with Standard Config", async ()=>{ it("Shoud Get Access Token with Standard Config", async ()=>{
const cli = getOauthClient(); const cli = getOauthClient();
mockedAxios.request.mockReset(); mockedAxios.request.mockReset();
mockedAxios.request.mockResolvedValueOnce({ mockedAxios.request.mockResolvedValueOnce({
@ -36,14 +37,15 @@ describe("lhisp-oauth-client", ()=>{
headers: { headers: {
Authorization: basicAuth, Authorization: basicAuth,
'Content-Type': contentTypeApplicationJson, 'Content-Type': contentTypeApplicationJson,
} },
data: defaultGrantType,
})); }));
}); });
it("Shout Get Access Token with Custom Auth Header", async ()=>{ it("Shoud Get Access Token with Custom Auth Header", async ()=>{
const cli = getOauthClient({ const cli = getOauthClient({
...baseClientParams, ...baseClientParams,
authHeaderName: "CustomAuthorizationHeader" authHeaderName: 'CustomAuthorizationHeader',
}); });
mockedAxios.request.mockReset(); mockedAxios.request.mockReset();
mockedAxios.request.mockResolvedValueOnce({ mockedAxios.request.mockResolvedValueOnce({
@ -64,7 +66,8 @@ describe("lhisp-oauth-client", ()=>{
headers: { headers: {
CustomAuthorizationHeader: basicAuth, CustomAuthorizationHeader: basicAuth,
'Content-Type': contentTypeApplicationJson, 'Content-Type': contentTypeApplicationJson,
} },
data: defaultGrantType,
})); }));
}); });
}); });