Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix order of arguments for path-service #6540

Merged
merged 2 commits into from
Apr 5, 2019
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
2 changes: 1 addition & 1 deletion ui/app/routes/vault/cluster/secrets/backend/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default Route.extend({
}
let modelType = 'ssh-otp-credential';
let owner = getOwner(this);
return this.pathHelp.getNewModel(modelType, backend, owner);
return this.pathHelp.getNewModel(modelType, owner, backend);
},

model(params) {
Expand Down
1 change: 1 addition & 0 deletions ui/app/templates/components/role-ssh-edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
mode="edit"
replace=true
class="button has-icon-right is-ghost is-compact"
data-test-edit-link=true
}}
Edit role
{{i-con glyph="chevron-right" size=11}}
Expand Down
77 changes: 77 additions & 0 deletions ui/tests/acceptance/secrets/backend/ssh/role-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { currentRouteName } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import editPage from 'vault/tests/pages/secrets/backend/ssh/edit-role';
import showPage from 'vault/tests/pages/secrets/backend/ssh/show';
import generatePage from 'vault/tests/pages/secrets/backend/ssh/generate-otp';
import listPage from 'vault/tests/pages/secrets/backend/list';
import enablePage from 'vault/tests/pages/settings/mount-secret-backend';
import authPage from 'vault/tests/pages/auth';

module('Acceptance | secrets/ssh', function(hooks) {
setupApplicationTest(hooks);

hooks.beforeEach(function() {
return authPage.login();
});

const mountAndNav = async () => {
const path = `ssh-${new Date().getTime()}`;
await enablePage.enable('ssh', path);
await editPage.visitRoot({ backend: path });
return path;
};

test('it creates a role and redirects', async function(assert) {
const path = await mountAndNav(assert);
await editPage.createOTPRole('role');
assert.equal(currentRouteName(), 'vault.cluster.secrets.backend.show', 'redirects to the show page');
assert.ok(showPage.generateIsPresent, 'shows the generate button');

await showPage.visit({ backend: path, id: 'role' });
await showPage.generate();
assert.equal(
currentRouteName(),
'vault.cluster.secrets.backend.credentials',
'navs to the credentials page'
);

await listPage.visitRoot({ backend: path });
assert.equal(listPage.secrets.length, 1, 'shows role in the list');
let secret = listPage.secrets.objectAt(0);
await secret.menuToggle();
assert.ok(listPage.menuItems.length > 0, 'shows links in the menu');
});

test('it deletes a role', async function(assert) {
await mountAndNav(assert);
await editPage.createOTPRole('role');
await showPage.edit();
assert.equal(currentRouteName(), 'vault.cluster.secrets.backend.edit', 'navs to the edit page');

await editPage.deleteRole();
assert.equal(currentRouteName(), 'vault.cluster.secrets.backend.list-root', 'redirects to list page');
assert.ok(listPage.backendIsEmpty, 'no roles listed');
});

test('it generates an OTP', async function(assert) {
const path = await mountAndNav(assert);
await editPage.createOTPRole('role');
assert.equal(currentRouteName(), 'vault.cluster.secrets.backend.show', 'redirects to the show page');
assert.ok(showPage.generateIsPresent, 'shows the generate button');

await showPage.visit({ backend: path, id: 'role' });
await showPage.generate();
assert.equal(
currentRouteName(),
'vault.cluster.secrets.backend.credentials',
'navs to the credentials page'
);

await generatePage.generateOTP();
assert.ok(generatePage.warningIsPresent, 'shows warning');
await generatePage.back();
assert.ok(generatePage.userIsPresent, 'clears generate, shows user input');
assert.ok(generatePage.ipIsPresent, 'clears generate, shows ip input');
});
});
28 changes: 28 additions & 0 deletions ui/tests/pages/secrets/backend/ssh/edit-role.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Base } from '../create';
import { clickable, visitable, create, fillable } from 'ember-cli-page-object';

export default create({
...Base,
visitEdit: visitable('/vault/secrets/:backend/edit/:id'),
visitEditRoot: visitable('/vault/secrets/:backend/edit'),
keyType: fillable('[data-test-input="keyType"]'),
defaultUser: fillable('[data-test-input="defaultUser"]'),
toggleMore: clickable('[data-test-toggle-more]'),
name: fillable('[data-test-input="name"]'),
CIDR: fillable('[data-test-input="cidrList"]'),
save: clickable('[data-test-role-ssh-create]'),
deleteBtn: clickable('[data-test-confirm-action-trigger]'),
confirmBtn: clickable('[data-test-confirm-button]'),
deleteRole() {
return this.deleteBtn().confirmBtn();
},

async createOTPRole(name) {
await this.toggleMore()
.keyType('otp')
.name(name)
.defaultUser('admin')
.CIDR('0.0.0.0/0')
.save();
},
});
19 changes: 19 additions & 0 deletions ui/tests/pages/secrets/backend/ssh/generate-otp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Base } from '../credentials';
import { clickable, value, create, fillable, isPresent } from 'ember-cli-page-object';

export default create({
...Base,
userIsPresent: isPresent('[data-test-input="username"]'),
ipIsPresent: isPresent('[data-test-input="ip"]'),
user: fillable('[data-test-input="username"]'),
ip: fillable('[data-test-input="ip"]'),
warningIsPresent: isPresent('[data-test-warning]'),
commonNameValue: value('[data-test-input="commonName"]'),
submit: clickable('[data-test-secret-generate]'),
back: clickable('[data-test-secret-generate-back]'),
generateOTP: async function() {
await this.user('admin')
.ip('192.168.1.1')
.submit();
},
});
11 changes: 11 additions & 0 deletions ui/tests/pages/secrets/backend/ssh/show.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Base } from '../show';
import { create, clickable, collection, isPresent } from 'ember-cli-page-object';

export default create({
...Base,
rows: collection('data-test-row-label'),
edit: clickable('[data-test-edit-link]'),
editIsPresent: isPresent('[data-test-edit-link]'),
generate: clickable('[data-test-backend-credentials]'),
generateIsPresent: isPresent('[data-test-backend-credentials]'),
});