-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #584 from mountaindude/535
535
- Loading branch information
Showing
44 changed files
with
703 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,3 +153,5 @@ certificate.p12 | |
.vscode/launch.json | ||
ctrl-q.exe | ||
.vscode/launch.json | ||
.test.env | ||
.vscode/launch.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { jest, test, expect, describe } from '@jest/globals'; | ||
import { qscloudTestConnection } from '../../../lib/cmd/qscloud/testconnection.js'; | ||
|
||
const options = { | ||
logLevel: process.env.CTRL_Q_LOG_LEVEL || 'info', | ||
tenantHost: process.env.CTRLQ_TENANT_HOST || '', | ||
authType: process.env.CTRLQ_AUTH_TYPE || 'apikey', | ||
apikey: process.env.CTRLQ_API_KEY || '', | ||
}; | ||
|
||
const defaultTestTimeout = process.env.CTRL_Q_TEST_TIMEOUT || 120000; // 2 minute default timeout | ||
console.log(`Jest timeout: ${defaultTestTimeout}`); | ||
jest.setTimeout(defaultTestTimeout); | ||
|
||
// Connection test using JWT auth | ||
describe('connection test (JWT auth)', () => { | ||
test('Verify parameters', async () => { | ||
expect(options.logLevel).not.toHaveLength(0); | ||
expect(options.tenantHost).not.toHaveLength(0); | ||
expect(options.authType).toBe('apikey'); | ||
expect(options.apikey).not.toHaveLength(0); | ||
|
||
// Check if the API key is a valid JWT | ||
try { | ||
const decoded = JSON.parse(Buffer.from(options.apikey.split('.')[1], 'base64').toString('utf8')); | ||
expect(decoded).toBeInstanceOf(Object); | ||
|
||
expect(decoded.aud).toBe('qlik.api'); | ||
expect(decoded.iss).toBe('qlik.api/api-keys'); | ||
|
||
// JTI should be a UUID | ||
expect(decoded.jti).not.toHaveLength(0); | ||
expect(decoded.jti).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); | ||
|
||
expect(decoded.sub).not.toHaveLength(0); | ||
expect(decoded.subType).toBe('user'); | ||
|
||
expect(decoded.tenantId).not.toHaveLength(0); | ||
} catch (error) { | ||
expect(error).toBeInstanceOf(Error); | ||
expect(error.message).toBe('Invalid API key'); | ||
} | ||
}); | ||
|
||
/** | ||
* Do connection test | ||
* Should succeed | ||
*/ | ||
test('do connection test', async () => { | ||
const result = await qscloudTestConnection(options); | ||
|
||
const decoded = JSON.parse(Buffer.from(options.apikey.split('.')[1], 'base64').toString('utf8')); | ||
|
||
// Result should be a JSON object | ||
expect(result).toBeInstanceOf(Object); | ||
expect(result.tenantId).toBe(decoded.tenantId); | ||
|
||
expect(result.id).not.toHaveLength(0); | ||
expect(result.id).toBe(decoded.sub); | ||
|
||
expect(result.name).not.toHaveLength(0); | ||
expect(result.email).not.toHaveLength(0); | ||
expect(result.status).not.toHaveLength(0); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
...ivity_custom_property_create_cert.test.js → ...ivity_custom_property_create_cert.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/app_cert.test.js → src/__tests__/cmd/qseow/app_cert.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/__tests__/app_import_cert.test.js → ...tests__/cmd/qseow/app_import_cert.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/__tests__/app_import_jwt.test.js → ..._tests__/cmd/qseow/app_import_jwt.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/__tests__/app_jwt.test.js → src/__tests__/cmd/qseow/app_jwt.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/app_scramble_cert.test.js → ...sts__/cmd/qseow/app_scramble_cert.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/bookmark_get_cert.test.js → ...sts__/cmd/qseow/bookmark_get_cert.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/bookmark_get_jwt.test.js → ...ests__/cmd/qseow/bookmark_get_jwt.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/connection_test_cert.test.js → ...__/cmd/qseow/connection_test_cert.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/connection_test_jwt.test.js → ...s__/cmd/qseow/connection_test_jwt.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/script_get_cert.test.js → ...tests__/cmd/qseow/script_get_cert.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/script_get_jwt.test.js → ..._tests__/cmd/qseow/script_get_jwt.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/task_cert.test.js → src/__tests__/cmd/qseow/task_cert.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...s__/task_custom_property_set_cert.test.js → ...eow/task_custom_property_set_cert.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ts__/task_custom_property_set_jwt.test.js → ...seow/task_custom_property_set_jwt.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/__tests__/task_import_cert.test.js → ...ests__/cmd/qseow/task_import_cert.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/__tests__/task_import_jwt.test.js → ...tests__/cmd/qseow/task_import_jwt.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/__tests__/task_jwt.test.js → src/__tests__/cmd/qseow/task_jwt.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello, world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Foo |
Oops, something went wrong.