Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions installer/frontend/ui-tests/commands/setFileField.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const fs = require('fs');

exports.command = function (selector, text) {
this.expect.element(selector).to.be.present;

// eslint-disable-next-line no-sync
fs.writeFileSync(this.globals.tmpUploadPath, text);
return this.setValue(selector, this.globals.tmpUploadPath);
};
20 changes: 20 additions & 0 deletions installer/frontend/ui-tests/commands/testFileTextCombo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
exports.command = function (fileSelector, textSelector, validText, invalidText, invalidMsg) {
this
.setField(textSelector, 'abc')
.expectValidationErrorContains(invalidMsg)
.setFileField(fileSelector, validText)
.expectNoValidationError()
.expect.element(textSelector).to.have.value.that.equals(validText);

this
.setFileField(fileSelector, invalidText)
.expectValidationErrorContains(invalidMsg)
.expect.element(textSelector).to.have.value.that.equals(invalidText);

this
.setFileField(fileSelector, validText)
.expectNoValidationError()
.expect.element(textSelector).to.have.value.that.equals(validText);

return this;
};
3 changes: 3 additions & 0 deletions installer/frontend/ui-tests/globals.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const chromedriver = require('chromedriver');
const path = require('path');

module.exports = {
default: {
Expand All @@ -14,4 +15,6 @@ module.exports = {
chromedriver.stop();
done();
},

tmpUploadPath: path.join(path.resolve(__dirname), 'tmp-upload-test'),
};
18 changes: 4 additions & 14 deletions installer/frontend/ui-tests/pages/clusterInfoPage.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
const _ = require('lodash');
const fs = require('fs');
const path = require('path');

const clusterInfoPageCommands = {
test (json, platform) {
const parentDir = path.resolve(__dirname, '..');
const licensePath = path.join(parentDir, 'tectonic-license.txt');
const configPath = path.join(parentDir, 'config.json');

/* eslint-disable no-sync */
const tectonic_license = fs.readFileSync(process.env.TF_VAR_tectonic_license_path, 'utf8');
const pull_secret = fs.readFileSync(process.env.TF_VAR_tectonic_pull_secret_path, 'utf8');
fs.writeFileSync(licensePath, tectonic_license);
fs.writeFileSync(configPath, pull_secret);
/* eslint-enable no-sync */

this.setField('@name', 'a%$#b');
if (platform === 'aws-tf') {
this.expectValidationErrorContains('must be a valid AWS Stack Name');
Expand All @@ -26,8 +14,10 @@ const clusterInfoPageCommands = {
this.setField('@name', json.clusterName);
this.expectNoValidationError();

this.setValue('@licenseUpload', licensePath);
this.setValue('@pullSecretUpload', configPath);
/* eslint-disable no-sync */
this.setFileField('@licenseUpload', fs.readFileSync(process.env.TF_VAR_tectonic_license_path, 'utf8'));
this.setFileField('@pullSecretUpload', fs.readFileSync(process.env.TF_VAR_tectonic_pull_secret_path, 'utf8'));
/* eslint-enable no-sync */

if (platform === 'aws-tf' && !_.isEmpty(json.awsTags)) {
this
Expand Down
63 changes: 22 additions & 41 deletions installer/frontend/ui-tests/pages/matchboxCredentialsPage.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,30 @@
const fs = require('fs');
const path = require('path');

const pageCommands = {
test (json) {
const parentDir = path.resolve(__dirname, '..');
const caCertPath = path.join(parentDir, 'ca-cert.txt');
const clientCertPath = path.join(parentDir, 'client-cert.txt');
const clientKeyPath = path.join(parentDir, 'client-key.txt');

/* eslint-disable no-sync */
fs.writeFileSync(caCertPath, json.matchboxCA);
fs.writeFileSync(clientCertPath, json.matchboxClientCert);
fs.writeFileSync(clientKeyPath, json.matchboxClientKey);
/* eslint-enable no-sync */

this
.setValue('@caCert', clientKeyPath)
.expectValidationErrorContains('Invalid certificate')
.setValue('@caCert', caCertPath)
.expectNoValidationError()
.setValue('@clientCert', clientKeyPath)
.expectValidationErrorContains('Invalid certificate')
.setValue('@clientCert', clientCertPath)
.expectNoValidationError()
.setValue('@clientKey', caCertPath)
.expectValidationErrorContains('Invalid private key')
.setValue('@clientKey', clientKeyPath)
.expectNoValidationError();
this.testFileTextCombo(
'input[type=file]#matchboxCA',
'textarea#matchboxCA',
json.matchboxCA,
json.matchboxClientKey,
'Invalid certificate'
);
this.testFileTextCombo(
'input[type=file]#matchboxClientCert',
'textarea#matchboxClientCert',
json.matchboxClientCert,
json.matchboxClientKey,
'Invalid certificate'
);
this.testFileTextCombo(
'input[type=file]#matchboxClientKey',
'textarea#matchboxClientKey',
json.matchboxClientKey,
json.matchboxCA,
'Invalid private key'
);
},
};

module.exports = {
commands: [pageCommands],
elements: {
caCert: {
selector: '(//*[text()="Upload"]/input[@type="file"])[1]',
locateStrategy: 'xpath',
},
clientCert: {
selector: '(//*[text()="Upload"]/input[@type="file"])[2]',
locateStrategy: 'xpath',
},
clientKey: {
selector: '(//*[text()="Upload"]/input[@type="file"])[3]',
locateStrategy: 'xpath',
},
},
elements: {},
};
29 changes: 8 additions & 21 deletions installer/frontend/ui-tests/pages/sshKeysPage.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
const fs = require('fs');
const path = require('path');

const pageCommands = {
test (json) {
const parentDir = path.resolve(__dirname, '..');
const sshKeyPath = path.join(parentDir, 'ssh-keys.txt');

/* eslint-disable no-sync */
fs.writeFileSync(sshKeyPath, json.sshAuthorizedKey);

this
.setField('@key', 'abc')
.expectValidationErrorContains('Invalid SSH pubkey')
.setValue('@upload', sshKeyPath)
.expectNoValidationError();
this.testFileTextCombo(
'input[type=file]#sshAuthorizedKey',
'textarea#sshAuthorizedKey',
json.sshAuthorizedKey,
'abc',
'Invalid SSH pubkey'
);
},
};

module.exports = {
commands: [pageCommands],
elements: {
key: 'textarea#sshAuthorizedKey',
upload: {
selector: '(//*[text()="Upload"]/input[@type="file"])',
locateStrategy: 'xpath',
},
},
elements: {},
};
3 changes: 3 additions & 0 deletions installer/frontend/ui-tests/tests/aws.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const fs = require('fs');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this extra newline wanted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're generally putting a newline between package imports and imports from the same repo.

const log = require('../utils/log');
const wizard = require('../utils/wizard');
const tfvarsUtil = require('../utils/terraformTfvars');
Expand Down Expand Up @@ -42,6 +44,7 @@ const toExport = {
},

after (client) {
fs.unlink(client.globals.tmpUploadPath);
client.getLog('browser', log.logger);
client.end();
},
Expand Down
3 changes: 3 additions & 0 deletions installer/frontend/ui-tests/tests/metal.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const fs = require('fs');

const log = require('../utils/log');
const wizard = require('../utils/wizard');
const tfvarsUtil = require('../utils/terraformTfvars');
Expand Down Expand Up @@ -46,6 +48,7 @@ const toExport = {
},

after (client) {
fs.unlink(client.globals.tmpUploadPath);
client.getLog('browser', log.logger);
client.end();
},
Expand Down