From 6faa3a93d9ff6aecac33be83146435b1054f8b78 Mon Sep 17 00:00:00 2001 From: netama Date: Tue, 10 Oct 2023 22:36:10 +0300 Subject: [PATCH] SALTO-4870 always default domain to zendesk.com (#4960) --- packages/zendesk-adapter/src/client/connection.ts | 3 ++- .../zendesk-adapter/test/adapter_creator.test.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/zendesk-adapter/src/client/connection.ts b/packages/zendesk-adapter/src/client/connection.ts index 322a07561c7..a1837b64958 100644 --- a/packages/zendesk-adapter/src/client/connection.ts +++ b/packages/zendesk-adapter/src/client/connection.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import _ from 'lodash' import axios from 'axios' import axiosRetry from 'axios-retry' import { AccountInfo } from '@salto-io/adapter-api' @@ -40,7 +41,7 @@ const EXPECTED_VALID_ACCOUNT_RES = Joi.object({ }).unknown(true).required() export const instanceUrl = (subdomain: string, domain?: string): string => ( - domain === undefined ? `https://${subdomain}.zendesk.com` : `https://${subdomain}.${domain}` + _.isEmpty(domain) ? `https://${subdomain}.zendesk.com` : `https://${subdomain}.${domain}` ) const baseUrl = instanceUrl // A URL for resource files diff --git a/packages/zendesk-adapter/test/adapter_creator.test.ts b/packages/zendesk-adapter/test/adapter_creator.test.ts index 690e6856b21..37eed1b40d3 100644 --- a/packages/zendesk-adapter/test/adapter_creator.test.ts +++ b/packages/zendesk-adapter/test/adapter_creator.test.ts @@ -230,6 +230,18 @@ describe('adapter creator', () => { port: 8080, clientId: 'client', })).toEqual('https://abc.zendesk1.org/oauth/authorizations/new?response_type=token&redirect_uri=http://localhost:8080&client_id=client&scope=read%20write') + expect(createUrlFromUserInput({ + subdomain: 'abc', + domain: '', + port: 8080, + clientId: 'client', + })).toEqual('https://abc.zendesk.com/oauth/authorizations/new?response_type=token&redirect_uri=http://localhost:8080&client_id=client&scope=read%20write') + expect(createUrlFromUserInput({ + subdomain: 'abc', + domain: undefined, + port: 8080, + clientId: 'client', + })).toEqual('https://abc.zendesk.com/oauth/authorizations/new?response_type=token&redirect_uri=http://localhost:8080&client_id=client&scope=read%20write') }) it('should validate credentials using createConnection', async () => {