fakecortex

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package fakecortex answers TheHive's Cortex job endpoint from memory, for unit tests of code that polls analyzer jobs. It is a package of its own so a tool package can use it from its internal tests: testutils imports the tools, and importing net/http directly makes bodyclose flag every SDK call in the package under test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Jobs

type Jobs struct {
	// contains filtered or unexported fields
}

Jobs answers each job's replies in turn, repeating the last one. A job it has no reply for is answered 404. It also answers the scope query TheHiveMCP runs before reading a job: every job is in scope unless OutOfScope says not.

func NewJobs

func NewJobs(replies map[string][]Reply) *Jobs

NewJobs returns a fake answering replies, keyed by job ID.

func (*Jobs) Client

func (j *Jobs) Client(t *testing.T) *thehive.APIClient

Client starts the fake and returns a TheHive client pointed at it.

func (*Jobs) OutOfScope

func (j *Jobs) OutOfScope(jobIDs ...string) *Jobs

OutOfScope makes the scope query exclude these jobs.

func (*Jobs) Reads

func (j *Jobs) Reads(jobID string) int

Reads reports how many times the job itself was read.

type Reply

type Reply struct {
	// contains filtered or unexported fields
}

Reply is one answer of the fake for a job.

func Hang

func Hang() Reply

Hang holds the request until the caller abandons it.

func Status

func Status(status string) Reply

Status answers with the job in that Cortex state, report included.

func Unavailable

func Unavailable() Reply

Unavailable answers 502, a failure worth asking again.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL