Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
meirish committed May 24, 2018
1 parent feba7a9 commit d195251
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 91 deletions.
2 changes: 0 additions & 2 deletions ui/app/components/secret-list-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ export default Ember.Component.extend({
baseKey: null,
backendCrumb: null,
model: null,


});
2 changes: 1 addition & 1 deletion ui/app/components/tool-actions-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default Ember.Component.extend(DEFAULTS, {

handleSuccess(resp, action) {
let props = {};
let secret = resp && resp.data || resp.auth;
let secret = (resp && resp.data) || resp.auth;
if (secret && action === 'unwrap') {
props = Ember.assign({}, props, { unwrap_data: secret });
}
Expand Down
6 changes: 1 addition & 5 deletions ui/app/macros/identity-capabilities.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities';

export default function() {
return lazyCapabilities(
apiPath`identity/${'identityType'}/id/${'id'}`,
'id',
'identityType'
);
return lazyCapabilities(apiPath`identity/${'identityType'}/id/${'id'}`, 'id', 'identityType');
}
10 changes: 5 additions & 5 deletions ui/app/macros/lazy-capabilities.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { queryRecord } from 'ember-computed-query';

export function apiPath(strings, ...keys) {
return (function(data) {
return function(data) {
let dict = data || {};
let result = [strings[0]];
keys.forEach((key, i) => {
result.push(dict[key], strings[i + 1]);
});
return result.join('');
});
};
};
}

export default function() {
let [templateFn, ...keys] = arguments;
return queryRecord(
'capabilities',
context => {
return {
id: templateFn(context.getProperties(...keys))
}
id: templateFn(context.getProperties(...keys)),
};
},
...keys
);
Expand Down
1 change: 0 additions & 1 deletion ui/app/models/identity/entity-alias.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import IdentityModel from './_base';
import DS from 'ember-data';
import Ember from 'ember';
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities';
import identityCapabilities from 'vault/macros/identity-capabilities';
const { attr, belongsTo } = DS;
const { computed } = Ember;
Expand Down
10 changes: 8 additions & 2 deletions ui/app/services/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,16 @@ export default DS.Store.extend({
this.peekAll(modelName).forEach(record => {
record.unloadRecord();
});
return new Ember.RSVP.Promise((resolve) => {
return new Ember.RSVP.Promise(resolve => {
Ember.run.schedule('destroy', () => {
this.push(
this.serializerFor(modelName).normalizeResponse(this, this.modelFor(modelName), response, null, 'query')
this.serializerFor(modelName).normalizeResponse(
this,
this.modelFor(modelName),
response,
null,
'query'
)
);
let model = this.peekAll(modelName).toArray();
model.set('meta', response.meta);
Expand Down
21 changes: 12 additions & 9 deletions ui/tests/acceptance/enterprise-replication-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ test('replication', function(assert) {
find('[data-test-mount-config-mode]').text().trim().toLowerCase().includes(mode),
'show page renders the correct mode'
);
assert.dom('[data-test-mount-config-paths]').hasText(mountPath, 'show page renders the correct mount path');
assert
.dom('[data-test-mount-config-paths]')
.hasText(mountPath, 'show page renders the correct mount path');
});
// click edit

Expand All @@ -101,10 +103,12 @@ test('replication', function(assert) {
`/vault/replication/performance/secondaries`,
'redirects to the secondaries page'
);
assert.dom('[data-test-flash-message-body]:contains(The performance mount filter)').hasText(
`The performance mount filter config for the secondary ${secondaryName} was successfully deleted.`,
'renders success flash upon deletion'
);
assert
.dom('[data-test-flash-message-body]:contains(The performance mount filter)')
.hasText(
`The performance mount filter config for the secondary ${secondaryName} was successfully deleted.`,
'renders success flash upon deletion'
);
click('[data-test-flash-message-body]:contains(The performance mount filter)');
});

Expand Down Expand Up @@ -149,10 +153,9 @@ test('replication', function(assert) {
});
click('[data-test-replication-link="secondaries"]');
andThen(() => {
assert.dom('[data-test-secondary-name]').hasText(
secondaryName,
'it displays the secondary in the list of known secondaries'
);
assert
.dom('[data-test-secondary-name]')
.hasText(secondaryName, 'it displays the secondary in the list of known secondaries');
});

// disable dr replication
Expand Down
23 changes: 15 additions & 8 deletions ui/tests/acceptance/leases-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ test('it renders the show page', function(assert) {
'vault.cluster.access.leases.show',
'a lease for the secret is in the list'
);
assert.dom('[data-test-lease-renew-picker]').doesNotExist('non-renewable lease does not render a renew picker');
assert
.dom('[data-test-lease-renew-picker]')
.doesNotExist('non-renewable lease does not render a renew picker');
});
});

Expand All @@ -65,7 +67,9 @@ skip('it renders the show page with a picker', function(assert) {
'vault.cluster.access.leases.show',
'a lease for the secret is in the list'
);
assert.dom('[data-test-lease-renew-picker]').exists({ count: 1 }, 'renewable lease renders a renew picker');
assert
.dom('[data-test-lease-renew-picker]')
.exists({ count: 1 }, 'renewable lease renders a renew picker');
});
});

Expand All @@ -84,7 +88,9 @@ test('it removes leases upon revocation', function(assert) {
click(`[data-test-lease-link="${this.enginePath}/"]`);
click('[data-test-lease-link="data/"]');
andThen(() => {
assert.dom(`[data-test-lease-link="${this.enginePath}/data/${this.name}/"]`).doesNotExist('link to the lease was removed with revocation');
assert
.dom(`[data-test-lease-link="${this.enginePath}/data/${this.name}/"]`)
.doesNotExist('link to the lease was removed with revocation');
});
});

Expand All @@ -99,16 +105,17 @@ test('it removes branches when a prefix is revoked', function(assert) {
'vault.cluster.access.leases.list-root',
'it navigates back to the leases root on revocation'
);
assert.dom(`[data-test-lease-link="${this.enginePath}/"]`).doesNotExist('link to the prefix was removed with revocation');
assert
.dom(`[data-test-lease-link="${this.enginePath}/"]`)
.doesNotExist('link to the prefix was removed with revocation');
});
});

