|
20 | 20 | /* eslint-disable no-console */ |
21 | 21 | /* eslint-disable no-await-in-loop */ |
22 | 22 |
|
| 23 | +const { IamAuthenticator } = require('ibm-cloud-sdk-core'); |
23 | 24 | const CodeEngineV2 = require('../../dist/code-engine/v2'); |
24 | 25 | // eslint-disable-next-line node/no-unpublished-require |
25 | 26 | const authHelper = require('../resources/auth-helper.js'); |
@@ -59,11 +60,31 @@ describe('CodeEngineV2', () => { |
59 | 60 | // const config = readExternalSources(CodeEngineV2.DEFAULT_SERVICE_NAME); |
60 | 61 |
|
61 | 62 | 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 | + } |
63 | 68 |
|
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}'`); |
65 | 79 |
|
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(); |
67 | 88 | }); |
68 | 89 |
|
69 | 90 | test('listProjects request example', async () => { |
|
0 commit comments