fakekms

package
v0.0.0-...-f938a04 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package fakekms supports integration testing of kms-plugin by faking CloudKMS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server fakes CloudKMS.

func NewWithPipethrough

func NewWithPipethrough(keyName string, port int) (*Server, error)

NewWithPipethrough creates and returns *Server that simply passed through the requests, by replacing ciphertext to cleartext and vice versa. Callers are also responsible for calling Close after completing tests. keyName simulates CloudKMS' keyName and is taken into account when calculating expected URL endpoints.

func NewWithResponses

func NewWithResponses(keyName string, port int, delay time.Duration, responses ...json.Marshaler) (*Server, error)

NewWithResponses creates and returns *Server. It is the responsibility of the caller to supply the expected number of Responses. When the provided Responses are exhausted an error will be returned. Callers are also responsible for calling Close after completing tests. keyName simulates CloudKMS' keyName and is taken into account when calculating expected URL endpoints. delay allows the caller to simulate delayed responses from KMS.

func (*Server) Client

func (f *Server) Client() *http.Client

Client returns *http.Client for the fake.

func (*Server) Close

func (f *Server) Close()

Close closes the underlying httptest.Server.

func (*Server) DecryptRequestsEqual

func (f *Server) DecryptRequestsEqual(r []*cloudkms.DecryptRequest) error

DecryptRequestsEqual validates that the supplied DecryptRequests are equal to the all DecryptRequests processed by the server.

func (*Server) EncryptRequestsEqual

func (f *Server) EncryptRequestsEqual(r []*cloudkms.EncryptRequest) error

EncryptRequestsEqual validates that the supplied EncryptRequests are equal to all EncryptRequests processed by the server.

func (*Server) TestIAMRequestsEqual

func (f *Server) TestIAMRequestsEqual(r []*cloudkms.TestIamPermissionsRequest) error

TestIAMRequestsEqual validates that the supplied TestIamPermissionsRequests are equal to the all TestIamPermissionsRequests processed by the server.

func (*Server) URL

func (f *Server) URL() string

URL returns URL on which the fake is expecting requests.

Jump to

Keyboard shortcuts

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