|
1 | | -// /*! |
2 | | -// * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
3 | | -// * SPDX-License-Identifier: Apache-2.0 |
4 | | -// */ |
5 | | -// import * as sinon from 'sinon' |
6 | | -// import assert from 'assert' |
7 | | -// import { globals } from 'aws-core-vscode/shared' |
8 | | -// import { LspClient } from 'aws-core-vscode/amazonq' |
| 1 | +/*! |
| 2 | + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | +import * as sinon from 'sinon' |
| 6 | +import assert from 'assert' |
| 7 | +import { globals } from 'aws-core-vscode/shared' |
| 8 | +import { LspClient } from 'aws-core-vscode/amazonq' |
9 | 9 |
|
10 | | -// describe('Amazon Q LSP client', function () { |
11 | | -// let lspClient: LspClient |
12 | | -// let encryptFunc: sinon.SinonSpy |
| 10 | +describe('Amazon Q LSP client', function () { |
| 11 | + let lspClient: LspClient |
| 12 | + let encryptFunc: sinon.SinonSpy |
13 | 13 |
|
14 | | -// beforeEach(async function () { |
15 | | -// sinon.stub(globals, 'isWeb').returns(false) |
16 | | -// lspClient = new LspClient() |
17 | | -// encryptFunc = sinon.spy(lspClient, 'encrypt') |
18 | | -// }) |
| 14 | + beforeEach(async function () { |
| 15 | + sinon.stub(globals, 'isWeb').returns(false) |
| 16 | + lspClient = new LspClient() |
| 17 | + encryptFunc = sinon.spy(lspClient, 'encrypt') |
| 18 | + }) |
19 | 19 |
|
20 | | -// it('encrypts payload of query ', async () => { |
21 | | -// await lspClient.queryVectorIndex('mock_input') |
22 | | -// assert.ok(encryptFunc.calledOnce) |
23 | | -// assert.ok(encryptFunc.calledWith(JSON.stringify({ query: 'mock_input' }))) |
24 | | -// const value = await encryptFunc.returnValues[0] |
25 | | -// // verifies JWT encryption header |
26 | | -// assert.ok(value.startsWith(`eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0`)) |
27 | | -// }) |
| 20 | + it('encrypts payload of query ', async () => { |
| 21 | + await lspClient.queryVectorIndex('mock_input') |
| 22 | + assert.ok(encryptFunc.calledOnce) |
| 23 | + assert.ok(encryptFunc.calledWith(JSON.stringify({ query: 'mock_input' }))) |
| 24 | + const value = await encryptFunc.returnValues[0] |
| 25 | + // verifies JWT encryption header |
| 26 | + assert.ok(value.startsWith(`eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0`)) |
| 27 | + }) |
28 | 28 |
|
29 | | -// it('encrypts payload of index files ', async () => { |
30 | | -// await lspClient.buildIndex(['fileA'], 'path', 'all') |
31 | | -// assert.ok(encryptFunc.calledOnce) |
32 | | -// assert.ok( |
33 | | -// encryptFunc.calledWith( |
34 | | -// JSON.stringify({ |
35 | | -// filePaths: ['fileA'], |
36 | | -// rootPath: 'path', |
37 | | -// refresh: false, |
38 | | -// }) |
39 | | -// ) |
40 | | -// ) |
41 | | -// const value = await encryptFunc.returnValues[0] |
42 | | -// // verifies JWT encryption header |
43 | | -// assert.ok(value.startsWith(`eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0`)) |
44 | | -// }) |
| 29 | + it('encrypts payload of index files ', async () => { |
| 30 | + await lspClient.buildIndex(['fileA'], 'path', 'all') |
| 31 | + assert.ok(encryptFunc.calledOnce) |
| 32 | + assert.ok( |
| 33 | + encryptFunc.calledWith( |
| 34 | + JSON.stringify({ |
| 35 | + filePaths: ['fileA'], |
| 36 | + rootPath: 'path', |
| 37 | + refresh: false, |
| 38 | + }) |
| 39 | + ) |
| 40 | + ) |
| 41 | + const value = await encryptFunc.returnValues[0] |
| 42 | + // verifies JWT encryption header |
| 43 | + assert.ok(value.startsWith(`eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0`)) |
| 44 | + }) |
45 | 45 |
|
46 | | -// it('encrypt removes readable information', async () => { |
47 | | -// const sample = 'hello' |
48 | | -// const encryptedSample = await lspClient.encrypt(sample) |
49 | | -// assert.ok(!encryptedSample.includes('hello')) |
50 | | -// }) |
| 46 | + it('encrypt removes readable information', async () => { |
| 47 | + const sample = 'hello' |
| 48 | + const encryptedSample = await lspClient.encrypt(sample) |
| 49 | + assert.ok(!encryptedSample.includes('hello')) |
| 50 | + }) |
51 | 51 |
|
52 | | -// afterEach(() => { |
53 | | -// sinon.restore() |
54 | | -// }) |
55 | | -// }) |
| 52 | + afterEach(() => { |
| 53 | + sinon.restore() |
| 54 | + }) |
| 55 | +}) |
0 commit comments