mirror of
https://github.com/ansible/awx.git
synced 2026-05-06 08:57:35 -02:30
add worker file push command
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"angular-mocks": "~1.6.6",
|
"angular-mocks": "~1.6.6",
|
||||||
|
"archiver": "^2.1.1",
|
||||||
"axios": "^0.16.2",
|
"axios": "^0.16.2",
|
||||||
"babel-core": "^6.26.0",
|
"babel-core": "^6.26.0",
|
||||||
"babel-istanbul": "^0.12.2",
|
"babel-istanbul": "^0.12.2",
|
||||||
|
|||||||
57
awx/ui/test/e2e/commands/pushFileToWorker.js
Normal file
57
awx/ui/test/e2e/commands/pushFileToWorker.js
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import { basename } from 'path';
|
||||||
|
import { EventEmitter } from 'events';
|
||||||
|
import { inherits } from 'util';
|
||||||
|
|
||||||
|
import archiver from 'archiver';
|
||||||
|
|
||||||
|
function pushFileToWorker (localFilePath, callback) {
|
||||||
|
const name = basename(localFilePath);
|
||||||
|
|
||||||
|
const push = handler => {
|
||||||
|
const archive = archiver('zip');
|
||||||
|
|
||||||
|
const buffers = [];
|
||||||
|
|
||||||
|
archive
|
||||||
|
.on('data', data => buffers.push(data))
|
||||||
|
.on('error', err => { throw err; })
|
||||||
|
.on('finish', () => {
|
||||||
|
const file = Buffer.concat(buffers).toString('base64');
|
||||||
|
|
||||||
|
this.api.session(session => {
|
||||||
|
const params = {
|
||||||
|
path: `/session/${session.sessionId}/file`,
|
||||||
|
method: 'POST',
|
||||||
|
data: { file },
|
||||||
|
};
|
||||||
|
|
||||||
|
this.client.runProtocolAction(params, handler).send();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
archive.file(localFilePath, { name });
|
||||||
|
archive.finalize();
|
||||||
|
};
|
||||||
|
|
||||||
|
push(({ status, value }) => {
|
||||||
|
if (status !== 0) {
|
||||||
|
throw new Error(value.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback.call(this, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.emit('complete');
|
||||||
|
});
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
function PushFileToWorker () { EventEmitter.call(this); }
|
||||||
|
|
||||||
|
inherits(PushFileToWorker, EventEmitter);
|
||||||
|
|
||||||
|
PushFileToWorker.prototype.command = pushFileToWorker;
|
||||||
|
|
||||||
|
module.exports = PushFileToWorker;
|
||||||
@@ -64,7 +64,9 @@ module.exports = {
|
|||||||
const { details } = credentials.section.add.section;
|
const { details } = credentials.section.add.section;
|
||||||
const { gce } = details.section;
|
const { gce } = details.section;
|
||||||
|
|
||||||
gce.section.serviceAccountFile.setValue('form input[type="file"]', GCE_SERVICE_ACCOUNT_FILE);
|
client.pushFileToWorker(GCE_SERVICE_ACCOUNT_FILE, file => {
|
||||||
|
gce.section.serviceAccountFile.setValue('form input[type="file"]', file);
|
||||||
|
});
|
||||||
|
|
||||||
gce.expect.element('@email').not.enabled;
|
gce.expect.element('@email').not.enabled;
|
||||||
gce.expect.element('@sshKeyData').not.enabled;
|
gce.expect.element('@sshKeyData').not.enabled;
|
||||||
@@ -100,7 +102,9 @@ module.exports = {
|
|||||||
const { details } = credentials.section.add.section;
|
const { details } = credentials.section.add.section;
|
||||||
const { gce } = details.section;
|
const { gce } = details.section;
|
||||||
|
|
||||||
gce.section.serviceAccountFile.setValue('form input[type="file"]', GCE_SERVICE_ACCOUNT_FILE_MISSING);
|
client.pushFileToWorker(GCE_SERVICE_ACCOUNT_FILE_MISSING, file => {
|
||||||
|
gce.section.serviceAccountFile.setValue('form input[type="file"]', file);
|
||||||
|
});
|
||||||
|
|
||||||
gce.expect.element('@email').not.enabled;
|
gce.expect.element('@email').not.enabled;
|
||||||
gce.expect.element('@sshKeyData').not.enabled;
|
gce.expect.element('@sshKeyData').not.enabled;
|
||||||
@@ -142,7 +146,9 @@ module.exports = {
|
|||||||
const { details } = credentials.section.add.section;
|
const { details } = credentials.section.add.section;
|
||||||
const { gce } = details.section;
|
const { gce } = details.section;
|
||||||
|
|
||||||
gce.section.serviceAccountFile.setValue('form input[type="file"]', GCE_SERVICE_ACCOUNT_FILE_INVALID);
|
client.pushFileToWorker(GCE_SERVICE_ACCOUNT_FILE_INVALID, file => {
|
||||||
|
gce.section.serviceAccountFile.setValue('form input[type="file"]', file);
|
||||||
|
});
|
||||||
|
|
||||||
gce.expect.element('@email').not.enabled;
|
gce.expect.element('@email').not.enabled;
|
||||||
gce.expect.element('@sshKeyData').not.enabled;
|
gce.expect.element('@sshKeyData').not.enabled;
|
||||||
@@ -184,7 +190,9 @@ module.exports = {
|
|||||||
const add = credentials.section.add.section.details;
|
const add = credentials.section.add.section.details;
|
||||||
const edit = credentials.section.edit.section.details;
|
const edit = credentials.section.edit.section.details;
|
||||||
|
|
||||||
add.section.gce.section.serviceAccountFile.setValue('form input[type="file"]', GCE_SERVICE_ACCOUNT_FILE);
|
client.pushFileToWorker(GCE_SERVICE_ACCOUNT_FILE, file => {
|
||||||
|
add.section.gce.section.serviceAccountFile.setValue('form input[type="file"]', file);
|
||||||
|
});
|
||||||
|
|
||||||
add.section.gce.expect.element('@email').not.enabled;
|
add.section.gce.expect.element('@email').not.enabled;
|
||||||
add.section.gce.expect.element('@sshKeyData').not.enabled;
|
add.section.gce.expect.element('@sshKeyData').not.enabled;
|
||||||
@@ -224,7 +232,9 @@ module.exports = {
|
|||||||
gce.section.project.expect.element('@error').not.present;
|
gce.section.project.expect.element('@error').not.present;
|
||||||
gce.section.serviceAccountFile.expect.element('@error').not.present;
|
gce.section.serviceAccountFile.expect.element('@error').not.present;
|
||||||
|
|
||||||
gce.section.serviceAccountFile.setValue('form input[type="file"]', GCE_SERVICE_ACCOUNT_FILE_ALT);
|
client.pushFileToWorker(GCE_SERVICE_ACCOUNT_FILE_ALT, file => {
|
||||||
|
gce.section.serviceAccountFile.setValue('form input[type="file"]', file);
|
||||||
|
});
|
||||||
|
|
||||||
gce.expect.element('@serviceAccountFile').enabled;
|
gce.expect.element('@serviceAccountFile').enabled;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user