Skip to content

Commit b988553

Browse files
update developer hub host configuration in OAuth tests
1 parent a92f7bc commit b988553

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/sanity-check/api/oauth-test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@ const oauthClient = client.oauth({
2121
redirectUri: process.env.REDIRECT_URI
2222
})
2323

24+
// Override developerHubBaseUrl for custom host
25+
if (process.env.HOST) {
26+
let developerHubHost = null
27+
28+
// For dev or stag environments (e.g., dev11-api.csnonprod.com -> dev-developerhub-api.csnonprod.com)
29+
if (process.env.HOST.startsWith('dev')) {
30+
developerHubHost = process.env.HOST.replace(/^dev\d*-api\./, 'dev-developerhub-api.')
31+
} else if (process.env.HOST.startsWith('stag')) {
32+
developerHubHost = process.env.HOST.replace(/^stag\d*-api\./, 'stag-developerhub-api.')
33+
}
34+
// For standard Contentstack region hosts (e.g., au-api.contentstack.com -> au-developerhub-api.contentstack.com)
35+
else if (process.env.HOST.includes('contentstack.com') || process.env.HOST.includes('contentstack.io')) {
36+
developerHubHost = process.env.HOST.replace(/-api\./, '-developerhub-api.')
37+
}
38+
39+
if (developerHubHost) {
40+
oauthClient.axiosInstance.defaults.developerHubBaseUrl = `https://${developerHubHost}`
41+
oauthClient.developerHubBaseUrl = `https://${developerHubHost}`
42+
}
43+
}
44+
2445
describe('OAuth Authentication API Test', () => {
2546
it('should login with credentials', done => {
2647
client.login({ email: process.env.EMAIL, password: process.env.PASSWORD }, { include_orgs: true, include_orgs_roles: true, include_stack_roles: true, include_user_settings: true }).then((response) => {

0 commit comments

Comments
 (0)