From 3ad235320b7e8d997b238af29c1f2a38e9c9a56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Wed, 15 May 2024 16:15:16 +0200 Subject: [PATCH] fix formatting issues --- .../@n8n/client-oauth2/src/ClientOAuth2Token.ts | 7 ++++--- .../@n8n/client-oauth2/test/CredentialsFlow.test.ts | 13 ++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/@n8n/client-oauth2/src/ClientOAuth2Token.ts b/packages/@n8n/client-oauth2/src/ClientOAuth2Token.ts index 4910e86ab80d7..505bd7c98286a 100644 --- a/packages/@n8n/client-oauth2/src/ClientOAuth2Token.ts +++ b/packages/@n8n/client-oauth2/src/ClientOAuth2Token.ts @@ -10,6 +10,7 @@ export interface ClientOAuth2TokenData extends Record = { + const body: Record = { refresh_token: this.refreshToken, grant_type: 'refresh_token', }; @@ -93,8 +94,8 @@ export class ClientOAuth2Token { { url: options.accessTokenUri, method: 'POST', - headers: headers, - body: body, + headers, + body, }, options, ); diff --git a/packages/@n8n/client-oauth2/test/CredentialsFlow.test.ts b/packages/@n8n/client-oauth2/test/CredentialsFlow.test.ts index 333487b09e26d..39978c41f8d08 100644 --- a/packages/@n8n/client-oauth2/test/CredentialsFlow.test.ts +++ b/packages/@n8n/client-oauth2/test/CredentialsFlow.test.ts @@ -159,8 +159,10 @@ describe('CredentialsFlow', () => { const token = await authClient.credentials.getToken(); expect(token.accessToken).toEqual(config.accessToken); - mockRefreshCall(); + const requestPromise = mockRefreshCall(); const token1 = await token.refresh(); + await requestPromise; + expect(token1).toBeInstanceOf(ClientOAuth2Token); expect(token1.accessToken).toEqual(config.refreshedAccessToken); expect(token1.tokenType).toEqual('bearer'); @@ -181,11 +183,16 @@ describe('CredentialsFlow', () => { expect(token1.accessToken).toEqual(config.refreshedAccessToken); expect(token1.tokenType).toEqual('bearer'); expect(headers?.authorization).toBe(undefined); - expect(body).toEqual('refresh_token=def456token&grant_type=refresh_token&client_id=abc&client_secret=123'); + expect(body).toEqual( + 'refresh_token=def456token&grant_type=refresh_token&client_id=abc&client_secret=123', + ); }); it('should make a request to get a new access token with authentication = "header"', async () => { - const authClient = createAuthClient({ scopes: ['notifications'], authentication: 'header' }); + const authClient = createAuthClient({ + scopes: ['notifications'], + authentication: 'header', + }); void mockTokenCall({ requestedScope: 'notifications' }); const token = await authClient.credentials.getToken();