2018-08-29 09:00:15 +00:00
|
|
|
import { moduleFor, test } from 'ember-qunit';
|
|
|
|
import repo from 'consul-ui/tests/helpers/repo';
|
2018-10-26 16:36:15 +00:00
|
|
|
const NAME = 'acl';
|
|
|
|
moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
|
2018-08-29 09:00:15 +00:00
|
|
|
// Specify the other units that are required for this test.
|
2019-12-17 18:47:37 +00:00
|
|
|
integration: true,
|
2018-08-29 09:00:15 +00:00
|
|
|
});
|
|
|
|
const dc = 'dc-1';
|
2019-12-17 18:47:37 +00:00
|
|
|
const nspace = 'default';
|
2018-08-29 09:00:15 +00:00
|
|
|
const id = 'token-name';
|
|
|
|
test('findByDatacenter returns the correct data for list endpoint', function(assert) {
|
|
|
|
return repo(
|
|
|
|
'Acl',
|
|
|
|
'findAllByDatacenter',
|
|
|
|
this.subject(),
|
|
|
|
function retrieveStub(stub) {
|
|
|
|
return stub(`/v1/acl/list?dc=${dc}`, {
|
|
|
|
CONSUL_ACL_COUNT: '100',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
function performTest(service) {
|
2021-02-23 08:56:42 +00:00
|
|
|
return service.findAllByDatacenter({ dc });
|
2018-08-29 09:00:15 +00:00
|
|
|
},
|
|
|
|
function performAssertion(actual, expected) {
|
|
|
|
assert.deepEqual(
|
|
|
|
actual,
|
|
|
|
expected(function(payload) {
|
|
|
|
return payload.map(item =>
|
|
|
|
Object.assign({}, item, {
|
|
|
|
Datacenter: dc,
|
2019-12-17 18:47:37 +00:00
|
|
|
// TODO: default isn't required here, once we've
|
|
|
|
// refactored out our Serializer this can go
|
|
|
|
uid: `["${nspace}","${dc}","${item.ID}"]`,
|
2018-08-29 09:00:15 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
test('findBySlug returns the correct data for item endpoint', function(assert) {
|
|
|
|
return repo(
|
|
|
|
'Acl',
|
|
|
|
'findBySlug',
|
|
|
|
this.subject(),
|
|
|
|
function retrieveStub(stub) {
|
|
|
|
return stub(`/v1/acl/info/${id}?dc=${dc}`);
|
|
|
|
},
|
|
|
|
function performTest(service) {
|
2021-02-23 08:56:42 +00:00
|
|
|
return service.findBySlug({ id, dc });
|
2018-08-29 09:00:15 +00:00
|
|
|
},
|
|
|
|
function performAssertion(actual, expected) {
|
|
|
|
assert.deepEqual(
|
|
|
|
actual,
|
|
|
|
expected(function(payload) {
|
|
|
|
const item = payload[0];
|
|
|
|
return Object.assign({}, item, {
|
|
|
|
Datacenter: dc,
|
2019-12-17 18:47:37 +00:00
|
|
|
// TODO: default isn't required here, once we've
|
|
|
|
// refactored out our Serializer this can go
|
|
|
|
uid: `["${nspace}","${dc}","${item.ID}"]`,
|
2018-08-29 09:00:15 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|