Skip to content

Commit 4430899

Browse files
committed
Merge branch 'main' into electron-prompt
2 parents a257200 + 6ebee69 commit 4430899

24 files changed

+590
-594
lines changed

electron/app/test/childProcessExecutor-test.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,36 @@
44
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
* @ignore
66
*/
7-
"use strict";
8-
const fs = require('fs');
7+
'use strict';
8+
99
const path = require('path');
1010
const proxyquire = require('proxyquire');
11-
const { assert, expect } = require('chai');
11+
const { expect } = require('chai');
12+
const { describe, it } = require('mocha');
1213
const osUtils = require('../js/osUtils');
1314

1415
const wktLoggerMock = {
1516
getLogger: () => {
1617
return console;
1718
}
18-
}
19+
};
1920

2021
const { executeFileCommand, executeScriptCommand } = proxyquire('../js/childProcessExecutor', { './wktLogging': wktLoggerMock });
2122

22-
it('verify node version is returned', async () => {
23+
/* global __dirname, process */
24+
describe('Child Process Executor tests', () => {
25+
it('verify node version is returned', async () => {
2326
const args = [ '-v' ];
2427

2528
const output = await executeFileCommand('node', args);
2629
expect(output.trim()).is.equal(process.version);
27-
});
30+
});
2831

29-
it('verify spaces in file path work', async() => {
30-
const scriptPath = path.join(__dirname, 'dir with spaces', 'testScript') + (osUtils.isWindows() ? '.cmd' : '.sh');
31-
const argList = [ '-v', 'some args with lots of spaces' ];
32+
it('verify spaces in file path work', async() => {
33+
const scriptPath = path.join(__dirname, 'dir with spaces', 'testScript') + (osUtils.isWindows() ? '.cmd' : '.sh');
34+
const argList = [ '-v', 'some args with lots of spaces' ];
3235

33-
const output = await executeScriptCommand(scriptPath, argList);
34-
expect(output.trim()).is.equal('Hello World from dir with spaces with 2 arguments');
36+
const output = await executeScriptCommand(scriptPath, argList);
37+
expect(output.trim()).is.equal('Hello World from dir with spaces with 2 arguments');
38+
});
3539
});

electron/app/test/credentialEncryptor-test.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,33 @@
44
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
* @ignore
66
*/
7-
"use strict";
8-
const proxyquire = require('proxyquire');
9-
const { assert, expect } = require('chai');
7+
'use strict';
8+
9+
const { expect } = require('chai');
10+
const { describe, it } = require('mocha');
1011
const CredentialEncryptor = require('../js/credentialEncryptor');
1112

12-
const passphrase = 'isdfgwgfigr94re9fhc8oifh298ei';
13-
let encryptor = new CredentialEncryptor(passphrase);
14-
const textToHide = 'My Super Secret Text';
15-
const storedEncryptedText = 'eJwVy8lygjAAANAP6jgUZLEHDg0RWzKNbEblBmHfIRIIX+/03R/qiheGw0evTelSD+RHXJL42zQPy9AWt0gn9d6' +
16-
'NNnx4YMlzxb/5nKvmIbWRv/ZWI+mrhZJAOsqvU/u/NrqV4LK6qKeGnEVUsqeMlZVPCJb0qn1SZ2pUy3OrcODub8yFoz2P3tblyXyHhed06hSipc72' +
17-
'l+XgqPurTkY+rmRGArHz/DCIajBRGlqqoSuGioia+DPmQKaWq8CpzIJNyTGGoCBhwvoKbNl5L+/CYcK/LqDhI/uaqaLyOGDmGyy9VlY=';
18-
let encryptedText;
13+
describe('Credential Encryptor tests', () => {
14+
const passphrase = 'isdfgwgfigr94re9fhc8oifh298ei';
15+
let encryptor = new CredentialEncryptor(passphrase);
16+
const textToHide = 'My Super Secret Text';
17+
const storedEncryptedText = 'eJwVy8lygjAAANAP6jgUZLEHDg0RWzKNbEblBmHfIRIIX+/03R/qiheGw0evTelSD+RHXJL42zQPy9AWt0gn9d6' +
18+
'NNnx4YMlzxb/5nKvmIbWRv/ZWI+mrhZJAOsqvU/u/NrqV4LK6qKeGnEVUsqeMlZVPCJb0qn1SZ2pUy3OrcODub8yFoz2P3tblyXyHhed06hSipc72' +
19+
'l+XgqPurTkY+rmRGArHz/DCIajBRGlqqoSuGioia+DPmQKaWq8CpzIJNyTGGoCBhwvoKbNl5L+/CYcK/LqDhI/uaqaLyOGDmGyy9VlY=';
20+
let encryptedText;
1921

20-
it('encryption works', () => {
21-
encryptedText = encryptor.getEncryptedText(textToHide);
22-
expect(encryptedText).to.not.be.null;
23-
});
22+
it('encryption works', () => {
23+
encryptedText = encryptor.getEncryptedText(textToHide);
24+
expect(encryptedText).to.not.be.null;
25+
});
2426

25-
it('decryption works', () => {
26-
const clearText = encryptor.getDecryptedText(encryptedText);
27-
expect(clearText).to.equal(textToHide);
28-
});
27+
it('decryption works', () => {
28+
const clearText = encryptor.getDecryptedText(encryptedText);
29+
expect(clearText).to.equal(textToHide);
30+
});
2931

30-
it('decryption with new encryptor works', () => {
31-
const clearText = encryptor.getDecryptedText(storedEncryptedText);
32-
expect(clearText).to.equal(textToHide);
32+
it('decryption with new encryptor works', () => {
33+
const clearText = encryptor.getDecryptedText(storedEncryptedText);
34+
expect(clearText).to.equal(textToHide);
35+
});
3336
});

electron/app/test/credentialStore-test.js

Lines changed: 104 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -4,120 +4,125 @@
44
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
* @ignore
66
*/
7-
"use strict";
7+
'use strict';
8+
89
const proxyquire = require('proxyquire');
910
const { assert, expect } = require('chai');
11+
const { before, describe, it } = require('mocha');
1012
const osUtils = require('../js/osUtils');
1113

12-
const wktLoggerMock = {
13-
getLogger: () => {
14-
return console;
15-
}
16-
}
14+
/* global process */
15+
describe('Credential Store tests', () => {
16+
const wktLoggerMock = {
17+
getLogger: () => {
18+
return console;
19+
}
20+
};
1721

18-
const CredentialStore = proxyquire('../js/credentialStore', { './wktLogging': wktLoggerMock });
19-
let credStore;
22+
const CredentialStore = proxyquire('../js/credentialStore', { './wktLogging': wktLoggerMock });
23+
let credStore;
2024

21-
let skipTestsInJenkins = false;
22-
if (osUtils.isMac() && 'JENKINS_NODE_COOKIE' in process.env) {
23-
skipTestsInJenkins = true;
24-
}
25+
let skipTestsInJenkins = false;
26+
if (osUtils.isMac() && 'JENKINS_NODE_COOKIE' in process.env) {
27+
skipTestsInJenkins = true;
28+
}
2529

26-
before(async () => {
27-
credStore = new CredentialStore('wktui-test');
28-
await cleanStaleCredentials();
29-
});
30+
before(async () => {
31+
credStore = new CredentialStore('wktui-test');
32+
await cleanStaleCredentials();
33+
});
3034

31-
async function cleanStaleCredentials() {
32-
const staleCreds = credStore.findCredentials();
33-
if (staleCreds && Array.isArray(staleCreds)) {
34-
for (const staleCred of staleCreds) {
35-
await credStore.deleteCredential(staleCred.account);
35+
async function cleanStaleCredentials() {
36+
const staleCreds = credStore.findCredentials();
37+
if (staleCreds && Array.isArray(staleCreds)) {
38+
for (const staleCred of staleCreds) {
39+
await credStore.deleteCredential(staleCred.account);
40+
}
3641
}
3742
}
38-
}
3943

40-
if (!skipTestsInJenkins) {
41-
it('store new credential works', async () => {
42-
try {
43-
await credStore.storeCredential('test1', 'f00b@r!');
44-
} catch (err) {
45-
assert.fail(`Failed to store credential test1: ${err}`);
46-
}
47-
});
44+
if (!skipTestsInJenkins) {
45+
it('store new credential works', async () => {
46+
try {
47+
await credStore.storeCredential('test1', 'f00b@r!');
48+
} catch (err) {
49+
assert.fail(`Failed to store credential test1: ${err}`);
50+
}
51+
});
4852

49-
// On the Jenkins MacOS slaves, this test fails at least half the time with the error:
50-
// The specified item already exists in the keychain. This causes some of the subsequent
51-
// tests to fail.
52-
//
53-
// This has never once reproduced on a developer's MacOS machine so we will just not run
54-
// the tests in the Jenkins MacOS environment.
55-
//
56-
it('replace existing credential works', async () => {
57-
try {
58-
await credStore.storeCredential('test1', '8e7rty9wrfhofhd98@92382093ue09udjo8dfsyu');
59-
const newCredentialValue = await credStore.getCredential('test1');
60-
expect(newCredentialValue).to.equal('8e7rty9wrfhofhd98@92382093ue09udjo8dfsyu');
61-
} catch (err) {
62-
assert.fail(`Failed to replace existing credential test1: ${err}`);
63-
}
64-
});
53+
// On the Jenkins MacOS slaves, this test fails at least half the time with the error:
54+
// The specified item already exists in the keychain. This causes some of the subsequent
55+
// tests to fail.
56+
//
57+
// This has never once reproduced on a developer's MacOS machine so we will just not run
58+
// the tests in the Jenkins MacOS environment.
59+
//
60+
it('replace existing credential works', async () => {
61+
try {
62+
await credStore.storeCredential('test1', '8e7rty9wrfhofhd98@92382093ue09udjo8dfsyu');
63+
const newCredentialValue = await credStore.getCredential('test1');
64+
expect(newCredentialValue).to.equal('8e7rty9wrfhofhd98@92382093ue09udjo8dfsyu');
65+
} catch (err) {
66+
assert.fail(`Failed to replace existing credential test1: ${err}`);
67+
}
68+
});
6569

66-
it('get existing credential works', async () => {
67-
try {
68-
const credentialValue = await credStore.getCredential('test1');
69-
expect(credentialValue).to.equal('8e7rty9wrfhofhd98@92382093ue09udjo8dfsyu');
70-
} catch (err) {
71-
assert.fail(`Failed to get existing credential test1: ${err}`);
72-
}
73-
});
70+
it('get existing credential works', async () => {
71+
try {
72+
const credentialValue = await credStore.getCredential('test1');
73+
expect(credentialValue).to.equal('8e7rty9wrfhofhd98@92382093ue09udjo8dfsyu');
74+
} catch (err) {
75+
assert.fail(`Failed to get existing credential test1: ${err}`);
76+
}
77+
});
7478

75-
it('get non-existent credential works as expected', async () => {
76-
try {
77-
const credentialValue = await credStore.getCredential('test2');
78-
expect(credentialValue).to.be.null;
79-
} catch (err) {
80-
assert.fail(`Failed to get non-existent credential test2: ${err}`);
81-
}
82-
});
79+
it('get non-existent credential works as expected', async () => {
80+
try {
81+
const credentialValue = await credStore.getCredential('test2');
82+
expect(credentialValue).to.be.null;
83+
} catch (err) {
84+
assert.fail(`Failed to get non-existent credential test2: ${err}`);
85+
}
86+
});
8387

84-
it('find credentials to work', async () => {
85-
try {
86-
const credentials = await credStore.findCredentials();
87-
expect(credentials).to.not.be.null;
88-
expect(credentials).to.have.length(1);
89-
expect(credentials[0].name).to.equal('test1');
90-
expect(credentials[0].value).to.equal('8e7rty9wrfhofhd98@92382093ue09udjo8dfsyu');
91-
} catch (err) {
92-
assert.fail(`Failed to get credentials: ${err}`);
93-
}
94-
});
88+
it('find credentials to work', async () => {
89+
try {
90+
const credentials = await credStore.findCredentials();
91+
expect(credentials).to.not.be.null;
92+
expect(credentials).to.have.length(1);
93+
expect(credentials[0].name).to.equal('test1');
94+
expect(credentials[0].value).to.equal('8e7rty9wrfhofhd98@92382093ue09udjo8dfsyu');
95+
} catch (err) {
96+
assert.fail(`Failed to get credentials: ${err}`);
97+
}
98+
});
9599

96-
it('delete non-existent credential works as expected', async () => {
97-
try {
98-
const result = await credStore.deleteCredential('test2');
99-
expect(result).to.be.false;
100-
} catch (err) {
101-
assert.fail(`Failed to handle delete for non-existent credential: ${err}`);
102-
}
103-
});
100+
it('delete non-existent credential works as expected', async () => {
101+
try {
102+
const result = await credStore.deleteCredential('test2');
103+
expect(result).to.be.false;
104+
} catch (err) {
105+
assert.fail(`Failed to handle delete for non-existent credential: ${err}`);
106+
}
107+
});
104108

105-
it('delete existing credential works as expected', async () => {
106-
try {
107-
const result = await credStore.deleteCredential('test1');
108-
expect(result).to.be.true;
109-
} catch (err) {
110-
assert.fail(`Failed to handle delete for existing credential: ${err}`);
111-
}
112-
});
109+
it('delete existing credential works as expected', async () => {
110+
try {
111+
const result = await credStore.deleteCredential('test1');
112+
expect(result).to.be.true;
113+
} catch (err) {
114+
assert.fail(`Failed to handle delete for existing credential: ${err}`);
115+
}
116+
});
113117

114-
it('find credentials when there are none works as expected', async () => {
115-
try {
116-
const credentials = await credStore.findCredentials();
117-
expect(credentials).to.not.be.null;
118-
expect(credentials).to.have.length(0);
119-
} catch (err) {
120-
assert.fail(`Failed to get credentials when there were none: ${err}`);
121-
}
122-
});
123-
}
118+
it('find credentials when there are none works as expected', async () => {
119+
try {
120+
const credentials = await credStore.findCredentials();
121+
expect(credentials).to.not.be.null;
122+
expect(credentials).to.have.length(0);
123+
} catch (err) {
124+
assert.fail(`Failed to get credentials when there were none: ${err}`);
125+
}
126+
});
127+
}
128+
});

0 commit comments

Comments
 (0)