ui: Use of header default ACL policy (#11192)
* Use of header default ACL policy * Update test for dc serializer
This commit is contained in:
parent
d4d6466665
commit
41ae63c2d2
|
@ -8,6 +8,7 @@ export default class Datacenter extends Model {
|
|||
@attr('string') uid;
|
||||
@attr('string') Name;
|
||||
@attr('boolean') Local;
|
||||
@attr('string') DefaultACLPolicy;
|
||||
|
||||
@attr('boolean', { defaultValue: () => true }) MeshEnabled;
|
||||
}
|
||||
|
|
|
@ -8,17 +8,21 @@ export default class DcSerializer extends Serializer {
|
|||
|
||||
respondForQuery(respond, query) {
|
||||
return respond(function(headers, body) {
|
||||
return body;
|
||||
return {
|
||||
body,
|
||||
headers,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
normalizePayload(payload, id, requestType) {
|
||||
switch (requestType) {
|
||||
case 'query':
|
||||
return payload.map(item => {
|
||||
return payload.body.map(item => {
|
||||
return {
|
||||
Local: this.env.var('CONSUL_DATACENTER_LOCAL') === item,
|
||||
[this.primaryKey]: item,
|
||||
DefaultACLPolicy: payload.headers['x-consul-default-acl-policy'],
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
"*":
|
||||
GET:
|
||||
"*":
|
||||
headers:
|
||||
response:
|
||||
X-Consul-Default-Acl-Policy: ${fake.helpers.randomize(['allow', 'deny'])}
|
|
@ -9,7 +9,10 @@ module('Integration | Serializer | dc', function(hooks) {
|
|||
url: `/v1/catalog/datacenters`,
|
||||
};
|
||||
return get(request.url).then(function(payload) {
|
||||
const expected = payload;
|
||||
const expected = {
|
||||
body: payload,
|
||||
headers: {},
|
||||
};
|
||||
const actual = serializer.respondForQuery(function(cb) {
|
||||
const headers = {};
|
||||
const body = payload;
|
||||
|
|
Loading…
Reference in New Issue