Skip to content

Commit 1038b50

Browse files
committed
fix endpointUri regression
- fixes issue #392
1 parent 4e671da commit 1038b50

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ ZENDESK_TOKEN=myToken
77
ZENDESK_PASSWORD=myPassword
88
ZENDESK_SUBDOMAIN=nodejsapi
99
ZENDESK_OAUTH_ACCESS_TOKEN=myOAuthAccessToken
10+
ZENDESK_ENDPOINT_URI=https://nodejsapi.zendesk.com/api/v2
1011

src/clients/client.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const {
99
flatten,
1010
checkRequestResponse,
1111
processResponseBody,
12-
generateUserAgent,
1312
} = require('./helpers');
1413

1514
/**
@@ -51,7 +50,6 @@ class Client {
5150
this.sideLoad = [];
5251
this.jsonAPINames = [];
5352
this.useDotJson = true;
54-
this.userAgent = generateUserAgent();
5553
this.eventTarget = new CustomEventTarget();
5654
}
5755

@@ -95,7 +93,7 @@ class Client {
9593
* @private
9694
*/
9795
_buildOptions(options, apiType = ApiTypes.core) {
98-
const endpointUri = this._getEndpointUri(options.subdomain, apiType);
96+
const endpointUri = options.endpointUri ?? this._getEndpointUri(options.subdomain, apiType);
9997
const data = {...options, endpointUri};
10098
return {
10199
...data,

test/authentication.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const password = process.env.ZENDESK_PASSWORD;
1212
const token = process.env.ZENDESK_TOKEN;
1313
const oauthAccessToken = process.env.ZENDESK_OAUTH_ACCESS_TOKEN;
1414
const TEST_USER = process.env.ZENDESK_FULL_NAME;
15+
const endpointUri = process.env.ZENDESK_ENDPOINT_URI;
1516

1617
describe('Zendesk Client Authentication', () => {
1718
beforeAll(async () => {
@@ -108,4 +109,11 @@ describe('Zendesk Client Authentication', () => {
108109
await verifyUser(client, TEST_USER);
109110
nockDone();
110111
});
112+
113+
it('should authenticate a user with a valid endpoint', async () => {
114+
const {nockDone} = await nockBack('authentication_test_endpoint_uri.json');
115+
const client = setupClient({endpointUri, token, subdomain: undefined});
116+
await verifyUser(client, TEST_USER);
117+
nockDone();
118+
});
111119
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[
2+
{
3+
"scope": "https://nodejsapi.zendesk.com:443",
4+
"method": "GET",
5+
"path": "/api/v2/users/me.json",
6+
"body": "",
7+
"status": 200,
8+
"response": {
9+
"user": {
10+
"name": "TEST USER"
11+
}
12+
},
13+
"responseIsBinary": false
14+
}
15+
]

0 commit comments

Comments
 (0)