-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cce73f
commit 28cac79
Showing
111 changed files
with
9,176 additions
and
1,039 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* SPDX-FileCopyrightText: 2024 Greenbone AG | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import {describe, test, expect} from '@gsa/testing'; | ||
import {createHttp, createEntityResponse} from 'gmp/commands/testing'; | ||
import {AuditReportCommand} from 'gmp/commands/auditreports'; | ||
|
||
describe('AuditReportCommand tests', () => { | ||
test('should request single audit report', () => { | ||
const response = createEntityResponse('report', {_id: 'foo'}); | ||
const fakeHttp = createHttp(response); | ||
|
||
expect.hasAssertions(); | ||
|
||
const cmd = new AuditReportCommand(fakeHttp); | ||
return cmd.get({id: 'foo'}).then(resp => { | ||
expect(fakeHttp.request).toHaveBeenCalledWith('get', { | ||
args: { | ||
cmd: 'get_report', | ||
report_id: 'foo', | ||
ignore_pagination: 1, | ||
details: 1, | ||
lean: 1, | ||
}, | ||
}); | ||
|
||
const {data} = resp; | ||
expect(data.id).toEqual('foo'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* SPDX-FileCopyrightText: 2024 Greenbone AG | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import {describe, test, expect} from '@gsa/testing'; | ||
import {ALL_FILTER} from 'gmp/models/filter'; | ||
|
||
import { | ||
createHttp, | ||
createEntitiesResponse, | ||
createAggregatesResponse, | ||
} from '../testing'; | ||
import {AuditReportsCommand} from 'gmp/commands/auditreports'; | ||
|
||
describe('AuditReportsCommand tests', () => { | ||
test('should return all audit reports', () => { | ||
const response = createEntitiesResponse('report', [ | ||
{ | ||
_id: '1', | ||
}, | ||
{ | ||
_id: '2', | ||
}, | ||
]); | ||
|
||
const fakeHttp = createHttp(response); | ||
|
||
expect.hasAssertions(); | ||
|
||
const cmd = new AuditReportsCommand(fakeHttp); | ||
return cmd.getAll().then(resp => { | ||
expect(fakeHttp.request).toHaveBeenCalledWith('get', { | ||
args: { | ||
cmd: 'get_reports', | ||
details: 0, | ||
filter: ALL_FILTER.toFilterString(), | ||
usage_type: 'audit', | ||
}, | ||
}); | ||
const {data} = resp; | ||
expect(data.length).toEqual(2); | ||
}); | ||
}); | ||
|
||
test('should return results', () => { | ||
const response = createEntitiesResponse('report', [ | ||
{ | ||
_id: '1', | ||
}, | ||
{ | ||
_id: '2', | ||
}, | ||
]); | ||
|
||
const fakeHttp = createHttp(response); | ||
|
||
expect.hasAssertions(); | ||
|
||
const cmd = new AuditReportsCommand(fakeHttp); | ||
return cmd.get().then(resp => { | ||
expect(fakeHttp.request).toHaveBeenCalledWith('get', { | ||
args: { | ||
cmd: 'get_reports', | ||
details: 0, | ||
usage_type: 'audit', | ||
}, | ||
}); | ||
const {data} = resp; | ||
expect(data.length).toEqual(2); | ||
}); | ||
}); | ||
|
||
test('should aggregate compliance counts', () => { | ||
const response = createAggregatesResponse(); | ||
const fakeHttp = createHttp(response); | ||
|
||
expect.hasAssertions(); | ||
|
||
const cmd = new AuditReportsCommand(fakeHttp); | ||
return cmd.getComplianceAggregates().then(resp => { | ||
expect(fakeHttp.request).toHaveBeenCalledWith('get', { | ||
args: { | ||
cmd: 'get_aggregate', | ||
aggregate_type: 'report', | ||
group_column: 'compliant', | ||
usage_type: 'audit', | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.