feat: 🎸 Add indexedDb parser (#2068)
* feat: 🎸 Add indexedDb parser ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12164 --------- Co-authored-by: Lisbet Alvarez <lisbet.alvarez@hashicorp.com>
This commit is contained in:
1 parent
bd5e3da1f4
commit
d72fa0d6e3
24 files changed
+890
-178
No files matched your search
@@ -29,19 +29,16 @@ module('Unit | Model | auth method', function (hooks) {
|
||||
|
||||
test('it has a `changeState` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
'/v1/auth-methods/123abc:change-state',
|
||||
(schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
attributes: {
|
||||
state: 'foobar',
|
||||
},
|
||||
version: 1,
|
||||
});
|
||||
return { id: '123abc' };
|
||||
},
|
||||
);
|
||||
this.server.post('/auth-methods/123abc:change-state', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
attributes: {
|
||||
state: 'foobar',
|
||||
},
|
||||
version: 1,
|
||||
});
|
||||
return { id: '123abc' };
|
||||
});
|
||||
store.push({
|
||||
data: {
|
||||
id: '123abc',
|
||||
|
||||
@@ -80,7 +80,7 @@ module('Unit | Model | base', function (hooks) {
|
||||
attributes: {},
|
||||
},
|
||||
});
|
||||
this.server.patch('/v1/users/1', () => {
|
||||
this.server.patch('users/1', () => {
|
||||
assert.ok(true, 'Correctly scoped update record URL was requested.');
|
||||
return { id: 1 };
|
||||
});
|
||||
@@ -112,17 +112,17 @@ module('Unit | Model | base', function (hooks) {
|
||||
assert.expect(3);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const model = store.createRecord('user', { scopeID: 'o_123' });
|
||||
this.server.post('/v1/users', () => {
|
||||
this.server.post('users', () => {
|
||||
assert.ok(true, 'Correctly scoped create record URL was requested.');
|
||||
return { id: 'u_123' };
|
||||
});
|
||||
await model.save();
|
||||
this.server.patch('/v1/users/u_123', () => {
|
||||
this.server.patch('users/u_123', () => {
|
||||
assert.ok(true, 'Correctly scoped update record URL was requested.');
|
||||
return { id: 'u_123' };
|
||||
});
|
||||
await model.save();
|
||||
this.server.delete('/v1/users/u_123', () => {
|
||||
this.server.delete('users/u_123', () => {
|
||||
assert.ok(true, 'Correctly scoped delete record URL was requested.');
|
||||
return {};
|
||||
});
|
||||
@@ -135,17 +135,17 @@ module('Unit | Model | base', function (hooks) {
|
||||
const customScopeID = 'global';
|
||||
const scope = { scope_id: 'o_123' };
|
||||
const model = store.createRecord('user', { scope });
|
||||
this.server.post('/v1/users', () => {
|
||||
this.server.post('users', () => {
|
||||
assert.ok(true, 'Correctly scoped create record URL was requested.');
|
||||
return { id: 'u_123' };
|
||||
});
|
||||
await model.save({ adapterOptions: { scopeID: customScopeID } });
|
||||
this.server.patch('/v1/users/u_123', () => {
|
||||
this.server.patch('users/u_123', () => {
|
||||
assert.ok(true, 'Correctly scoped update record URL was requested.');
|
||||
return { id: 'u_123' };
|
||||
});
|
||||
await model.save({ adapterOptions: { scopeID: customScopeID } });
|
||||
this.server.delete('/v1/users/u_123', () => {
|
||||
this.server.delete('users/u_123', () => {
|
||||
assert.ok(true, 'Correctly scoped delete record URL was requested.');
|
||||
return {};
|
||||
});
|
||||
@@ -158,7 +158,7 @@ module('Unit | Model | base', function (hooks) {
|
||||
const method = 'my-custom-method';
|
||||
const scope = { scope_id: 'o_123' };
|
||||
const model = store.createRecord('user', { scope });
|
||||
this.server.post(`/v1/users:${method}`, () => {
|
||||
this.server.post(`users:${method}`, () => {
|
||||
assert.ok(true, 'Correctly scoped create record URL was requested.');
|
||||
return { id: 'u_123' };
|
||||
});
|
||||
|
||||
@@ -63,7 +63,7 @@ module('Unit | Model | group', function (hooks) {
|
||||
|
||||
test('it has an `addMembers` method that groups a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/groups/123abc:add-members', (schema, request) => {
|
||||
this.server.post('/groups/123abc:add-members', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
member_ids: ['123_abc', 'foobar'],
|
||||
@@ -94,7 +94,7 @@ module('Unit | Model | group', function (hooks) {
|
||||
|
||||
test('it has a `removeMembers` method that groups a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/groups/123abc:remove-members', (schema, request) => {
|
||||
this.server.post('/groups/123abc:remove-members', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
member_ids: ['1', '3'],
|
||||
@@ -125,7 +125,7 @@ module('Unit | Model | group', function (hooks) {
|
||||
|
||||
test('it has a `removeMember` method that deletes a single member set using `removeMembers` method', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/groups/123abc:remove-members', (schema, request) => {
|
||||
this.server.post('/groups/123abc:remove-members', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
member_ids: ['3'],
|
||||
|
||||
@@ -13,7 +13,7 @@ module('Unit | Model | host set', function (hooks) {
|
||||
|
||||
test('it has an `addHosts` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/host-sets/123abc:add-hosts', (schema, request) => {
|
||||
this.server.post('/host-sets/123abc:add-hosts', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
host_ids: ['123_abc', 'foobar'],
|
||||
@@ -44,7 +44,7 @@ module('Unit | Model | host set', function (hooks) {
|
||||
|
||||
test('it has an `addHost` method that adds a single host using `addHosts` method', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/host-sets/123abc:add-hosts', (schema, request) => {
|
||||
this.server.post('/host-sets/123abc:add-hosts', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
host_ids: ['foobar'],
|
||||
@@ -75,7 +75,7 @@ module('Unit | Model | host set', function (hooks) {
|
||||
|
||||
test('it has a `removeHosts` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/host-sets/123abc:remove-hosts', (schema, request) => {
|
||||
this.server.post('/host-sets/123abc:remove-hosts', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
host_ids: ['3'],
|
||||
@@ -106,7 +106,7 @@ module('Unit | Model | host set', function (hooks) {
|
||||
|
||||
test('it has a `removeHost` method that removes a single host using `removeHosts` method', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/host-sets/123abc:remove-hosts', (schema, request) => {
|
||||
this.server.post('/host-sets/123abc:remove-hosts', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
host_ids: ['3'],
|
||||
|
||||
@@ -19,7 +19,7 @@ module('Unit | Model | role', function (hooks) {
|
||||
|
||||
test('it has a `saveGrantStrings` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/roles/123abc:set-grants', (schema, request) => {
|
||||
this.server.post('/roles/123abc:set-grants', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
grant_strings: ['foo', 'bar'],
|
||||
@@ -50,7 +50,7 @@ module('Unit | Model | role', function (hooks) {
|
||||
|
||||
test('it has an `addPrincipals` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/roles/123abc:add-principals', (schema, request) => {
|
||||
this.server.post('/roles/123abc:add-principals', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
principal_ids: ['123_abc', 'foobar'],
|
||||
@@ -85,17 +85,14 @@ module('Unit | Model | role', function (hooks) {
|
||||
|
||||
test('it has a `removePrincipals` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
'/v1/roles/123abc:remove-principals',
|
||||
(schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
principal_ids: ['1', '3', '5'],
|
||||
version: 1,
|
||||
});
|
||||
return { id: '123abc' };
|
||||
},
|
||||
);
|
||||
this.server.post('/roles/123abc:remove-principals', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
principal_ids: ['1', '3', '5'],
|
||||
version: 1,
|
||||
});
|
||||
return { id: '123abc' };
|
||||
});
|
||||
const store = this.owner.lookup('service:store');
|
||||
store.push({
|
||||
data: {
|
||||
@@ -123,17 +120,14 @@ module('Unit | Model | role', function (hooks) {
|
||||
|
||||
test('it has a `removePrincipal` method that deletes a single principal using `removePrincipals` method', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
'/v1/roles/123abc:remove-principals',
|
||||
(schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
principal_ids: ['3'],
|
||||
version: 1,
|
||||
});
|
||||
return { id: '123abc' };
|
||||
},
|
||||
);
|
||||
this.server.post('/roles/123abc:remove-principals', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
principal_ids: ['3'],
|
||||
version: 1,
|
||||
});
|
||||
return { id: '123abc' };
|
||||
});
|
||||
const store = this.owner.lookup('service:store');
|
||||
store.push({
|
||||
data: {
|
||||
|
||||
@@ -13,7 +13,7 @@ module('Unit | Model | scope', function (hooks) {
|
||||
|
||||
test('it may have a scope fragment', async function (assert) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
this.server.get('/v1/scopes', () => ({
|
||||
this.server.get('/scopes', () => ({
|
||||
items: [
|
||||
{ id: 'global', type: 'global' },
|
||||
{ id: 'o_1', type: 'org', scope: { scope_id: 'global' } },
|
||||
@@ -72,7 +72,7 @@ module('Unit | Model | scope', function (hooks) {
|
||||
test('it has an `attachStoragePolicy` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
'/v1/scopes/123abc:attach-storage-policy',
|
||||
'/scopes/123abc:attach-storage-policy',
|
||||
(schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
@@ -106,7 +106,7 @@ module('Unit | Model | scope', function (hooks) {
|
||||
test('it has a `detachStoragePolicy` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
'/v1/scopes/123abc:detach-storage-policy',
|
||||
'/scopes/123abc:detach-storage-policy',
|
||||
(schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
|
||||
@@ -79,17 +79,14 @@ module('Unit | Model | target', function (hooks) {
|
||||
|
||||
test('it has an `addHostSources` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
'/v1/targets/123abc:add-host-sources',
|
||||
(schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
host_source_ids: ['123_abc', 'foobar'],
|
||||
version: 1,
|
||||
});
|
||||
return { id: '123abc' };
|
||||
},
|
||||
);
|
||||
this.server.post('/targets/123abc:add-host-sources', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
host_source_ids: ['123_abc', 'foobar'],
|
||||
version: 1,
|
||||
});
|
||||
return { id: '123abc' };
|
||||
});
|
||||
const store = this.owner.lookup('service:store');
|
||||
store.push({
|
||||
data: {
|
||||
@@ -117,7 +114,7 @@ module('Unit | Model | target', function (hooks) {
|
||||
test('it has a `removeHostSources` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
'/v1/targets/123abc:remove-host-sources',
|
||||
'/targets/123abc:remove-host-sources',
|
||||
(schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
@@ -154,7 +151,7 @@ module('Unit | Model | target', function (hooks) {
|
||||
test('it has a `removeHostSource` method that deletes a single host set using `removeHostSources` method', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
'/v1/targets/123abc:remove-host-sources',
|
||||
'/targets/123abc:remove-host-sources',
|
||||
(schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
@@ -283,7 +280,7 @@ module('Unit | Model | target', function (hooks) {
|
||||
test('it has an `addBrokeredCredentialSources` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
'/v1/targets/123abc:add-credential-sources',
|
||||
'/targets/123abc:add-credential-sources',
|
||||
(schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
@@ -317,7 +314,7 @@ module('Unit | Model | target', function (hooks) {
|
||||
test('it has a `removeBrokeredCredentialSources` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
'/v1/targets/123abc:remove-credential-sources',
|
||||
'/targets/123abc:remove-credential-sources',
|
||||
(schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
@@ -351,7 +348,7 @@ module('Unit | Model | target', function (hooks) {
|
||||
test('it has a `removeBrokeredCredentialSource` method that deletes a single credential library using `removeBrokeredCredentialSources` method', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
'/v1/targets/123abc:remove-credential-sources',
|
||||
'/targets/123abc:remove-credential-sources',
|
||||
(schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
|
||||
@@ -13,7 +13,7 @@ module('Unit | Model | user', function (hooks) {
|
||||
|
||||
test('it has an `addAccounts` method that users a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/users/123abc:add-accounts', (schema, request) => {
|
||||
this.server.post('/users/123abc:add-accounts', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
account_ids: ['123_abc', 'foobar'],
|
||||
@@ -44,7 +44,7 @@ module('Unit | Model | user', function (hooks) {
|
||||
|
||||
test('it has a `removeAccounts` method that users a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/users/123abc:remove-accounts', (schema, request) => {
|
||||
this.server.post('/users/123abc:remove-accounts', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
account_ids: ['1', '3'],
|
||||
@@ -75,7 +75,7 @@ module('Unit | Model | user', function (hooks) {
|
||||
|
||||
test('it has a `removeAccount` method that deletes a single account set using `removeAccounts` method', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/users/123abc:remove-accounts', (schema, request) => {
|
||||
this.server.post('/users/123abc:remove-accounts', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
account_ids: ['3'],
|
||||
@@ -122,7 +122,7 @@ module('Unit | Model | user', function (hooks) {
|
||||
|
||||
test('it defaults to null for readonly attributes when response does not have fields', async function (assert) {
|
||||
assert.expect(3);
|
||||
this.server.post('/v1/users/123abc:remove-accounts', (schema, request) => {
|
||||
this.server.post('/users/123abc:remove-accounts', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
account_ids: ['3'],
|
||||
|
||||
@@ -15,7 +15,7 @@ module('Unit | Model | worker', function (hooks) {
|
||||
assert.expect(2);
|
||||
const scopeId = 'global';
|
||||
const workerGeneratedAuthToken = 'token';
|
||||
this.server.post('/v1/workers:create:worker-led', (schema, request) => {
|
||||
this.server.post('/workers:create:worker-led', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
scope_id: scopeId,
|
||||
|
||||
Reference in new issue
Block a user