- {{#if (gt items.length 0)}}
- No ACLs found
- {{else}}
- Welcome to ACLs
- {{/if}}
-
-
-
-
- {{#if (gt items.length 0)}}
- No ACLs where found matching that search, or you may not have access to view the ACLs you are searching for.
- {{else}}
- There don't seem to be any ACLs yet, or you may not have access to view ACLs yet.
- {{/if}}
-
-
-
-
-
-
-
-
- {{/let}}
+ {{did-insert (route-action 'replaceWith' 'dc.acls.tokens')}}
diff --git a/ui/packages/consul-ui/app/utils/acls-status.js b/ui/packages/consul-ui/app/utils/acls-status.js
deleted file mode 100644
index acc34dc59..000000000
--- a/ui/packages/consul-ui/app/utils/acls-status.js
+++ /dev/null
@@ -1,64 +0,0 @@
-// This is used by all acl routes to check whether
-// acls are enabled on the server, and whether the user
-// has a valid token
-// Right now this is very acl specific, but is likely to be
-// made a bit more less specific
-
-export default function(isValidServerError, P = Promise) {
- return function(obj) {
- const propName = Object.keys(obj)[0];
- const p = obj[propName];
- let authorize;
- let enable;
- return {
- isAuthorized: new P(function(resolve) {
- authorize = function(bool) {
- resolve(bool);
- };
- }),
- isEnabled: new P(function(resolve) {
- enable = function(bool) {
- resolve(bool);
- };
- }),
- [propName]: p
- .catch(function(e) {
- if (e.errors && e.errors[0]) {
- switch (e.errors[0].status) {
- case '500':
- if (isValidServerError(e)) {
- enable(true);
- authorize(false);
- } else {
- enable(false);
- authorize(false);
- return P.reject(e);
- }
- break;
- case '403':
- enable(true);
- authorize(false);
- break;
- case '401':
- enable(false);
- authorize(false);
- break;
- default:
- enable(false);
- authorize(false);
- throw e;
- }
- return [];
- }
- enable(false);
- authorize(false);
- throw e;
- })
- .then(function(res) {
- enable(true);
- authorize(true);
- return res;
- }),
- };
- };
-}
diff --git a/ui/packages/consul-ui/app/utils/http/acl/is-valid-server-error.js b/ui/packages/consul-ui/app/utils/http/acl/is-valid-server-error.js
deleted file mode 100644
index 2c1dcb67f..000000000
--- a/ui/packages/consul-ui/app/utils/http/acl/is-valid-server-error.js
+++ /dev/null
@@ -1,12 +0,0 @@
-// very specific error check just for one specific ACL case
-// likely to be reused at a later date, so lets use the specific
-// case we need right now as default
-const UNKNOWN_METHOD_ERROR = "rpc error making call: rpc: can't find method ACL";
-export default function(response = UNKNOWN_METHOD_ERROR) {
- return function(e) {
- if (e && e.errors && e.errors[0] && e.errors[0].detail) {
- return e.errors[0].detail.indexOf(response) !== -1;
- }
- return false;
- };
-}
diff --git a/ui/packages/consul-ui/app/validations/acl.js b/ui/packages/consul-ui/app/validations/acl.js
deleted file mode 100644
index 5878e768e..000000000
--- a/ui/packages/consul-ui/app/validations/acl.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import { validatePresence, validateLength } from 'ember-changeset-validations/validators';
-export default {
- Name: [validatePresence(true), validateLength({ min: 1 })],
- Type: validatePresence(true),
-};
diff --git a/ui/packages/consul-ui/ember-cli-build.js b/ui/packages/consul-ui/ember-cli-build.js
index cd993ed90..0ede17347 100644
--- a/ui/packages/consul-ui/ember-cli-build.js
+++ b/ui/packages/consul-ui/ember-cli-build.js
@@ -163,6 +163,9 @@ module.exports = function(defaults, $ = process.env) {
app.import('vendor/metrics-providers/prometheus.js', {
outputFile: 'assets/metrics-providers/prometheus.js',
});
+ app.import('vendor/acls/routes.js', {
+ outputFile: 'assets/acls/routes.js',
+ });
app.import('vendor/init.js', {
outputFile: 'assets/init.js',
});
diff --git a/ui/packages/consul-ui/lib/startup/templates/body.html.js b/ui/packages/consul-ui/lib/startup/templates/body.html.js
index 975cbd650..cafa6fb7c 100644
--- a/ui/packages/consul-ui/lib/startup/templates/body.html.js
+++ b/ui/packages/consul-ui/lib/startup/templates/body.html.js
@@ -41,6 +41,26 @@ ${environment === 'production' ? `{{jsonEncode .}}` : JSON.stringify(config.oper
"codemirror/mode/yaml/yaml.js": "${rootURL}assets/codemirror/mode/yaml/yaml.js"
}
+${
+ environment === 'production'
+ ? `
+{{if .ACLsEnabled}}
+
+{{end}}
+`
+ : `
+
+`
+}
${environment === 'test' ? `` : ``}
diff --git a/ui/packages/consul-ui/package.json b/ui/packages/consul-ui/package.json
index 35c17e2f9..a4e9383c3 100644
--- a/ui/packages/consul-ui/package.json
+++ b/ui/packages/consul-ui/package.json
@@ -85,6 +85,7 @@
"d3-selection": "^2.0.0",
"d3-shape": "^2.0.0",
"dayjs": "^1.9.3",
+ "deepmerge": "^4.2.2",
"ember-assign-helper": "^0.3.0",
"ember-auto-import": "^1.5.3",
"ember-can": "^3.0.0",
diff --git a/ui/packages/consul-ui/server/index.js b/ui/packages/consul-ui/server/index.js
index a2abdb55e..7b0bec453 100644
--- a/ui/packages/consul-ui/server/index.js
+++ b/ui/packages/consul-ui/server/index.js
@@ -29,7 +29,7 @@ module.exports = function(app, options) {
// sets the base CSP policy for the UI
app.use(function(request, response, next) {
response.set({
- 'Content-Security-Policy': `default-src 'self' ws: localhost:${options.liveReloadPort} http: localhost:${options.liveReloadPort}; img-src 'self' data: ; style-src 'self' 'unsafe-inline'`,
+ 'Content-Security-Policy': `default-src 'self' 'unsafe-inline' ws: localhost:${options.liveReloadPort} http: localhost:${options.liveReloadPort}; img-src 'self' data: ; style-src 'self' 'unsafe-inline'`,
});
next();
});
diff --git a/ui/packages/consul-ui/tests/integration/adapters/acl-test.js b/ui/packages/consul-ui/tests/integration/adapters/acl-test.js
deleted file mode 100644
index 398292bff..000000000
--- a/ui/packages/consul-ui/tests/integration/adapters/acl-test.js
+++ /dev/null
@@ -1,106 +0,0 @@
-import { module, test } from 'qunit';
-import { setupTest } from 'ember-qunit';
-module('Integration | Adapter | acl', function(hooks) {
- setupTest(hooks);
- const dc = 'dc-1';
- const id = 'token-name';
- test('requestForQuery returns the correct url', function(assert) {
- const adapter = this.owner.lookup('adapter:acl');
- const client = this.owner.lookup('service:client/http');
- const request = client.url.bind(client);
- const expected = `GET /v1/acl/list?dc=${dc}`;
- const actual = adapter.requestForQuery(request, {
- dc: dc,
- });
- assert.equal(actual, expected);
- });
- test('requestForQueryRecord returns the correct url', function(assert) {
- const adapter = this.owner.lookup('adapter:acl');
- const client = this.owner.lookup('service:client/http');
- const request = client.url.bind(client);
- const expected = `GET /v1/acl/info/${id}?dc=${dc}`;
- const actual = adapter.requestForQueryRecord(request, {
- dc: dc,
- id: id,
- });
- assert.equal(actual, expected);
- });
- test("requestForQueryRecord throws if you don't specify an id", function(assert) {
- const adapter = this.owner.lookup('adapter:acl');
- const client = this.owner.lookup('service:client/http');
- const request = client.url.bind(client);
- assert.throws(function() {
- adapter.requestForQueryRecord(request, {
- dc: dc,
- });
- });
- });
- test('requestForCreateRecord returns the correct url', function(assert) {
- const adapter = this.owner.lookup('adapter:acl');
- const client = this.owner.lookup('service:client/http');
- const request = client.url.bind(client);
- const expected = `PUT /v1/acl/create?dc=${dc}`;
- const actual = adapter
- .requestForCreateRecord(
- request,
- {},
- {
- Datacenter: dc,
- ID: id,
- }
- )
- .split('\n')[0];
- assert.equal(actual, expected);
- });
- test('requestForUpdateRecord returns the correct url', function(assert) {
- const adapter = this.owner.lookup('adapter:acl');
- const client = this.owner.lookup('service:client/http');
- const request = client.url.bind(client);
- const expected = `PUT /v1/acl/update?dc=${dc}`;
- const actual = adapter
- .requestForUpdateRecord(
- request,
- {},
- {
- Datacenter: dc,
- ID: id,
- }
- )
- .split('\n')[0];
- assert.equal(actual, expected);
- });
- test('requestForDeleteRecord returns the correct url', function(assert) {
- const adapter = this.owner.lookup('adapter:acl');
- const client = this.owner.lookup('service:client/http');
- const request = client.url.bind(client);
- const expected = `PUT /v1/acl/destroy/${id}?dc=${dc}`;
- const actual = adapter
- .requestForDeleteRecord(
- request,
- {},
- {
- Datacenter: dc,
- ID: id,
- }
- )
- .split('/n')[0];
- assert.equal(actual, expected);
- });
- test('requestForCloneRecord returns the correct url', function(assert) {
- const adapter = this.owner.lookup('adapter:acl');
- const client = this.owner.lookup('service:client/http');
- const request = client.url.bind(client);
- const expected = `PUT /v1/acl/clone/${id}?dc=${dc}`;
- const actual = adapter
- .requestForCloneRecord(
- request,
- {},
- {
- Datacenter: dc,
- ID: id,
- }
- )
- .split('\n')[0];
- assert.equal(actual, expected);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/adapters/acl-test.js b/ui/packages/consul-ui/tests/unit/adapters/acl-test.js
deleted file mode 100644
index faccc4787..000000000
--- a/ui/packages/consul-ui/tests/unit/adapters/acl-test.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import { module, test } from 'qunit';
-import { setupTest } from 'ember-qunit';
-
-module('Unit | Adapter | acl', function(hooks) {
- setupTest(hooks);
-
- // Replace this with your real tests.
- test('it exists', function(assert) {
- let adapter = this.owner.lookup('adapter:acl');
- assert.ok(adapter);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/controllers/dc/acls/create-test.js b/ui/packages/consul-ui/tests/unit/controllers/dc/acls/create-test.js
deleted file mode 100644
index adb0e65b7..000000000
--- a/ui/packages/consul-ui/tests/unit/controllers/dc/acls/create-test.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import { module, test } from 'qunit';
-import { setupTest } from 'ember-qunit';
-
-module('Unit | Controller | dc/acls/create', function(hooks) {
- setupTest(hooks);
-
- // Replace this with your real tests.
- test('it exists', function(assert) {
- let controller = this.owner.lookup('controller:dc/acls/create');
- assert.ok(controller);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/controllers/dc/acls/edit-test.js b/ui/packages/consul-ui/tests/unit/controllers/dc/acls/edit-test.js
deleted file mode 100644
index cd0135ee6..000000000
--- a/ui/packages/consul-ui/tests/unit/controllers/dc/acls/edit-test.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import { module, test } from 'qunit';
-import { setupTest } from 'ember-qunit';
-
-module('Unit | Controller | dc/acls/edit', function(hooks) {
- setupTest(hooks);
-
- // Replace this with your real tests.
- test('it exists', function(assert) {
- let controller = this.owner.lookup('controller:dc/acls/edit');
- assert.ok(controller);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/mixins/acl/with-actions-test.js b/ui/packages/consul-ui/tests/unit/mixins/acl/with-actions-test.js
deleted file mode 100644
index 137e79083..000000000
--- a/ui/packages/consul-ui/tests/unit/mixins/acl/with-actions-test.js
+++ /dev/null
@@ -1,75 +0,0 @@
-import { module } from 'qunit';
-import { setupTest } from 'ember-qunit';
-import test from 'ember-sinon-qunit/test-support/test';
-import Service from '@ember/service';
-import Route from 'consul-ui/routes/dc/acls/index';
-
-import Mixin from 'consul-ui/mixins/acl/with-actions';
-
-module('Unit | Mixin | acl/with actions', function(hooks) {
- setupTest(hooks);
-
- hooks.beforeEach(function() {
- this.subject = function() {
- const MixedIn = Route.extend(Mixin);
- this.owner.register('test-container:acl/with-actions-object', MixedIn);
- return this.owner.lookup('test-container:acl/with-actions-object');
- };
- });
-
- // Replace this with your real tests.
- test('it works', function(assert) {
- const subject = this.subject();
- assert.ok(subject);
- });
- test('use persists the token', function(assert) {
- assert.expect(2);
- const item = { ID: 'id' };
- const expected = { Namespace: 'default', AccessorID: null, SecretID: item.ID };
- this.owner.register(
- 'service:settings',
- Service.extend({
- persist: function(actual) {
- assert.deepEqual(actual.token, expected);
- return Promise.resolve(actual);
- },
- })
- );
- const subject = this.subject();
- return subject.actions.use
- .bind(subject)(item)
- .then(function(actual) {
- assert.deepEqual(actual.token, expected);
- });
- });
- test('clone clones the token and calls afterDelete correctly', function(assert) {
- assert.expect(4);
- this.owner.register(
- 'service:feedback',
- Service.extend({
- execute: function(cb, name) {
- assert.equal(name, 'clone');
- return cb();
- },
- })
- );
- const expected = { ID: 'id' };
- this.owner.register(
- 'service:repository/acl',
- Service.extend({
- clone: function(actual) {
- assert.deepEqual(actual, expected);
- return Promise.resolve(actual);
- },
- })
- );
- const subject = this.subject();
- const afterDelete = this.stub(subject, 'afterDelete').returnsArg(0);
- return subject.actions.clone
- .bind(subject)(expected)
- .then(function(actual) {
- assert.ok(afterDelete.calledOnce);
- assert.equal(actual, expected);
- });
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/models/acl-test.js b/ui/packages/consul-ui/tests/unit/models/acl-test.js
deleted file mode 100644
index 24df7d51e..000000000
--- a/ui/packages/consul-ui/tests/unit/models/acl-test.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import { module, test } from 'qunit';
-import { setupTest } from 'ember-qunit';
-import { run } from '@ember/runloop';
-
-module('Unit | Model | acl', function(hooks) {
- setupTest(hooks);
-
- // Replace this with your real tests.
- test('it exists', function(assert) {
- let store = this.owner.lookup('service:store');
- let model = run(() => store.createRecord('acl', {}));
- assert.ok(model);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/routes/dc/acls-test.js b/ui/packages/consul-ui/tests/unit/routes/dc/acls-test.js
deleted file mode 100644
index a455e74a2..000000000
--- a/ui/packages/consul-ui/tests/unit/routes/dc/acls-test.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { module, test } from 'qunit';
-import { setupTest } from 'ember-qunit';
-
-module('Unit | Route | dc/acls', function(hooks) {
- setupTest(hooks);
-
- test('it exists', function(assert) {
- let route = this.owner.lookup('route:dc/acls');
- assert.ok(route);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/routes/dc/acls/create-test.js b/ui/packages/consul-ui/tests/unit/routes/dc/acls/create-test.js
deleted file mode 100644
index a2159a044..000000000
--- a/ui/packages/consul-ui/tests/unit/routes/dc/acls/create-test.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { module, test } from 'qunit';
-import { setupTest } from 'ember-qunit';
-
-module('Unit | Route | dc/acls/create', function(hooks) {
- setupTest(hooks);
-
- test('it exists', function(assert) {
- let route = this.owner.lookup('route:dc/acls/create');
- assert.ok(route);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/routes/dc/acls/edit-test.js b/ui/packages/consul-ui/tests/unit/routes/dc/acls/edit-test.js
deleted file mode 100644
index 024529fd9..000000000
--- a/ui/packages/consul-ui/tests/unit/routes/dc/acls/edit-test.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { module, test } from 'qunit';
-import { setupTest } from 'ember-qunit';
-
-module('Unit | Route | dc/acls/edit', function(hooks) {
- setupTest(hooks);
-
- test('it exists', function(assert) {
- let route = this.owner.lookup('route:dc/acls/edit');
- assert.ok(route);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/routes/dc/acls/index-test.js b/ui/packages/consul-ui/tests/unit/routes/dc/acls/index-test.js
deleted file mode 100644
index 9bd559be0..000000000
--- a/ui/packages/consul-ui/tests/unit/routes/dc/acls/index-test.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { module, test } from 'qunit';
-import { setupTest } from 'ember-qunit';
-
-module('Unit | Route | dc/acls/index', function(hooks) {
- setupTest(hooks);
-
- test('it exists', function(assert) {
- let route = this.owner.lookup('route:dc/acls/index');
- assert.ok(route);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/search/predicates/acl-test.js b/ui/packages/consul-ui/tests/unit/search/predicates/acl-test.js
deleted file mode 100644
index dcadd5cae..000000000
--- a/ui/packages/consul-ui/tests/unit/search/predicates/acl-test.js
+++ /dev/null
@@ -1,43 +0,0 @@
-import { module, test } from 'qunit';
-
-import ExactSearch from 'consul-ui/utils/search/exact';
-import predicates from 'consul-ui/search/predicates/acl';
-
-module('Unit | Search | Predicate | acl', function() {
- test('items are found by properties', function(assert) {
- const actual = new ExactSearch(
- [
- {
- ID: 'HIT-id',
- Name: 'name',
- },
- {
- ID: 'id',
- Name: 'name',
- },
- {
- ID: 'id',
- Name: 'name-HIT',
- },
- ],
- {
- finders: predicates,
- }
- ).search('hit');
- assert.equal(actual.length, 2);
- });
- test('items are not found', function(assert) {
- const actual = new ExactSearch(
- [
- {
- ID: 'id',
- Name: 'name',
- },
- ],
- {
- finders: predicates,
- }
- ).search('hit');
- assert.equal(actual.length, 0);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/serializers/acl-test.js b/ui/packages/consul-ui/tests/unit/serializers/acl-test.js
deleted file mode 100644
index ee548017f..000000000
--- a/ui/packages/consul-ui/tests/unit/serializers/acl-test.js
+++ /dev/null
@@ -1,24 +0,0 @@
-import { module, test } from 'qunit';
-import { setupTest } from 'ember-qunit';
-import { run } from '@ember/runloop';
-
-module('Unit | Serializer | acl', function(hooks) {
- setupTest(hooks);
-
- // Replace this with your real tests.
- test('it exists', function(assert) {
- let store = this.owner.lookup('service:store');
- let serializer = store.serializerFor('acl');
-
- assert.ok(serializer);
- });
-
- test('it serializes records', function(assert) {
- let store = this.owner.lookup('service:store');
- let record = run(() => store.createRecord('acl', {}));
-
- let serializedRecord = record.serialize();
-
- assert.ok(serializedRecord);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/services/repository/acl-test.js b/ui/packages/consul-ui/tests/unit/services/repository/acl-test.js
deleted file mode 100644
index 470764ec0..000000000
--- a/ui/packages/consul-ui/tests/unit/services/repository/acl-test.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import { module, test } from 'qunit';
-import { setupTest } from 'ember-qunit';
-
-module('Unit | Service | acl', function(hooks) {
- setupTest(hooks);
-
- // Replace this with your real tests.
- test('it exists', function(assert) {
- let service = this.owner.lookup('service:repository/acl');
- assert.ok(service);
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/utils/acls-status-test.js b/ui/packages/consul-ui/tests/unit/utils/acls-status-test.js
deleted file mode 100644
index 2034b5d69..000000000
--- a/ui/packages/consul-ui/tests/unit/utils/acls-status-test.js
+++ /dev/null
@@ -1,89 +0,0 @@
-import { module } from 'qunit';
-import test from 'ember-sinon-qunit/test-support/test';
-import aclsStatus from 'consul-ui/utils/acls-status';
-
-module('Unit | Utility | acls status', function() {
- test('it rejects and nothing is enabled or authorized', function(assert) {
- const isValidServerError = this.stub().returns(false);
- const status = aclsStatus(isValidServerError);
- [
- this.stub().rejects(),
- this.stub().rejects({ errors: [] }),
- this.stub().rejects({ errors: [{ status: '404' }] }),
- ].forEach(function(reject) {
- const actual = status({
- response: reject(),
- });
- assert.rejects(actual.response);
- ['isAuthorized', 'isEnabled'].forEach(function(prop) {
- actual[prop].then(function(actual) {
- assert.notOk(actual);
- });
- });
- });
- });
- test('with a 401 it resolves with an empty array and nothing is enabled or authorized', function(assert) {
- assert.expect(3);
- const isValidServerError = this.stub().returns(false);
- const status = aclsStatus(isValidServerError);
- const actual = status({
- response: this.stub().rejects({ errors: [{ status: '401' }] })(),
- });
- actual.response.then(function(actual) {
- assert.deepEqual(actual, []);
- });
- ['isAuthorized', 'isEnabled'].forEach(function(prop) {
- actual[prop].then(function(actual) {
- assert.notOk(actual);
- });
- });
- });
- test("with a 403 it resolves with an empty array and it's enabled but not authorized", function(assert) {
- assert.expect(3);
- const isValidServerError = this.stub().returns(false);
- const status = aclsStatus(isValidServerError);
- const actual = status({
- response: this.stub().rejects({ errors: [{ status: '403' }] })(),
- });
- actual.response.then(function(actual) {
- assert.deepEqual(actual, []);
- });
- actual.isEnabled.then(function(actual) {
- assert.ok(actual);
- });
- actual.isAuthorized.then(function(actual) {
- assert.notOk(actual);
- });
- });
- test("with a 500 (but not a 'valid' error) it rejects and nothing is enabled or authorized", function(assert) {
- assert.expect(3);
- const isValidServerError = this.stub().returns(false);
- const status = aclsStatus(isValidServerError);
- const actual = status({
- response: this.stub().rejects({ errors: [{ status: '500' }] })(),
- });
- assert.rejects(actual.response);
- ['isAuthorized', 'isEnabled'].forEach(function(prop) {
- actual[prop].then(function(actual) {
- assert.notOk(actual);
- });
- });
- });
- test("with a 500 and a 'valid' error, it resolves with an empty array and it's enabled but not authorized", function(assert) {
- assert.expect(3);
- const isValidServerError = this.stub().returns(true);
- const status = aclsStatus(isValidServerError);
- const actual = status({
- response: this.stub().rejects({ errors: [{ status: '500' }] })(),
- });
- actual.response.then(function(actual) {
- assert.deepEqual(actual, []);
- });
- actual.isEnabled.then(function(actual) {
- assert.ok(actual);
- });
- actual.isAuthorized.then(function(actual) {
- assert.notOk(actual);
- });
- });
-});
diff --git a/ui/packages/consul-ui/tests/unit/utils/http/acl/is-valid-server-error-test.js b/ui/packages/consul-ui/tests/unit/utils/http/acl/is-valid-server-error-test.js
deleted file mode 100644
index c1297598c..000000000
--- a/ui/packages/consul-ui/tests/unit/utils/http/acl/is-valid-server-error-test.js
+++ /dev/null
@@ -1,49 +0,0 @@
-import createIsValidServerError from 'consul-ui/utils/http/acl/is-valid-server-error';
-import { module, test } from 'qunit';
-
-module('Unit | Utility | http/acl/is valid server error', function() {
- const createEmberDataError = function(response) {
- return {
- errors: [
- {
- detail: response,
- },
- ],
- };
- };
- test('it returns a function', function(assert) {
- const isValidServerError = createIsValidServerError();
- assert.ok(typeof isValidServerError === 'function');
- });
- test("it returns false if there is no 'correctly' formatted error", function(assert) {
- const isValidServerError = createIsValidServerError();
- assert.notOk(isValidServerError());
- assert.notOk(isValidServerError({}));
- assert.notOk(isValidServerError({ errors: {} }));
- assert.notOk(isValidServerError({ errors: [{}] }));
- assert.notOk(isValidServerError({ errors: [{ notDetail: '' }] }));
- });
- // don't go too crazy with these, just enough for sanity check, we are essentially testing indexOf
- test("it returns false if the response doesn't contain the exact error response", function(assert) {
- const isValidServerError = createIsValidServerError();
- [
- "pc error making call: rpc: can't find method ACL",
- "rpc error making call: rpc: can't find method",
- "rpc rror making call: rpc: can't find method ACL",
- ].forEach(function(response) {
- const e = createEmberDataError(response);
- assert.notOk(isValidServerError(e));
- });
- });
- test('it returns true if the response contains the exact error response', function(assert) {
- const isValidServerError = createIsValidServerError();
- [
- "rpc error making call: rpc: can't find method ACL",
- " rpc error making call: rpc: can't find method ACL",
- "rpc error making call: rpc: rpc error making call: rpc: rpc error making call: rpc: can't find method ACL",
- ].forEach(function(response) {
- const e = createEmberDataError(response);
- assert.ok(isValidServerError(e));
- });
- });
-});
diff --git a/ui/packages/consul-ui/vendor/acls/routes.js b/ui/packages/consul-ui/vendor/acls/routes.js
new file mode 100644
index 000000000..b553c9e93
--- /dev/null
+++ b/ui/packages/consul-ui/vendor/acls/routes.js
@@ -0,0 +1,15 @@
+(function(appNameJS = 'consulUi', doc = document) {
+ const scripts = doc.getElementsByTagName('script');
+ const script = scripts[scripts.length - 1];
+ script.dataset[`${appNameJS}Routes`] = JSON.stringify({
+ dc: {
+ acls: {
+ tokens: {
+ _options: {
+ abilities: ['read tokens'],
+ },
+ },
+ },
+ },
+ });
+})();
diff --git a/ui/yarn.lock b/ui/yarn.lock
index 7b5c435a6..75c5968df 100644
--- a/ui/yarn.lock
+++ b/ui/yarn.lock
@@ -5102,6 +5102,11 @@ deep-is@^0.1.3, deep-is@~0.1.3:
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=
+deepmerge@^4.2.2:
+ version "4.2.2"
+ resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955"
+ integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==
+
defaults@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"