Skip to content

Commit 12e77cf

Browse files
committed
fix(tests): adjusted integration tests
1 parent ad6feec commit 12e77cf

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

test/integration/code-engine.v2.test.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/* eslint-disable no-console */
2121
/* eslint-disable no-await-in-loop */
2222

23+
const { IamAuthenticator } = require('ibm-cloud-sdk-core');
2324
const CodeEngineV2 = require('../../dist/code-engine/v2');
2425
// eslint-disable-next-line node/no-unpublished-require
2526
const authHelper = require('../resources/auth-helper.js');
@@ -59,11 +60,31 @@ describe('CodeEngineV2', () => {
5960
// const config = readExternalSources(CodeEngineV2.DEFAULT_SERVICE_NAME);
6061

6162
test('Initialize service', async () => {
62-
// begin-common
63+
// Determine the target IAM endpoint
64+
let iamEndpoint = 'https://iam.cloud.ibm.com';
65+
if (process.env.IAM_ENDPOINT) {
66+
iamEndpoint = process.env.IAM_ENDPOINT;
67+
}
6368

64-
codeEngineService = CodeEngineV2.newInstance();
69+
// Create an IAM authenticator.
70+
const authenticator = new IamAuthenticator({
71+
apikey: process.env.CE_API_KEY,
72+
clientId: 'bx',
73+
clientSecret: 'bx',
74+
url: iamEndpoint,
75+
});
76+
77+
const codeEngineApiEndpoint = `https://${process.env.CE_API_HOST}/v2`;
78+
console.info(`Using Code Engine API endpoint: '${codeEngineApiEndpoint}'`);
6579

66-
// end-common
80+
// Construct the Code Engine client using the IAM authenticator.
81+
const options = {
82+
authenticator,
83+
serviceUrl: codeEngineApiEndpoint,
84+
};
85+
86+
// Init the service
87+
codeEngineService = CodeEngineV2.newInstance();
6788
});
6889

6990
test('listProjects request example', async () => {

0 commit comments

Comments
 (0)