UI - Active Directory secrets (#4647)

* add AD secrets in the ui and move deprecated engines to the bottom of the list

* fix tools tests

* prettier
This commit is contained in:
Matthew Irish 2018-05-29 09:14:31 -05:00 committed by GitHub
parent 365335f609
commit b383874a76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 171 additions and 125 deletions

View File

@ -31,6 +31,6 @@ export default Ember.Component.extend({
},
fullscreen() {
this.get('onFullscreen')();
}
},
},
});

View File

@ -26,8 +26,15 @@ export default Ember.Component.extend({
executeCommand(command, shouldThrow = false) {
let service = this.get('console');
let serviceArgs;
if(executeUICommand(command, (args) => this.logAndOutput(args), (args) => service.clearLog(args), () => this.toggleProperty('isFullscreen'))){
if (
executeUICommand(
command,
args => this.logAndOutput(args),
args => service.clearLog(args),
() => this.toggleProperty('isFullscreen')
)
) {
return;
}
@ -55,7 +62,8 @@ export default Ember.Component.extend({
return;
}
let serviceFn = service[method];
serviceFn.call(service, path, data, flags.wrapTTL)
serviceFn
.call(service, path, data, flags.wrapTTL)
.then(resp => {
this.logAndOutput(command, logFromResponse(resp, path, method, flags));
})
@ -65,7 +73,7 @@ export default Ember.Component.extend({
},
shiftCommandIndex(keyCode) {
this.get('console').shiftCommandIndex(keyCode, (val) => {
this.get('console').shiftCommandIndex(keyCode, val => {
this.set('inputValue', val);
});
},

View File

@ -16,7 +16,7 @@ export default Component.extend({
model.rollbackAttributes();
}
},
onSuccess(){},
onSuccess() {},
// override and return a promise
transaction() {
assert('override transaction call in an extension of popup-base', false);

View File

@ -60,7 +60,7 @@ export default Ember.Component.extend({
return;
}
this.get('flashMessages').success(message);
yield this.get('onSave')({saveType: 'save', model});
yield this.get('onSave')({ saveType: 'save', model });
}).drop(),
willDestroy() {
@ -74,12 +74,10 @@ export default Ember.Component.extend({
deleteItem(model) {
let message = this.getMessage(model, true);
let flash = this.get('flashMessages');
model
.destroyRecord()
.then(() => {
flash.success(message);
return this.get('onSave')({saveType: 'delete', model});
});
model.destroyRecord().then(() => {
flash.success(message);
return this.get('onSave')({ saveType: 'delete', model });
});
},
},
});

View File

@ -9,8 +9,9 @@ export default Ember.Component.extend({
enable(model) {
model.set('disabled', false);
model.save().
then(() => {
model
.save()
.then(() => {
this.get('flashMessages').success(`Successfully enabled entity: ${model.id}`);
})
.catch(e => {
@ -18,6 +19,6 @@ export default Ember.Component.extend({
`There was a problem enabling the entity: ${model.id} - ${e.error.join(' ') || e.message}`
);
});
}
}
},
},
});

View File

@ -7,10 +7,10 @@ export default Ember.Component.extend({
isActive: false,
tagName: 'span',
trackingSource: computed('pageName', function() {
let trackingSource = "vaultui";
let trackingSource = 'vaultui';
let pageName = this.get('pageName');
if (pageName) {
trackingSource = trackingSource + "_" + encodeURIComponent(pageName);
trackingSource = trackingSource + '_' + encodeURIComponent(pageName);
}
return trackingSource;
}),

View File

@ -5,6 +5,6 @@ export default Ember.Controller.extend(ListController, {
actions: {
onDelete() {
this.send('reload');
}
}
},
},
});

View File

@ -4,26 +4,20 @@ import { task } from 'ember-concurrency';
export default Ember.Controller.extend({
showRoute: 'vault.cluster.access.identity.show',
showTab: 'details',
navAfterSave: task(function*({saveType, model}) {
navAfterSave: task(function*({ saveType, model }) {
let isDelete = saveType === 'delete';
let type = model.get('identityType');
let listRoutes= {
let listRoutes = {
'entity-alias': 'vault.cluster.access.identity.aliases.index',
'group-alias': 'vault.cluster.access.identity.aliases.index',
'group': 'vault.cluster.access.identity.index',
'entity': 'vault.cluster.access.identity.index',
group: 'vault.cluster.access.identity.index',
entity: 'vault.cluster.access.identity.index',
};
let routeName = listRoutes[type]
let routeName = listRoutes[type];
if (!isDelete) {
yield this.transitionToRoute(
this.get('showRoute'),
model.id,
this.get('showTab')
);
yield this.transitionToRoute(this.get('showRoute'), model.id, this.get('showTab'));
return;
}
yield this.transitionToRoute(
routeName
);
yield this.transitionToRoute(routeName);
}),
});

View File

@ -29,8 +29,9 @@ export default Ember.Controller.extend(ListController, {
let id = model.id;
model.toggleProperty('disabled');
model.save().
then(() => {
model
.save()
.then(() => {
this.get('flashMessages').success(`Successfully ${action[0]} ${type}: ${id}`);
})
.catch(e => {

View File

@ -7,22 +7,23 @@ const { computed } = Ember;
export default Ember.Controller.extend({
mountTypes: [
{ label: 'Active Directory', value: 'ad' },
{ label: 'AWS', value: 'aws' },
{ label: 'Cassandra', value: 'cassandra', deprecated: true },
{ label: 'Consul', value: 'consul' },
{ label: 'Databases', value: 'database' },
{ label: 'Google Cloud', value: 'gcp' },
{ label: 'KV', value: 'kv' },
{ label: 'MongoDB', value: 'mongodb', deprecated: true },
{ label: 'MSSQL', value: 'mssql', deprecated: true },
{ label: 'MySQL', value: 'mysql', deprecated: true },
{ label: 'Nomad', value: 'nomad' },
{ label: 'PKI', value: 'pki' },
{ label: 'PostgreSQL', value: 'postgresql', deprecated: true },
{ label: 'RabbitMQ', value: 'rabbitmq' },
{ label: 'SSH', value: 'ssh' },
{ label: 'Transit', value: 'transit' },
{ label: 'TOTP', value: 'totp' },
{ label: 'Cassandra', value: 'cassandra', deprecated: true },
{ label: 'MongoDB', value: 'mongodb', deprecated: true },
{ label: 'MSSQL', value: 'mssql', deprecated: true },
{ label: 'MySQL', value: 'mysql', deprecated: true },
{ label: 'PostgreSQL', value: 'postgresql', deprecated: true },
],
selectedType: null,

View File

@ -29,12 +29,12 @@ export function extractDataAndFlags(data, flags) {
}, { data: {}, flags: {} });
}
export function executeUICommand(command, logAndOutput, clearLog, toggleFullscreen){
export function executeUICommand(command, logAndOutput, clearLog, toggleFullscreen) {
const isUICommand = uiCommands.includes(command);
if(isUICommand){
if (isUICommand) {
logAndOutput(command);
}
switch(command){
switch (command) {
case 'clearall':
clearLog(true);
break;
@ -149,7 +149,9 @@ export function shiftCommandIndex(keyCode, history, index) {
let newInputValue;
let commandHistoryLength = history.length;
if (!commandHistoryLength) { return []; }
if (!commandHistoryLength) {
return [];
}
if (keyCode === keys.UP) {
index -= 1;

View File

@ -35,5 +35,4 @@ export default IdentityModel.extend({
updatePath: identityCapabilities(),
canDelete: computed.alias('updatePath.canDelete'),
canEdit: computed.alias('updatePath.canUpdate'),
});

View File

@ -32,7 +32,7 @@ export default Ember.Route.extend(ModelBoundaryRoute, ClusterRoute, {
model(params) {
const id = this.getClusterId(params);
return this.get('store').findRecord('cluster', id);
return this.get('store').findRecord('cluster', id);
},
stopPoll: Ember.on('deactivate', function() {

View File

@ -35,6 +35,6 @@ export default Ember.Route.extend(ListRoute, {
reload() {
this.store.clearAllDatasets();
this.refresh();
}
},
},
});

View File

@ -37,6 +37,6 @@ export default Ember.Route.extend(ListRoute, {
reload() {
this.store.clearAllDatasets();
this.refresh();
}
},
},
});

View File

@ -162,6 +162,6 @@ export default Ember.Route.extend({
reload() {
this.refresh();
this.store.clearAllDatasets();
}
},
},
});

View File

@ -1,9 +1,7 @@
// Low level service that allows users to input paths to make requests to vault
// this service provides the UI synecdote to the cli commands read, write, delete, and list
import Ember from 'ember';
import {
shiftCommandIndex,
} from 'vault/lib/console-helpers';
import { shiftCommandIndex } from 'vault/lib/console-helpers';
const { Service, getOwner, computed } = Ember;
@ -48,7 +46,7 @@ export default Service.extend({
}
},
clearLog(clearAll=false) {
clearLog(clearAll = false) {
let log = this.get('log');
let history;
if (!clearAll) {

View File

@ -27,21 +27,31 @@ export const testAliasCRUD = (name, itemType, assert) => {
'navigates to the correct route'
);
assert.ok(
aliasShowPage.flashMessage.latestMessage.startsWith('Successfully saved', `${itemType}: shows a flash message`)
aliasShowPage.flashMessage.latestMessage.startsWith(
'Successfully saved',
`${itemType}: shows a flash message`
)
);
assert.ok(aliasShowPage.nameContains(name), `${itemType}: renders the name on the show page`);
});
aliasIndexPage.visit({ item_type: itemType });
andThen(() => {
assert.equal(aliasIndexPage.items.filterBy('id', aliasID).length, 1, `${itemType}: lists the entity in the entity list`);
assert.equal(
aliasIndexPage.items.filterBy('id', aliasID).length,
1,
`${itemType}: lists the entity in the entity list`
);
aliasIndexPage.items.filterBy('id', aliasID)[0].menu();
});
aliasIndexPage.delete().confirmDelete();
andThen(() => {
assert.equal(aliasIndexPage.items.filterBy('id', aliasID).length, 0, `${itemType}: the row is deleted`);
aliasIndexPage.flashMessage.latestMessage.startsWith('Successfully deleted', `${itemType}: shows flash message`);
aliasIndexPage.flashMessage.latestMessage.startsWith(
'Successfully deleted',
`${itemType}: shows flash message`
);
});
};
@ -66,12 +76,27 @@ export const testAliasDeleteFromForm = (name, itemType, assert) => {
aliasShowPage.edit();
andThen(() => {
assert.equal(currentRouteName(), 'vault.cluster.access.identity.aliases.edit', `${itemType}: navigates to edit on create`);
assert.equal(
currentRouteName(),
'vault.cluster.access.identity.aliases.edit',
`${itemType}: navigates to edit on create`
);
});
page.editForm.delete().confirmDelete();
andThen(() => {
assert.equal(currentRouteName(), 'vault.cluster.access.identity.aliases.index', `${itemType}: navigates to list page on delete`);
assert.equal(aliasIndexPage.items.filterBy('id', aliasID).length, 0, `${itemType}: the row does not show in the list`);
aliasIndexPage.flashMessage.latestMessage.startsWith('Successfully deleted', `${itemType}: shows flash message`);
assert.equal(
currentRouteName(),
'vault.cluster.access.identity.aliases.index',
`${itemType}: navigates to list page on delete`
);
assert.equal(
aliasIndexPage.items.filterBy('id', aliasID).length,
0,
`${itemType}: the row does not show in the list`
);
aliasIndexPage.flashMessage.latestMessage.startsWith(
'Successfully deleted',
`${itemType}: shows flash message`
);
});
};

View File

@ -9,43 +9,70 @@ export const testCRUD = (name, itemType, assert) => {
andThen(() => {
let idRow = showPage.rows.filterBy('hasLabel').filterBy('rowLabel', 'ID')[0];
id = idRow.rowValue;
assert.equal(currentRouteName(), 'vault.cluster.access.identity.show', `${itemType}: navigates to show on create`);
assert.equal(
currentRouteName(),
'vault.cluster.access.identity.show',
`${itemType}: navigates to show on create`
);
assert.ok(
showPage.flashMessage.latestMessage.startsWith('Successfully saved', `${itemType}: shows a flash message`)
showPage.flashMessage.latestMessage.startsWith(
'Successfully saved',
`${itemType}: shows a flash message`
)
);
assert.ok(showPage.nameContains(name), `${itemType}: renders the name on the show page`);
});
indexPage.visit({ item_type: itemType });
andThen(() => {
assert.equal(indexPage.items.filterBy('id', id).length, 1, `${itemType}: lists the entity in the entity list`);
assert.equal(
indexPage.items.filterBy('id', id).length,
1,
`${itemType}: lists the entity in the entity list`
);
indexPage.items.filterBy('id', id)[0].menu();
});
indexPage.delete().confirmDelete();
andThen(() => {
assert.equal(indexPage.items.filterBy('id', id).length, 0, `${itemType}: the row is deleted`);
indexPage.flashMessage.latestMessage.startsWith('Successfully deleted', `${itemType}: shows flash message`);
indexPage.flashMessage.latestMessage.startsWith(
'Successfully deleted',
`${itemType}: shows flash message`
);
});
};
export const testDeleteFromForm = (name, itemType, assert) => {
let id;
page.visit({ item_type: itemType });
page.editForm.name(name).submit();
andThen(() => {
id = showPage.rows.filterBy('hasLabel').filterBy('rowLabel', 'ID')[0].rowValue
id = showPage.rows.filterBy('hasLabel').filterBy('rowLabel', 'ID')[0].rowValue;
});
showPage.edit();
andThen(() => {
assert.equal(currentRouteName(), 'vault.cluster.access.identity.edit', `${itemType}: navigates to edit on create`);
assert.equal(
currentRouteName(),
'vault.cluster.access.identity.edit',
`${itemType}: navigates to edit on create`
);
});
page.editForm.delete().confirmDelete();
andThen(() => {
assert.equal(currentRouteName(), 'vault.cluster.access.identity.index', `${itemType}: navigates to list page on delete`);
assert.equal(indexPage.items.filterBy('id', id).length, 0, `${itemType}: the row does not show in the list`);
indexPage.flashMessage.latestMessage.startsWith('Successfully deleted', `${itemType}: shows flash message`);
assert.equal(
currentRouteName(),
'vault.cluster.access.identity.index',
`${itemType}: navigates to list page on delete`
);
assert.equal(
indexPage.items.filterBy('id', id).length,
0,
`${itemType}: the row does not show in the list`
);
indexPage.flashMessage.latestMessage.startsWith(
'Successfully deleted',
`${itemType}: shows flash message`
);
});
};

View File

@ -8,7 +8,6 @@ moduleForAcceptance('Acceptance | /access/identity/entities/aliases/add', {
},
});
test('it allows create, list, delete of an entity alias', function(assert) {
let name = `alias-${Date.now()}`;
testAliasCRUD(name, 'entities', assert);
@ -18,4 +17,3 @@ test('it allows delete from the edit form', function(assert) {
let name = `alias-${Date.now()}`;
testAliasDeleteFromForm(name, 'entities', assert);
});

View File

@ -29,4 +29,3 @@ test('it can be deleted from the edit form', function(assert) {
let name = `entity-${Date.now()}`;
testDeleteFromForm(name, 'entities', assert);
});

View File

@ -8,7 +8,6 @@ moduleForAcceptance('Acceptance | /access/identity/groups/aliases/add', {
},
});
test('it allows create, list, delete of an entity alias', function(assert) {
let name = `alias-${Date.now()}`;
testAliasCRUD(name, 'groups', assert);
@ -18,4 +17,3 @@ test('it allows delete from the edit form', function(assert) {
let name = `alias-${Date.now()}`;
testAliasDeleteFromForm(name, 'groups', assert);
});

View File

@ -30,7 +30,7 @@ test('it sets the ttl corrects when mounting', function(assert) {
.maxTTLUnit('h')
.submit();
configPage.visit({backend: path});
configPage.visit({ backend: path });
andThen(() => {
assert.equal(configPage.defaultTTL, defaultTTLSeconds, 'shows the proper TTL');
assert.equal(configPage.maxTTL, maxTTLSeconds, 'shows the proper max TTL');

View File

@ -59,14 +59,10 @@ test('tools functionality', function(assert) {
});
click('[data-test-tools-submit]');
andThen(() => {
assert.ok(
find('[data-test-tools="token-lookup-row"]:eq(0)').text().match(/Creation time/i),
'show creation time row'
);
assert.ok(
find('[data-test-tools="token-lookup-row"]:eq(1)').text().match(/Creation ttl/i),
'show creation ttl row'
);
let rows = document.querySelectorAll('[data-test-tools="token-lookup-row"]');
assert.dom(rows[0]).hasText(/Creation path/, 'show creation path row');
assert.dom(rows[1]).hasText(/Creation time/, 'show creation time row');
assert.dom(rows[2]).hasText(/Creation TTL/, 'show creation ttl row');
});
//rewrap

View File

@ -16,7 +16,7 @@ moduleForComponent('identity/item-details', 'Integration | Component | identity/
},
afterEach() {
component.removeContext();
}
},
});
test('it renders the disabled warning', function(assert) {
@ -25,7 +25,7 @@ test('it renders the disabled warning', function(assert) {
return Ember.RSVP.resolve();
},
disabled: true,
canEdit: true
canEdit: true,
});
sinon.spy(model, 'save');
this.set('model', model);
@ -38,7 +38,7 @@ test('it renders the disabled warning', function(assert) {
test('it does not render the button if canEdit is false', function(assert) {
let model = Ember.Object.create({
disabled: true
disabled: true,
});
this.set('model', model);

View File

@ -279,7 +279,7 @@ test('it includes algorithm param for HMAC', function(assert) {
backend: 'transit',
id: 'akey',
payload: {
algorithm: "sha2-384"
algorithm: 'sha2-384',
},
},
'passes expected args to the adapter'

View File

@ -7,5 +7,5 @@ export default create({
flashMessage,
nameContains: contains('[data-test-alias-name]'),
rows: collection('[data-test-component="info-table-row"]', infoTableRow),
edit: clickable('[data-test-alias-edit-link]')
edit: clickable('[data-test-alias-edit-link]'),
});

View File

@ -6,8 +6,8 @@ export default create({
editForm,
createItem(item_type, type) {
if (type) {
return this.visit({item_type}).editForm.type(type).submit();
return this.visit({ item_type }).editForm.type(type).submit();
}
return this.visit({item_type}).editForm.submit();
}
return this.visit({ item_type }).editForm.submit();
},
});

View File

@ -7,5 +7,5 @@ export default create({
flashMessage,
nameContains: contains('[data-test-identity-item-name]'),
rows: collection('[data-test-component="info-table-row"]', infoTableRow),
edit: clickable('[data-test-entity-edit-link]')
edit: clickable('[data-test-entity-edit-link]'),
});

View File

@ -64,10 +64,6 @@ testCases.forEach(function(testCase) {
component.set('mode', testCase.mode);
component.set('model', model);
assert.equal(
component.get('cancelLink'),
testCase.expected,
'cancel link is correct'
);
assert.equal(component.get('cancelLink'), testCase.expected, 'cancel link is correct');
});
});

View File

@ -129,14 +129,16 @@ test('store.fetchPage', function(assert) {
);
Ember.run(() => {
store.fetchPage('transit-key', {
size: pageSize,
page: 3,
responsePath: 'data.keys',
}).then(r => {
result = r;
done()
});
store
.fetchPage('transit-key', {
size: pageSize,
page: 3,
responsePath: 'data.keys',
})
.then(r => {
result = r;
done();
});
});
const pageThreeEnd = 3 * pageSize;
@ -148,15 +150,16 @@ test('store.fetchPage', function(assert) {
);
Ember.run(() => {
store.fetchPage('transit-key', {
size: pageSize,
page: 99,
responsePath: 'data.keys',
}).then(r => {
result = r;
done();
});
store
.fetchPage('transit-key', {
size: pageSize,
page: 99,
responsePath: 'data.keys',
})
.then(r => {
result = r;
done();
});
});
assert.deepEqual(
@ -166,14 +169,16 @@ test('store.fetchPage', function(assert) {
);
Ember.run(() => {
store.fetchPage('transit-key', {
size: pageSize,
page: 0,
responsePath: 'data.keys',
}).then(r => {
result = r;
done();
});
store
.fetchPage('transit-key', {
size: pageSize,
page: 0,
responsePath: 'data.keys',
})
.then(r => {
result = r;
done();
});
});
assert.deepEqual(
result.mapBy('id'),