mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
New test coverage for 403 handling on list pages
This commit is contained in:
@@ -139,3 +139,23 @@ test('when the namespace query param is set, only matching jobs are shown and th
|
||||
assert.equal(find('.job-row td').textContent, job2.name, 'The correct job is shown');
|
||||
});
|
||||
});
|
||||
|
||||
test('when accessing jobs is forbidden, show a message with a link to the tokens page', function(
|
||||
assert
|
||||
) {
|
||||
server.pretender.get('/v1/jobs', () => [403, {}, null]);
|
||||
|
||||
visit('/jobs');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(find('.empty-message-headline').textContent, 'Not Authorized');
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
click('.empty-message-body a');
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(currentURL(), '/settings/tokens');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -104,6 +104,28 @@ test('when there are clients, but no matches for a search term, there is an empt
|
||||
});
|
||||
});
|
||||
|
||||
test('when accessing clients is forbidden, show a message with a link to the tokens page', function(
|
||||
assert
|
||||
) {
|
||||
server.create('agent');
|
||||
server.create('node', { name: 'node' });
|
||||
server.pretender.get('/v1/nodes', () => [403, {}, null]);
|
||||
|
||||
visit('/nodes');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(find('.empty-message-headline').textContent, 'Not Authorized');
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
click('.empty-message-body a');
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(currentURL(), '/settings/tokens');
|
||||
});
|
||||
});
|
||||
|
||||
test('/servers should list all servers', function(assert) {
|
||||
const agentsCount = 10;
|
||||
const pageSize = 8;
|
||||
@@ -191,3 +213,24 @@ test('when the API returns no agents, show an empty message', function(assert) {
|
||||
assert.equal(find('.empty-message-headline').textContent, 'Invalid Permissions');
|
||||
});
|
||||
});
|
||||
|
||||
test('when accessing servers is forbidden, show a message with a link to the tokens page', function(
|
||||
assert
|
||||
) {
|
||||
server.create('agent');
|
||||
server.pretender.get('/v1/agent/members', () => [403, {}, null]);
|
||||
|
||||
visit('/servers');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(find('.empty-message-headline').textContent, 'Not Authorized');
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
click('.empty-message-body a');
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(currentURL(), '/settings/tokens');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user