Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Reset the system and refetch namespaces with every token change #8413

Merged
merged 2 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
BUG FIXES:

* ui: Fixed order of column headers in client allocations table. [[GH-8409](https://github.com/hashicorp/nomad/pull/8409)]
* ui: Fixed stale namespaces after changing acl tokens. [[GH-8413](https://github.com/hashicorp/nomad/issues/8413)]
* ui: Fixed missing namespace query param after changing acl tokens [[GH-8413](https://github.com/hashicorp/nomad/issues/8413)]
* vault: Fixed a bug where vault identity policies not considered in permissions check [[GH-7732](https://github.com/hashicorp/nomad/issues/7732)]

## 0.12.0 (July 9, 2020)
Expand Down
5 changes: 3 additions & 2 deletions ui/app/controllers/settings/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export default class Tokens extends Controller {
tokenIsValid: false,
tokenIsInvalid: false,
});
// Clear out all data to ensure only data the anonymous token is privileged to see is shown
this.system.reset();
this.resetStore();
this.token.reset();
}
Expand All @@ -44,8 +46,7 @@ export default class Tokens extends Controller {

TokenAdapter.findSelf().then(
() => {
// Clear out all data to ensure only data the new token is privileged to
// see is shown
// Clear out all data to ensure only data the new token is privileged to see is shown
this.system.reset();
this.resetStore();

Expand Down
1 change: 1 addition & 0 deletions ui/app/services/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,6 @@ export default class SystemService extends Service {

reset() {
this.set('activeNamespace', null);
this.notifyPropertyChange('namespaces');
}
}
2 changes: 1 addition & 1 deletion ui/app/templates/settings/tokens.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<p>Tokens are stored client-side in <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage">local storage</a>. This will persist your token across sessions. You can manually clear your token here.</p>
</div>
<div class="column is-centered is-minimum">
<button class="button is-info" {{action "clearTokenProperties"}} type="button">Clear Token</button>
<button data-test-token-clear class="button is-info" {{action "clearTokenProperties"}} type="button">Clear Token</button>
</div>
</div>
</div>
Expand Down
17 changes: 17 additions & 0 deletions ui/tests/acceptance/token-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@ module('Acceptance | tokens', function(hooks) {
assert.notOk(find('[data-test-job-row]'), 'No jobs found');
});

test('when namespaces are enabled, setting or clearing a token refetches namespaces available with new permissions', async function(assert) {
const { secretId } = clientToken;

server.createList('namespace', 2);
await Tokens.visit();

const requests = server.pretender.handledRequests;

assert.equal(requests.filter(req => req.url === '/v1/namespaces').length, 1);

await Tokens.secret(secretId).submit();
assert.equal(requests.filter(req => req.url === '/v1/namespaces').length, 2);

await Tokens.clear();
assert.equal(requests.filter(req => req.url === '/v1/namespaces').length, 3);
});

function getHeader({ requestHeaders }, name) {
// Headers are case-insensitive, but object property look up is not
return (
Expand Down
1 change: 1 addition & 0 deletions ui/tests/pages/settings/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default create({

secret: fillable('[data-test-token-secret]'),
submit: clickable('[data-test-token-submit]'),
clear: clickable('[data-test-token-clear]'),

errorMessage: isVisible('[data-test-token-error]'),
successMessage: isVisible('[data-test-token-success]'),
Expand Down