Skip to content

Commit

Permalink
backport of UI: correctly call resultant-acl when user root is root (#…
Browse files Browse the repository at this point in the history
…25785)

Co-authored-by: Chelsea Shaw <[email protected]>
  • Loading branch information
1 parent 1d5f136 commit 6364acb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog/25766.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: call resultant-acl without namespace header when user mounted at root namespace
```
2 changes: 1 addition & 1 deletion ui/app/adapters/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ApplicationAdapter from './application';

export default ApplicationAdapter.extend({
query() {
const namespace = this.namespaceService.userRootNamespace || this.namespaceService.path;
const namespace = this.namespaceService.userRootNamespace ?? this.namespaceService.path;
return this.ajax(this.urlForQuery(), 'GET', { namespace });
},

Expand Down
25 changes: 25 additions & 0 deletions ui/tests/unit/adapters/permissions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,29 @@ module('Unit | Adapter | permissions', function (hooks) {
});
await adapter.query();
});
test('it calls resultant-acl with the users root namespace when root', async function (assert) {
assert.expect(1);
const adapter = this.owner.lookup('adapter:permissions');
const nsService = this.owner.lookup('service:namespace');
const auth = this.owner.lookup('service:auth');
nsService.setNamespace('admin');
auth.setCluster('1');
auth.set('tokens', ['vault-_root_☃1']);
auth.setTokenData('vault-_root_☃1', { userRootNamespace: '', backend: { mountPath: 'token' } });

this.server.get('/sys/internal/ui/resultant-acl', (schema, request) => {
assert.false(
Object.keys(request.requestHeaders).includes('X-Vault-Namespace'),
'request is called without namespace'
);

return {
data: {
exact_paths: {},
glob_paths: {},
},
};
});
await adapter.query();
});
});

0 comments on commit 6364acb

Please sign in to comment.