From faedff310de032295167f5b3f49ffc266c44c27d Mon Sep 17 00:00:00 2001 From: Piotr Bulawa Date: Wed, 8 Nov 2023 16:11:09 +0100 Subject: [PATCH] Fix response handling --- lib/authentication/auth_okta.js | 4 ++-- test/unit/authentication/authentication_test.js | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/authentication/auth_okta.js b/lib/authentication/auth_okta.js index 035045674..42a110379 100644 --- a/lib/authentication/auth_okta.js +++ b/lib/authentication/auth_okta.js @@ -56,7 +56,7 @@ function auth_okta(password, region, account, clientType, clientVersion, httpCli var tokenUrl; await step1(authenticator, serviceName, account, username).then((response) => { - const responseData = JSON.parse(response['data']); + const responseData = response['data']; const success = responseData['success']; const errorCode = responseData['code']; const errorMessage = responseData['message']; @@ -78,7 +78,7 @@ function auth_okta(password, region, account, clientType, clientVersion, httpCli var oneTimeToken; await step3(tokenUrl, username, password).then((response) => { - var data = JSON.parse(response['data']); + var data = response['data']; if (data['sessionToken']) { oneTimeToken = data['sessionToken']; diff --git a/test/unit/authentication/authentication_test.js b/test/unit/authentication/authentication_test.js index 05992a364..bd98bb9f9 100644 --- a/test/unit/authentication/authentication_test.js +++ b/test/unit/authentication/authentication_test.js @@ -398,20 +398,20 @@ describe('okta authentication', function () { json = { - data: JSON.stringify( { + data: { success: true, data: { ssoUrl: mockssoUrl, tokenUrl: mockTokenUrl } - }) + } } } if (url === mockTokenUrl) { json = { - data: JSON.stringify(mockCookieToken) + data: mockCookieToken } } return json; @@ -471,14 +471,14 @@ describe('okta authentication', function () { json = { - data: JSON.stringify({ + data: { success: true, data: { ssoUrl: mockssoUrl, tokenUrl: 'abcd' } - }) + } } } return json; @@ -514,21 +514,21 @@ describe('okta authentication', function () { json = { - data: JSON.stringify({ + data: { success: true, data: { ssoUrl: mockssoUrl, tokenUrl: mockTokenUrl } - }) + } } } if (url === mockTokenUrl) { json = { - data: JSON.stringify(mockCookieToken) + data: mockCookieToken } } return json;