c2test

package
v0.0.0-...-0e2b5c9 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckC2Online

func CheckC2Online(addr string, grpcPort int, httpPort int) bool

CheckC2Online is a quick function to wait until the C2 is online It does this by defining the C2 online as when both GRPC and HTTP APIs are up and accepting connections. TODO: We might want to formally define some way to deduce if the C2 is loaded, for example by a GRPC request So that all services and any backend initialization is ready.

func GRPCApi

func GRPCApi(ctx context.Context, resChan chan<- TestResult, grpcClient pb.C2Client)

GRPCApi tests the GRPC api of the C2

func GenerateID

func GenerateID() ([]byte, error)

GenerateID generates a random ID that is e4.IDLen bytes in length, using a CSPRNG

func GenerateKey

func GenerateKey() ([]byte, error)

GenerateKey generates a random key that is e4.KeyLen bytes in length, using a CSPRNG

func GenerateName

func GenerateName() (string, error)

GenerateName generates a random name beginning clientname-%s it is used to make random-looking names for devices for test purposes.

func GenerateTopic

func GenerateTopic() (string, error)

GenerateTopic generates a random topic

func GetRandomDBName

func GetRandomDBName() string

GetRandomDBName returns a random database filepath to be used with sqlite driver

func HTTPApi

func HTTPApi(resChan chan<- TestResult, httpClient *http.Client, host string)

HTTPApi tests the http api of the C2

func NewTestingGRPCClient

func NewTestingGRPCClient(relativeCertPath string, serverAddr string) (pb.C2Client, func() error, error)

NewTestingGRPCClient returns a new GRPC client to use for testing

func NewTestingHTTPClient

func NewTestingHTTPClient() *http.Client

NewTestingHTTPClient Create a new http client for testing

Types

type Server

type Server interface {
	Start() error
	Stop() error
}

Server defines a C2 server to use for testing

func NewServer

func NewServer(mqttEndpoint string) Server

NewServer creates a new C2 server to use for testing

type TestClient

type TestClient struct {
	Name string
	ID   []byte
	Key  []byte
}

TestClient provides a representation of an id-key pair.

func NewTestClient

func NewTestClient() (*TestClient, error)

NewTestClient generates a new TestClient

func NewTestClientWithoutName

func NewTestClientWithoutName() (*TestClient, error)

NewTestClientWithoutName generates a new TestClient without name

type TestResult

type TestResult struct {
	Name     string
	Result   bool
	Critical bool
	Error    error
}

TestResult reports a test outcome for nice display

func (TestResult) Print

func (result TestResult) Print(w io.Writer)

Print will write the TestResult to given writer

type TestTopic

type TestTopic struct {
	TopicName string
	Key       []byte
}

TestTopic provides a representation of the topic-key pair.

func NewTestTopic

func NewTestTopic(topickeygen bool) (*TestTopic, error)

NewTestTopic generates a new TestTopic

Jump to

Keyboard shortcuts

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