mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-18 12:37:02 +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
170 lines
6.4 KiB
JavaScript
170 lines
6.4 KiB
JavaScript
export default (test) => {
|
|
test('it should make request to correct endpoint on save', async function (assert) {
|
|
assert.expect(1);
|
|
|
|
this.server.post(this.path, () => {
|
|
assert.ok(true, 'request made to correct endpoint on save');
|
|
});
|
|
|
|
const model = this.store.createRecord(this.modelName, this.data);
|
|
await model.save();
|
|
});
|
|
|
|
test('it should throw error if attempting to createRecord with an existing name', async function (assert) {
|
|
const { modelName, data } = this;
|
|
this.store.pushPayload(modelName, { modelName, name: data.name });
|
|
|
|
const model = this.store.createRecord(modelName, data);
|
|
assert.rejects(model.save(), `Error: A record already exists with the name: ${data.name}`);
|
|
});
|
|
|
|
test('it should make request to correct endpoint on find', async function (assert) {
|
|
assert.expect(1);
|
|
|
|
this.server.get(this.path, () => {
|
|
assert.ok(true, 'request is made to correct endpoint on find');
|
|
return { data: this.data };
|
|
});
|
|
|
|
this.store.findRecord(this.modelName, this.data.name);
|
|
});
|
|
|
|
test('it should make request to correct endpoint on query', async function (assert) {
|
|
const keyInfoModels = ['client', 'provider']; // these models have key_info on the LIST response
|
|
const { name, ...otherAttrs } = this.data; // excludes name from key_info data
|
|
const key_info = { [name]: { ...otherAttrs } };
|
|
|
|
this.server.get(`/identity/${this.modelName}`, (schema, req) => {
|
|
assert.strictEqual(req.queryParams.list, 'true', 'request is made to correct endpoint on query');
|
|
if (keyInfoModels.some((model) => this.modelName.includes(model))) {
|
|
return { data: { keys: [name], key_info } };
|
|
} else {
|
|
return { data: { keys: [name] } };
|
|
}
|
|
});
|
|
|
|
this.store.query(this.modelName, {});
|
|
});
|
|
|
|
test('it should filter query when passed filterFor and paramKey', async function (assert) {
|
|
const keyInfoModels = ['client', 'provider']; // these models have key_info on the LIST response
|
|
const keys = ['model-1', 'model-2', 'model-3'];
|
|
const key_info = {
|
|
'model-1': {
|
|
model_id: 'a123',
|
|
key: 'test-key',
|
|
access_token_ttl: '30m',
|
|
id_token_ttl: '1h',
|
|
},
|
|
'model-2': {
|
|
model_id: 'b123',
|
|
key: 'test-key',
|
|
access_token_ttl: '30m',
|
|
id_token_ttl: '1h',
|
|
},
|
|
'model-3': {
|
|
model_id: 'c123',
|
|
key: 'test-key',
|
|
access_token_ttl: '30m',
|
|
id_token_ttl: '1h',
|
|
},
|
|
};
|
|
|
|
this.server.get(`/identity/${this.modelName}`, () => {
|
|
if (keyInfoModels.some((model) => this.modelName.includes(model))) {
|
|
return { data: { keys, key_info } };
|
|
} else {
|
|
return { data: { keys: [this.data.name] } };
|
|
}
|
|
});
|
|
|
|
// test passing 'paramKey' and 'filterFor' to query and filterListResponse in adapters/named-path.js works as expected
|
|
if (keyInfoModels.some((model) => this.modelName.includes(model))) {
|
|
let testQuery = ['*', 'a123'];
|
|
await this.store
|
|
.query(this.modelName, { paramKey: 'model_id', filterFor: testQuery })
|
|
.then((resp) =>
|
|
assert.strictEqual(resp.content.length, 3, 'returns all models when ids include glob (*)')
|
|
);
|
|
|
|
testQuery = ['*'];
|
|
await this.store
|
|
.query(this.modelName, { paramKey: 'model_id', filterFor: testQuery })
|
|
.then((resp) =>
|
|
assert.strictEqual(resp.content.length, 3, 'returns all models when glob (*) is only id')
|
|
);
|
|
|
|
testQuery = ['b123'];
|
|
await this.store.query(this.modelName, { paramKey: 'model_id', filterFor: testQuery }).then((resp) => {
|
|
assert.strictEqual(resp.content.length, 1, 'filters response and returns only matching id');
|
|
|
|
assert.strictEqual(resp.firstObject.name, 'model-2', 'response contains correct model');
|
|
});
|
|
|
|
testQuery = ['b123', 'c123'];
|
|
await this.store.query(this.modelName, { paramKey: 'model_id', filterFor: testQuery }).then((resp) => {
|
|
assert.strictEqual(resp.content.length, 2, 'filters response when passed multiple ids');
|
|
resp.content.forEach((m) =>
|
|
assert.ok(['model-2', 'model-3'].includes(m.id), `it filters correctly and included: ${m.id}`)
|
|
);
|
|
});
|
|
|
|
await this.store
|
|
.query(this.modelName, { paramKey: 'nonexistent_key', filterFor: testQuery })
|
|
.then((resp) => assert.ok(resp.isLoaded, 'does not error when paramKey does not exist'));
|
|
|
|
assert.rejects(
|
|
this.store.query(this.modelName, { paramKey: 'model_id', filterFor: 'some-string' }),
|
|
'throws assertion when filterFor is not an array'
|
|
);
|
|
} else {
|
|
let testQuery = ['b123', 'c123'];
|
|
await this.store
|
|
.query(this.modelName, { paramKey: 'model_id', filterFor: testQuery })
|
|
.then((resp) => assert.ok(resp.isLoaded, 'does not error when key_info does not exist'));
|
|
}
|
|
});
|
|
|
|
test('it passes allowed_client_id only when the param exists', async function (assert) {
|
|
const keyInfoModels = ['client', 'provider']; // these models have key_info on the LIST response
|
|
const { name, ...otherAttrs } = this.data; // excludes name from key_info data
|
|
const key_info = { [name]: { ...otherAttrs } };
|
|
|
|
this.server.get(`/identity/${this.modelName}`, (schema, req) => {
|
|
if (this.modelName === 'oidc/provider') {
|
|
assert.propEqual(
|
|
req.queryParams,
|
|
{ list: 'true', allowed_client_id: 'a123' },
|
|
'request has allowed_client_id as query param'
|
|
);
|
|
} else {
|
|
assert.propEqual(req.queryParams, { list: 'true' }, 'request only has `list` param');
|
|
}
|
|
if (keyInfoModels.some((model) => this.modelName.includes(model))) {
|
|
return { data: { keys: [name], key_info } };
|
|
} else {
|
|
return { data: { keys: [name] } };
|
|
}
|
|
});
|
|
|
|
// only /provider accepts an allowed_client_id
|
|
if (this.modelName === 'oidc/provider') {
|
|
this.store.query(this.modelName, { allowed_client_id: 'a123' });
|
|
} else {
|
|
this.store.query(this.modelName, {});
|
|
}
|
|
});
|
|
|
|
test('it should make request to correct endpoint on delete', async function (assert) {
|
|
assert.expect(1);
|
|
|
|
this.server.get(this.path, () => ({ data: this.data }));
|
|
this.server.delete(this.path, () => {
|
|
assert.ok(true, 'request made to correct endpoint on delete');
|
|
});
|
|
|
|
const model = await this.store.findRecord(this.modelName, this.data.name);
|
|
await model.destroyRecord();
|
|
});
|
|
};
|