ui: Use of header default ACL policy (#11192)

* Use of header default ACL policy

* Update test for dc serializer
This commit is contained in:
Kenia 2021-09-30 13:01:48 -04:00 committed by GitHub
parent d4d6466665
commit 41ae63c2d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 3 deletions

View File

@ -8,6 +8,7 @@ export default class Datacenter extends Model {
@attr('string') uid; @attr('string') uid;
@attr('string') Name; @attr('string') Name;
@attr('boolean') Local; @attr('boolean') Local;
@attr('string') DefaultACLPolicy;
@attr('boolean', { defaultValue: () => true }) MeshEnabled; @attr('boolean', { defaultValue: () => true }) MeshEnabled;
} }

View File

@ -8,17 +8,21 @@ export default class DcSerializer extends Serializer {
respondForQuery(respond, query) { respondForQuery(respond, query) {
return respond(function(headers, body) { return respond(function(headers, body) {
return body; return {
body,
headers,
};
}); });
} }
normalizePayload(payload, id, requestType) { normalizePayload(payload, id, requestType) {
switch (requestType) { switch (requestType) {
case 'query': case 'query':
return payload.map(item => { return payload.body.map(item => {
return { return {
Local: this.env.var('CONSUL_DATACENTER_LOCAL') === item, Local: this.env.var('CONSUL_DATACENTER_LOCAL') === item,
[this.primaryKey]: item, [this.primaryKey]: item,
DefaultACLPolicy: payload.headers['x-consul-default-acl-policy'],
}; };
}); });
} }

View File

@ -0,0 +1,7 @@
---
"*":
GET:
"*":
headers:
response:
X-Consul-Default-Acl-Policy: ${fake.helpers.randomize(['allow', 'deny'])}

View File

@ -9,7 +9,10 @@ module('Integration | Serializer | dc', function(hooks) {
url: `/v1/catalog/datacenters`, url: `/v1/catalog/datacenters`,
}; };
return get(request.url).then(function(payload) { return get(request.url).then(function(payload) {
const expected = payload; const expected = {
body: payload,
headers: {},
};
const actual = serializer.respondForQuery(function(cb) { const actual = serializer.respondForQuery(function(cb) {
const headers = {}; const headers = {};
const body = payload; const body = payload;