2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
2022-09-01 15:37:37 +00:00
|
|
|
import { setupTest } from 'ember-qunit';
|
2021-02-17 18:56:56 +00:00
|
|
|
import repo from 'consul-ui/tests/helpers/repo';
|
2022-09-01 15:37:37 +00:00
|
|
|
import { module, skip, test } from 'qunit';
|
2021-02-17 18:56:56 +00:00
|
|
|
|
2022-09-15 08:43:17 +00:00
|
|
|
module(`Integration | Service | auth-method`, function (hooks) {
|
2022-09-01 15:37:37 +00:00
|
|
|
setupTest(hooks);
|
|
|
|
const dc = 'dc-1';
|
|
|
|
const id = 'auth-method-name';
|
|
|
|
const undefinedNspace = 'default';
|
|
|
|
const undefinedPartition = 'default';
|
|
|
|
const partition = 'default';
|
2022-09-15 08:43:17 +00:00
|
|
|
[undefinedNspace, 'team-1', undefined].forEach((nspace) => {
|
|
|
|
test(`findAllByDatacenter returns the correct data for list endpoint when nspace is ${nspace}`, function (assert) {
|
2022-09-01 15:37:37 +00:00
|
|
|
const subject = this.owner.lookup('service:repository/auth-method');
|
|
|
|
|
|
|
|
return repo(
|
|
|
|
'auth-method',
|
|
|
|
'findAllByDatacenter',
|
|
|
|
subject,
|
|
|
|
function retrieveStub(stub) {
|
|
|
|
return stub(
|
|
|
|
`/v1/acl/auth-methods?dc=${dc}${typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``}${
|
|
|
|
typeof partition !== 'undefined' ? `&partition=${partition}` : ``
|
|
|
|
}`,
|
|
|
|
{
|
|
|
|
CONSUL_AUTH_METHOD_COUNT: '3',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
function performTest(service) {
|
|
|
|
return service.findAllByDatacenter({
|
|
|
|
dc: dc,
|
|
|
|
nspace: nspace || undefinedNspace,
|
|
|
|
partition: partition || undefinedPartition,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
function performAssertion(actual, expected) {
|
2022-09-15 08:43:17 +00:00
|
|
|
assert.propContains(
|
2022-09-01 15:37:37 +00:00
|
|
|
actual,
|
2022-09-15 08:43:17 +00:00
|
|
|
expected(function (payload) {
|
|
|
|
return payload.map(function (item) {
|
2022-09-01 15:37:37 +00:00
|
|
|
return Object.assign({}, item, {
|
|
|
|
Datacenter: dc,
|
|
|
|
Namespace: item.Namespace || undefinedNspace,
|
|
|
|
Partition: item.Partition || undefinedPartition,
|
2022-09-15 08:43:17 +00:00
|
|
|
uid: `["${item.Partition || undefinedPartition}","${
|
|
|
|
item.Namespace || undefinedNspace
|
|
|
|
}","${dc}","${item.Name}"]`,
|
2022-09-01 15:37:37 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2022-09-15 08:43:17 +00:00
|
|
|
skip(`findBySlug returns the correct data for item endpoint when the nspace is ${nspace}`, function (assert) {
|
2022-09-01 15:37:37 +00:00
|
|
|
const subject = this.owner.lookup('service:repository/auth-method');
|
|
|
|
|
|
|
|
return repo(
|
|
|
|
'AuthMethod',
|
|
|
|
'findBySlug',
|
|
|
|
subject,
|
|
|
|
function retrieveStub(stub) {
|
|
|
|
return stub(
|
|
|
|
`/v1/acl/auth-method/${id}?dc=${dc}${
|
|
|
|
typeof nspace !== 'undefined' ? `&ns=${nspace}` : ``
|
|
|
|
}`
|
|
|
|
);
|
|
|
|
},
|
|
|
|
function performTest(service) {
|
|
|
|
return service.findBySlug(id, dc, nspace || undefinedNspace);
|
|
|
|
},
|
|
|
|
function performAssertion(actual, expected) {
|
2022-09-15 08:43:17 +00:00
|
|
|
assert.propContains(
|
2022-09-01 15:37:37 +00:00
|
|
|
actual,
|
2022-09-15 08:43:17 +00:00
|
|
|
expected(function (payload) {
|
2022-09-01 15:37:37 +00:00
|
|
|
const item = payload;
|
2021-02-17 18:56:56 +00:00
|
|
|
return Object.assign({}, item, {
|
|
|
|
Datacenter: dc,
|
|
|
|
Namespace: item.Namespace || undefinedNspace,
|
2022-09-01 15:37:37 +00:00
|
|
|
uid: `["${item.Namespace || undefinedNspace}","${dc}","${item.Name}"]`,
|
|
|
|
meta: {
|
|
|
|
cacheControl: undefined,
|
|
|
|
cursor: undefined,
|
|
|
|
dc: dc,
|
|
|
|
nspace: item.Namespace || undefinedNspace,
|
|
|
|
},
|
2021-02-17 18:56:56 +00:00
|
|
|
});
|
2022-09-01 15:37:37 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2021-02-17 18:56:56 +00:00
|
|
|
});
|
|
|
|
});
|