Skip to content
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
9 changes: 3 additions & 6 deletions src/gmp/commands/__tests__/entity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@ import {
import type Http from 'gmp/http/http';
import Response from 'gmp/http/response';
import {type XmlResponseData} from 'gmp/http/transform/fast-xml';
import {
type EntityModelElement,
type EntityModelProperties,
} from 'gmp/models/entity-model';
import {type EntityModelElement} from 'gmp/models/entity-model';
import Filter from 'gmp/models/filter';
import BaseFilter from 'gmp/models/filter/base-filter';
import Model from 'gmp/models/model';

type FooElement = EntityModelElement;
type FooProperties = EntityModelProperties;

class Foo extends Model {
static fromElement(element: FooElement): Foo {
return new Foo(element as FooProperties);
const ret = super.fromElement(element);
return new Foo(ret);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/gmp/commands/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ class AlertCommand extends EntityCommand<Alert> {
})) as Response<EditAlertElement>;
const {edit_alert} = response.data;
const editAlert: EditAlertSettings = {
// @ts-expect-error
alert: Alert.fromElement(edit_alert?.get_alerts_response?.alert),
report_formats: map(
edit_alert?.get_report_formats_response?.report_format,
Expand Down
15 changes: 10 additions & 5 deletions src/gmp/models/__tests__/agent-group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {describe, test, expect} from '@gsa/testing';
import AgentGroup from 'gmp/models/agent-group';
import {testModel} from 'gmp/models/testing';

testModel(AgentGroup, 'agentgroup');

describe('AgentGroup model tests', () => {
testModel(AgentGroup, 'agentgroup');

test('should use defaults', () => {
const agentGroup = new AgentGroup();
const agentGroup = new AgentGroup({id: '123'});

expect(agentGroup.id).toBeUndefined();
expect(agentGroup.id).toEqual('123');
expect(agentGroup.name).toBeUndefined();
expect(agentGroup.comment).toBeUndefined();
expect(agentGroup.scanner).toBeUndefined();
Expand All @@ -22,6 +22,7 @@ describe('AgentGroup model tests', () => {

test('should parse agents', () => {
const agentGroup = AgentGroup.fromElement({
_id: '123',
agents: {
agent: [
{
Expand Down Expand Up @@ -50,6 +51,7 @@ describe('AgentGroup model tests', () => {

test('should parse single agent', () => {
const agentGroup = AgentGroup.fromElement({
_id: '123',
agents: {
agent: {
_id: '6b9ac61f-ffff-0000-1111-223344556677',
Expand All @@ -68,20 +70,22 @@ describe('AgentGroup model tests', () => {

test('should handle empty agents element', () => {
const agentGroup = AgentGroup.fromElement({
_id: '123',
agents: {},
});

expect(agentGroup.agents).toEqual([]);
});

test('should handle missing agents element', () => {
const agentGroup = AgentGroup.fromElement();
const agentGroup = AgentGroup.fromElement({_id: '123'});

expect(agentGroup.agents).toEqual([]);
});

test('should parse scanner', () => {
const agentGroup = AgentGroup.fromElement({
_id: '123',
scanner: {
_id: '3b4be213-281f-49ee-b457-5a5f34f71510',
name: 'Agent Controller',
Expand All @@ -97,6 +101,7 @@ describe('AgentGroup model tests', () => {

test('should parse scheduler cron time', () => {
const agentGroup = AgentGroup.fromElement({
_id: '123',
scheduler_cron_time: '0 0 * * *',
});

Expand Down
9 changes: 7 additions & 2 deletions src/gmp/models/__tests__/agent-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ describe('AgentInstaller model tests', () => {
testModel(AgentInstaller, 'agentinstaller');

test('should use defaults', () => {
const agentInstaller = new AgentInstaller();
const agentInstaller = new AgentInstaller({id: '123'});

expect(agentInstaller.id).toBeUndefined();
expect(agentInstaller.id).toEqual('123');
expect(agentInstaller.name).toBeUndefined();
expect(agentInstaller.comment).toBeUndefined();
expect(agentInstaller.description).toBeUndefined();
Expand All @@ -26,6 +26,7 @@ describe('AgentInstaller model tests', () => {

test('should parse contentType', () => {
const agentInstaller = AgentInstaller.fromElement({
_id: '123',
content_type: 'application/octet-stream',
});

Expand All @@ -34,6 +35,7 @@ describe('AgentInstaller model tests', () => {

test('should parse description', () => {
const agentInstaller = AgentInstaller.fromElement({
_id: '123',
description: 'This is a test agent installer.',
});

Expand All @@ -42,6 +44,7 @@ describe('AgentInstaller model tests', () => {

test('should parse fileExtension', () => {
const agentInstaller = AgentInstaller.fromElement({
_id: '123',
file_extension: '.exe',
});

Expand All @@ -50,6 +53,7 @@ describe('AgentInstaller model tests', () => {

test('should parse version', () => {
const agentInstaller = AgentInstaller.fromElement({
_id: '123',
version: '1.0.0',
});

Expand All @@ -58,6 +62,7 @@ describe('AgentInstaller model tests', () => {

test('should parse checksum', () => {
const agentInstaller = AgentInstaller.fromElement({
_id: '123',
checksum: 'abc123',
});

Expand Down
Loading
Loading