mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-15 02:57:04 +02:00
* runs ember-cli-update to 4.4.0 * updates yarn.lock * updates dependencies causing runtime errors (#17135) * Inject Store Service When Accessed Implicitly (#17345) * adds codemod for injecting store service * adds custom babylon parser with decorators-legacy plugin for jscodeshift transforms * updates inject-store-service codemod to only look for .extend object expressions and adds recast options * runs inject-store-service codemod on js files * replace query-params helper with hash (#17404) * Updates/removes dependencies throwing errors in Ember 4.4 (#17396) * updates ember-responsive to latest * updates ember-composable-helpers to latest and uses includes helper since contains was removed * updates ember-concurrency to latest * updates ember-cli-clipboard to latest * temporary workaround for toolbar-link component throwing errors for using params arg with LinkTo * adds missing store injection to auth configure route * fixes issue with string-list component throwing error for accessing prop in same computation * fixes non-iterable query params issue in mfa methods controller * refactors field-to-attrs to handle belongsTo rather than fragments * converts mount-config fragment to belongsTo on auth-method model * removes ember-api-actions and adds tune method to auth-method adapter * converts cluster replication attributes from fragment to relationship * updates ember-data, removes ember-data-fragments and updates yarn to latest * removes fragments from secret-engine model * removes fragment from test-form-model * removes commented out code * minor change to inject-store-service codemod and runs again on js files * Remove LinkTo positional params (#17421) * updates ember-cli-page-object to latest version * update toolbar-link to support link-to args and not positional params * adds replace arg to toolbar-link component * Clean up js lint errors (#17426) * replaces assert.equal to assert.strictEqual * update eslint no-console to error and disables invididual intended uses of console * cleans up hbs lint warnings (#17432) * Upgrade bug and test fixes (#17500) * updates inject-service codemod to take arg for service name and runs for flashMessages service * fixes hbs lint error after merging main * fixes flash messages * updates more deps * bug fixes * test fixes * updates ember-cli-content-security-policy and prevents default form submission throwing errors * more bug and test fixes * removes commented out code * fixes issue with code-mirror modifier sending change event on setup causing same computation error * Upgrade Clean Up (#17543) * updates deprecation workflow and filter * cleans up build errors, removes unused ivy-codemirror and sass and updates ember-cli-sass and node-sass to latest * fixes control groups test that was skipped after upgrade * updates control group service tests * addresses review feedback * updates control group service handleError method to use router.currentURL rather that transition.intent.url * adds changelog entry
95 lines
3.6 KiB
JavaScript
95 lines
3.6 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import Service from '@ember/service';
|
|
import { click, find, render, typeIn } from '@ember/test-helpers';
|
|
import { selectChoose, clickTrigger } from 'ember-power-select/test-support/helpers';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import sinon from 'sinon';
|
|
|
|
const TITLE = 'Get Credentials';
|
|
const SEARCH_LABEL = 'Role to use';
|
|
|
|
const storeService = Service.extend({
|
|
query(modelType) {
|
|
return new Promise((resolve, reject) => {
|
|
switch (modelType) {
|
|
case 'database/role':
|
|
resolve([{ id: 'my-role', backend: 'database' }]);
|
|
break;
|
|
default:
|
|
reject({ httpStatus: 404, message: 'not found' });
|
|
break;
|
|
}
|
|
reject({ httpStatus: 404, message: 'not found' });
|
|
});
|
|
},
|
|
});
|
|
|
|
module('Integration | Component | get-credentials-card', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.router = this.owner.lookup('service:router');
|
|
this.router.transitionTo = sinon.stub();
|
|
|
|
this.owner.unregister('service:store');
|
|
this.owner.register('service:store', storeService);
|
|
this.set('title', TITLE);
|
|
this.set('searchLabel', SEARCH_LABEL);
|
|
});
|
|
|
|
hooks.afterEach(function () {
|
|
this.router.transitionTo.reset();
|
|
});
|
|
|
|
test('it shows a disabled button when no item is selected', async function (assert) {
|
|
await render(hbs`<GetCredentialsCard @title={{this.title}} @searchLabel={{this.searchLabel}}/>`);
|
|
assert.dom('[data-test-get-credentials]').isDisabled();
|
|
});
|
|
|
|
test('it shows button that can be clicked to credentials route when an item is selected', async function (assert) {
|
|
const models = ['database/role'];
|
|
this.set('models', models);
|
|
await render(
|
|
hbs`<GetCredentialsCard @title={{this.title}} @searchLabel={{this.searchLabel}} @placeholder="Search for a role..." @models={{this.models}} @type="role"/>`
|
|
);
|
|
assert
|
|
.dom('[data-test-component="search-select"]#search-input-role')
|
|
.exists('renders search select component by default');
|
|
assert
|
|
.dom('[data-test-component="search-select"]#search-input-role')
|
|
.hasText('Search for a role...', 'renders placeholder text passed to search select');
|
|
await clickTrigger();
|
|
await selectChoose('', 'my-role');
|
|
assert.dom('[data-test-get-credentials]').isEnabled();
|
|
await click('[data-test-get-credentials]');
|
|
assert.propEqual(
|
|
this.router.transitionTo.lastCall.args,
|
|
['vault.cluster.secrets.backend.credentials', 'my-role'],
|
|
'transitionTo is called with correct route and role name'
|
|
);
|
|
});
|
|
|
|
test('it renders input search field when renderInputSearch=true and shows placeholder text', async function (assert) {
|
|
await render(
|
|
hbs`<GetCredentialsCard @title={{this.title}} @renderInputSearch={{true}} @placeholder="secret/" @backend="kv" @type="secret"/>`
|
|
);
|
|
assert
|
|
.dom('[data-test-component="search-select"]')
|
|
.doesNotExist('does not render search select component');
|
|
assert.strictEqual(
|
|
find('[data-test-search-roles] input').placeholder,
|
|
'secret/',
|
|
'renders placeholder text passed to search input'
|
|
);
|
|
await typeIn('[data-test-search-roles] input', 'test');
|
|
assert.dom('[data-test-get-credentials]').isEnabled('submit button enables after typing input text');
|
|
await click('[data-test-get-credentials]');
|
|
assert.propEqual(
|
|
this.router.transitionTo.lastCall.args,
|
|
['vault.cluster.secrets.backend.show', 'test'],
|
|
'transitionTo is called with correct route and secret name'
|
|
);
|
|
});
|
|
});
|