From aa9a96cd0a49849fe2e197c0474a4dbec95fca96 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Fri, 3 Nov 2017 20:35:13 +0100 Subject: [PATCH] Fix tests --- app/__mocks__/insomnia-node-libcurl.js | 4 ++ .../grant-authorization-code.test.js | 48 ------------------- 2 files changed, 4 insertions(+), 48 deletions(-) diff --git a/app/__mocks__/insomnia-node-libcurl.js b/app/__mocks__/insomnia-node-libcurl.js index 38a86cbe5c..7754e5a4d7 100644 --- a/app/__mocks__/insomnia-node-libcurl.js +++ b/app/__mocks__/insomnia-node-libcurl.js @@ -8,6 +8,10 @@ class Curl extends EventEmitter { this._meta = {}; } + static getVersion () { + return 'libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0'; + } + setOpt (name, value) { if (!name) { throw new Error(`Invalid option ${name} ${value}`); diff --git a/app/network/o-auth-2/__tests__/grant-authorization-code.test.js b/app/network/o-auth-2/__tests__/grant-authorization-code.test.js index 6d5f00f537..a0d57a09c6 100644 --- a/app/network/o-auth-2/__tests__/grant-authorization-code.test.js +++ b/app/network/o-auth-2/__tests__/grant-authorization-code.test.js @@ -107,52 +107,4 @@ describe('authorization_code', () => { error_description: null }); }); - - it('handles hostless redirects', async () => { - createBWRedirectMock(`/redirect?code=code_123&state=${STATE}`); - window.fetch = jest.fn(() => new window.Response( - `access_token=token_123&token_type=token_type&scope=${SCOPE}`, - {headers: {'Content-Type': 'application/x-www-form-urlencoded'}} - )); - - const result = await getToken( - AUTHORIZE_URL, - ACCESS_TOKEN_URL, - true, - CLIENT_ID, - CLIENT_SECRET, - REDIRECT_URI, - SCOPE, - STATE - ); - - // Check the request to fetch the token - expect(window.fetch.mock.calls).toEqual([[ACCESS_TOKEN_URL, { - body: [ - 'grant_type=authorization_code', - 'code=code_123', - `redirect_uri=${encodeURIComponent(REDIRECT_URI)}`, - `state=${STATE}`, - `client_id=${CLIENT_ID}`, - `client_secret=${CLIENT_SECRET}` - ].join('&'), - method: 'POST', - headers: { - 'Accept': 'application/x-www-form-urlencoded, application/json', - 'Content-Type': 'application/x-www-form-urlencoded' - } - }]]); - - // Check the expected value - expect(result).toEqual({ - access_token: 'token_123', - refresh_token: null, - expires_in: null, - token_type: 'token_type', - scope: SCOPE, - error: null, - error_uri: null, - error_description: null - }); - }); });