test('lease not found', function(assert) {
visit('/vault/access/leases/show/not-found');
andThen(() => {
assert.dom('[data-test-lease-error]').hasText(
'not-found is not a valid lease ID',
'it shows an error when the lease is not found'
);
assert
.dom('[data-test-lease-error]')
.hasText('not-found is not a valid lease ID', 'it shows an error when the lease is not found');
});
});
8 changes: 6 additions & 2 deletions ui/tests/acceptance/policies-acl-old-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ test('policies', function(assert) {
});
click('[data-test-policy-list-link]');
andThen(function() {
assert.dom(`[data-test-policy-link="${policyLower}"]`).exists({ count: 1 }, 'new policy shown in the list');
assert
.dom(`[data-test-policy-link="${policyLower}"]`)
.exists({ count: 1 }, 'new policy shown in the list');
});

// policy deletion
Expand All @@ -56,7 +58,9 @@ test('policies', function(assert) {
click('[data-test-confirm-button]');
andThen(function() {
assert.equal(currentURL(), `/vault/policies/acl`, 'navigates to policy list on successful deletion');
assert.dom(`[data-test-policy-item="${policyLower}"]`).doesNotExist('deleted policy is not shown in the list');
assert
.dom(`[data-test-policy-item="${policyLower}"]`)
.doesNotExist('deleted policy is not shown in the list');
});
});

Expand Down
6 changes: 1 addition & 5 deletions ui/tests/acceptance/settings-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ test('settings', function(assert) {
});

andThen(() => {
assert.ok(
currentURL(),
'/vault/secrets/${path}/configuration',
'navigates to the config page'
);
assert.ok(currentURL(), '/vault/secrets/${path}/configuration', 'navigates to the config page');
});
});
4 changes: 3 additions & 1 deletion ui/tests/acceptance/ssh-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ test('ssh backend', function(assert) {
click(`[data-test-confirm-button]`);

andThen(() => {
assert.dom(`[data-test-secret-link="${role.name}"]`).doesNotExist(`${role.type}: role is no longer in the list`);
assert
.dom(`[data-test-secret-link="${role.name}"]`)
.doesNotExist(`${role.type}: role is no longer in the list`);
});
});
});
56 changes: 26 additions & 30 deletions ui/tests/acceptance/tools-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,50 +118,46 @@ test('tools functionality', function(assert) {
click('[data-test-tools-b64-toggle="input"]');
click('[data-test-tools-submit]');
andThen(() => {
assert.dom('[data-test-tools-input="sum"]').hasValue(
'LCa0a2j/xo/5m0U8HTBBNBNCLXBkg7+g+YpeiGJm564=',
'hashes the data, encodes input'
);
assert
.dom('[data-test-tools-input="sum"]')
.hasValue('LCa0a2j/xo/5m0U8HTBBNBNCLXBkg7+g+YpeiGJm564=', 'hashes the data, encodes input');
});
click('[data-test-tools-back]');
fillIn('[data-test-tools-input="hash-input"]', 'e2RhdGE6ImZvbyJ9');

click('[data-test-tools-submit]');
andThen(() => {
assert.dom('[data-test-tools-input="sum"]').hasValue(
'JmSi2Hhbgu2WYOrcOyTqqMdym7KT3sohCwAwaMonVrc=',
'hashes the data, passes b64 input through'
);
assert
.dom('[data-test-tools-input="sum"]')
.hasValue('JmSi2Hhbgu2WYOrcOyTqqMdym7KT3sohCwAwaMonVrc=', 'hashes the data, passes b64 input through');
});
});

const AUTH_RESPONSE = {
"request_id": "39802bc4-235c-2f0b-87f3-ccf38503ac3e",
"lease_id": "",
"renewable": false,
"lease_duration": 0,
"data": null,
"wrap_info": null,
"warnings": null,
"auth": {
"client_token": "ecfc2758-588e-981d-50f4-a25883bbf03c",
"accessor": "6299780b-f2b2-1a3f-7b83-9d3d67629249",
"policies": [
"root"
],
"metadata": null,
"lease_duration": 0,
"renewable": false,
"entity_id": ""
}
request_id: '39802bc4-235c-2f0b-87f3-ccf38503ac3e',
lease_id: '',
renewable: false,
lease_duration: 0,
data: null,
wrap_info: null,
warnings: null,
auth: {
client_token: 'ecfc2758-588e-981d-50f4-a25883bbf03c',
accessor: '6299780b-f2b2-1a3f-7b83-9d3d67629249',
policies: ['root'],
metadata: null,
lease_duration: 0,
renewable: false,
entity_id: '',
},
};

test('ensure unwrap with auth block works properly', function(assert) {
this.server = new Pretender(function() {
this.post('/v1/sys/wrapping/unwrap', response => {
return [response, { 'Content-Type': 'application/json' }, JSON.stringify(AUTH_RESPONSE)];
});
this.server = new Pretender(function() {
this.post('/v1/sys/wrapping/unwrap', response => {
return [response, { 'Content-Type': 'application/json' }, JSON.stringify(AUTH_RESPONSE)];
});
});
visit('/vault/tools');
//unwrap
click('[data-test-tools-action-link="unwrap"]');
Expand Down
Loading

0 comments on commit d195251

Please sign in to comment.