From 3db6514f40fb296464bbb2583b6d8f7f6c20d5e5 Mon Sep 17 00:00:00 2001 From: Leandro Costa Date: Fri, 16 Jun 2023 22:22:00 -0300 Subject: [PATCH] Revert "feat: adiciona flag disableAuthContentType" This reverts commit 970ccff48ed1efabdf09b337b6f91bcfb7098345. --- __tests__/lhisp-oauth-client.test.ts | 18 ------------------ src/lhisp-oauth-client.t.ts | 1 - src/lhisp-oauth-client.ts | 9 +++++---- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/__tests__/lhisp-oauth-client.test.ts b/__tests__/lhisp-oauth-client.test.ts index c4e26bd..a47af5b 100644 --- a/__tests__/lhisp-oauth-client.test.ts +++ b/__tests__/lhisp-oauth-client.test.ts @@ -105,24 +105,6 @@ describe("Get Access Token", () => { }) ); }); - - it("Shoud Get with Credentials without ContentType", async () => { - const cli = getOauthClient({ - ...baseClientParams, - disableAuthContentType: true, - }); - await accessTokenValidator(cli); - expect(mockedAxios.request).toBeCalledWith( - expect.objectContaining({ - url: authUrl, - method: "POST", - headers: { - Authorization: basicAuth, - }, - data: `grant_type=${defaultGrantValue}`, - }) - ); - }); }); describe("Request", () => { diff --git a/src/lhisp-oauth-client.t.ts b/src/lhisp-oauth-client.t.ts index 954b77c..cacb4f8 100644 --- a/src/lhisp-oauth-client.t.ts +++ b/src/lhisp-oauth-client.t.ts @@ -18,7 +18,6 @@ export interface LhispOauthClientConstructorParams { grantType?: string; authContentType?: ContentType; sendAuthCredentialsOnRequestBody?: boolean; - disableAuthContentType?: boolean; debug?: boolean; } diff --git a/src/lhisp-oauth-client.ts b/src/lhisp-oauth-client.ts index e51f7a5..8c63e33 100644 --- a/src/lhisp-oauth-client.ts +++ b/src/lhisp-oauth-client.ts @@ -21,7 +21,6 @@ export class LhispOauthClient { protected authHeaderName: string; protected tokenHeaderName: string; protected authContentType: ContentType; - protected disableAuthContentType = false; protected certificado?: string; protected senhaCertificado?: string; protected authScope?: string; @@ -54,7 +53,6 @@ export class LhispOauthClient { this.authScope = params.authScope; this.grantType = params.grantType || defaultGrantType; this.authContentType = params.authContentType || defaultAuthContentType; - this.disableAuthContentType = Boolean(params.disableAuthContentType); this.clientId = params.clientId; this.clientSecret = params.clientSecret; this.authHeaderName = params.authHeaderName || defaultAuthHeaderName; @@ -100,7 +98,7 @@ export class LhispOauthClient { httpsAgent: this.agent, headers: { [this.authHeaderName]: this.getAuthHeaderValue(), - ...(this.disableAuthContentType ? {} : { "Content-Type": this.authContentType }), + "Content-Type": this.authContentType, }, data: {}, }; @@ -113,7 +111,10 @@ export class LhispOauthClient { if (this.clientSecret) authRequestOpt.data.client_secret = this.clientSecret; } - authRequestOpt.data = this.parseData({ data: authRequestOpt.data, contentType: this.authContentType }); + authRequestOpt.data = this.parseData({ + data: authRequestOpt.data, + contentType: this.authContentType, + }); const resp = await axios.request(authRequestOpt); this.accessToken = this.buildAccessToken(resp.data); this.tokenCreatedAt = new Date().getTime();