internal

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MockLagoonNumCalls int
View Source
var MockLagoonRequestBodies []string

Functions

func MockLagoonReset added in v0.2.2

func MockLagoonReset()

func MockLagoonServer added in v0.2.2

func MockLagoonServer() *httptest.Server

func MockRemoteInsightsServer added in v0.3.0

func MockRemoteInsightsServer(state *MockInsightsRemoteTestState) *httptest.Server

func ShellCommanderMaker

func ShellCommanderMaker(out *string, err error, generatedCommand *string) func(name string, arg ...string) command.IShellCommand

ShellCommanderMaker is a commander generator that can return the provided stdout or stderr, and can also update a given variable with the generated command.

func TestFetchData added in v0.3.0

func TestFetchData(t *testing.T, ctest FetchDataTest)

TestFetchData can be used to run test scenarios in test tables.

func TestRemediate added in v0.3.0

func TestRemediate(t *testing.T, rt RemediateTest)

TestRunCheck can be used to run test scenarios in test tables.

func TestRunCheck

func TestRunCheck(t *testing.T, ctest RunCheckTest)

TestRunCheck can be used to run test scenarios in test tables.

Types

type FetchDataTest added in v0.3.0

type FetchDataTest struct {
	// Name of the test.
	Name  string
	Check config.Check
	// Initialise the check before testing.
	Init bool
	// Func to run before running the check
	PreFetch func(t *testing.T)
	// Expected values after running the check.
	ExpectPasses   []string
	ExpectBreaches []result.Breach
	ExpectDataMap  map[string][]byte
}

FetchDataTest can be used to create test scenarios using test tables, for the FetchData method using TestFetchData below.

type MockInsightsRemoteTestState added in v0.3.0

type MockInsightsRemoteTestState struct {
	LastCallBody     string
	LastCallHeaders  map[string]string
	LastCallEndpoint string
	LastCallStatus   string
}

type RemediateTest added in v0.3.0

type RemediateTest struct {
	// Name of the test.
	Name     string
	Check    config.Check
	Breaches []result.Breach
	// Func to run before running Remediate
	PreRun func(t *testing.T)
	// Expected values after running Remediate.
	ExpectGeneratedCommand  string
	ExpectStatusFail        bool
	ExpectNoBreach          bool
	ExpectBreaches          []result.Breach
	ExpectRemediationStatus result.RemediationStatus
	ExpectNoRemediations    bool
	ExpectRemediations      []string
}

CheckTest can be used to create test scenarios, especially using test tables, for the RunCheck method using TestRunCheck below.

type RunCheckTest

type RunCheckTest struct {
	// Name of the test.
	Name  string
	Check config.Check
	// Initialise the check before testing.
	Init bool
	// Sort the results after running the check.
	Sort bool
	// Func to run before running the check
	PreRun func(t *testing.T)
	// Expected values after running the check.
	ExpectStatus result.Status
	ExpectNoPass bool
	ExpectPasses []string
	ExpectNoFail bool
	ExpectFails  []result.Breach
}

CheckTest can be used to create test scenarios, especially using test tables, for the RunCheck method using TestRunCheck below.

type TestShellCommand

type TestShellCommand struct {
	OutputterFunc func() ([]byte, error)
}

func (TestShellCommand) Output

func (sc TestShellCommand) Output() ([]byte, error)

Jump to

Keyboard shortcuts

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