Skip to content

Commit

Permalink
Incorporate ssh elevate credential into target tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saberlynx committed Jun 29, 2021
1 parent 095ed6a commit 7a4fb3a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
42 changes: 41 additions & 1 deletion gsa/src/web/pages/targets/__tests__/detailspage.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,31 @@ const target = Target.fromElement({
alive_tests: 'Scan Config Default',
allow_simultaneous_ips: 1,
port_range: '1-5',
ssh_credential: {
_id: '1235',
name: 'ssh',
port: '22',
trash: '0',
},
ssh_elevate_credential: {
_id: '3456',
name: 'ssh_elevate',
trash: '0',
},
smb_credential: {
_id: '4784',
name: 'smb_credential',
},
esxi_credential: {
_id: '',
name: '',
trash: '0',
},
snmp_credential: {
_id: '',
name: '',
trash: '0',
},
});

const targetInUse = Target.fromElement({
Expand Down Expand Up @@ -222,8 +247,23 @@ describe('Target Detailspage tests', () => {
expect(links[2]).toHaveAttribute('href', '/portlist/32323');
expect(element).toHaveTextContent('All IANA assigned TCP');

expect(element).toHaveTextContent('Credentials');

expect(element).toHaveTextContent('SSH');
expect(element).toHaveTextContent('ssh');
expect(links[3]).toHaveAttribute('href', '/credential/1235');
expect(element).toHaveTextContent('on Port 22');

expect(element).toHaveTextContent('SSH elevate credential');
expect(element).toHaveTextContent('ssh_elevate');
expect(links[4]).toHaveAttribute('href', '/credential/3456');

expect(element).toHaveTextContent('SMB');
expect(element).toHaveTextContent('smb_credential');
expect(links[5]).toHaveAttribute('href', '/credential/4784');

expect(element).toHaveTextContent('Tasks using this Target (1)');
expect(links[3]).toHaveAttribute('href', '/task/465');
expect(links[6]).toHaveAttribute('href', '/task/465');
expect(element).toHaveTextContent('foo');
});

Expand Down
18 changes: 16 additions & 2 deletions gsa/src/web/pages/targets/__tests__/listpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ const target = Target.fromElement({
alive_tests: 'Scan Config Default',
allow_simultaneous_ips: 1,
port_range: '1-5',
ssh_credential: {
_id: '1235',
name: 'ssh',
port: '22',
trash: '0',
},
ssh_elevate_credential: {
_id: '3456',
name: 'ssh_elevate',
trash: '0',
},
});

const caps = new Capabilities(['everything']);
Expand Down Expand Up @@ -190,6 +201,9 @@ describe('TargetPage tests', () => {
expect(row[1]).toHaveTextContent('2');
expect(row[1]).toHaveTextContent('All IANA assigned TCP');

expect(row[1]).toHaveTextContent('SSH: ssh');
expect(row[1]).toHaveTextContent('SSH Elevate: ssh_elevate');

expect(
screen.getAllByTitle('Move Target to trashcan')[0],
).toBeInTheDocument();
Expand Down Expand Up @@ -273,7 +287,7 @@ describe('TargetPage tests', () => {
expect(deleteByFilter).toHaveBeenCalled();
});

test.skip('should allow to bulk action on selected targets', async () => {
test('should allow to bulk action on selected targets', async () => {
// mock cache issues will cause these tests to randomly fail. Will fix later.
const deleteByIds = jest.fn().mockResolvedValue({
foo: 'bar',
Expand Down Expand Up @@ -365,7 +379,7 @@ describe('TargetPage tests', () => {
expect(deleteByIds).toHaveBeenCalled();
});

test.skip('should allow to bulk action on filtered targets', async () => {
test('should allow to bulk action on filtered targets', async () => {
// mock cache issues will cause these tests to randomly fail. Will fix later.
const deleteByFilter = jest.fn().mockResolvedValue({
foo: 'bar',
Expand Down

0 comments on commit 7a4fb3a

Please sign in to comment.