testkit

package
v0.0.0-...-a52e8f6 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApplicationHeader = "Application"
	GroupHeader       = "Group"
	TenantHeader      = "Tenant"
	Tenant            = "testkit-tenant"
	Group             = "testkit-group"
	Extensions        = ""
	KeyAlgorithm      = "rsa2048"
)

Variables

This section is empty.

Functions

func CertificateSHA256Fingerprint

func CertificateSHA256Fingerprint(t *testing.T, certificate *x509.Certificate) string

CertificateSHA256Fingerprint returns certificate fingerprint generated using SHA256 algorithm

func CheckIfCertIsSigned

func CheckIfCertIsSigned(t *testing.T, certificates []*x509.Certificate)

CheckIfCertIsSigned verifies that client certificate is signed by server certificate

func CheckIfSubjectEquals

func CheckIfSubjectEquals(t *testing.T, expectedSubject string, certificate *x509.Certificate)

CheckIfSubjectEquals verifies that specified subject is equal to this in certificate

func CreateCsr

func CreateCsr(t *testing.T, strSubject string, keys *rsa.PrivateKey) []byte

CreateCsr creates CSR request

func CreateKey

func CreateKey(t *testing.T) *rsa.PrivateKey

Create Key generates rsa.PrivateKey

func EncodeBase64

func EncodeBase64(src []byte) string

func EncodeCertToPem

func EncodeCertToPem(t *testing.T, certificate *x509.Certificate) []byte

func EncodedCertChainToPemBytes

func EncodedCertChainToPemBytes(t *testing.T, encodedChain string) []byte

EncodedCertChainToPemBytes decodes certificates chain and return pemBlock's bytes for client cert and ca cert

func EncodedCertToPemBytes

func EncodedCertToPemBytes(t *testing.T, encodedCert string) []byte

EncodedCertToPemBytes decodes certificate and return pemBlock's bytes for it

func NewHttpClient

func NewHttpClient(skipVerify bool) *http.Client

func NewTLSClientWithCert

func NewTLSClientWithCert(skipVerify bool, key *rsa.PrivateKey, certificate ...[]byte) *http.Client

func ParseSubject

func ParseSubject(subject string) pkix.Name

Types

type ApiInfo

type ApiInfo struct {
	*RuntimeURLs
	ManagementInfoURL string `json:"infoUrl"`
	CertificatesUrl   string `json:"certificatesUrl"`
}

type ApplicationClientIdentity

type ApplicationClientIdentity struct {
	Application string `json:"application,omitempty"`
	ClusterClientIdentity
}

type CertInfo

type CertInfo struct {
	Subject      string `json:"subject"`
	Extensions   string `json:"extensions"`
	KeyAlgorithm string `json:"key-algorithm"`
}

type ClusterClientIdentity

type ClusterClientIdentity struct {
	Group  string `json:"group"`
	Tenant string `json:"tenant"`
}

type ConnectorClient

type ConnectorClient interface {
	CreateToken(t *testing.T) TokenResponse
	GetInfo(t *testing.T, url string) (*InfoResponse, *Error)
	RevokeCertificate(t *testing.T, revocationUrl, csr string) *Error
	CreateCertChain(t *testing.T, csr, url string) (*CrtResponse, *Error)
}

func NewConnectorClient

func NewConnectorClient(tokenRequest *http.Request, skipVerify bool) ConnectorClient

type CrtResponse

type CrtResponse struct {
	CRTChain  string `json:"crt"`
	ClientCRT string `json:"clientCrt"`
	CaCRT     string `json:"caCrt"`
}

type CsrRequest

type CsrRequest struct {
	Csr string `json:"csr"`
}

type DecodedCrtResponse

type DecodedCrtResponse struct {
	CRTChain  []*x509.Certificate
	ClientCRT *x509.Certificate
	CaCRT     *x509.Certificate
}

func DecodeAndParseCerts

func DecodeAndParseCerts(t *testing.T, crtResponse *CrtResponse) DecodedCrtResponse

DecodeAndParseCerts decodes base64 encoded certificates chain and parses it

type Error

type Error struct {
	StatusCode    int
	ErrorResponse ErrorResponse
}

type ErrorResponse

type ErrorResponse struct {
	Code  int    `json:"code"`
	Error string `json:"error"`
}

type InfoResponse

type InfoResponse struct {
	CertUrl     string   `json:"csrUrl"`
	Api         ApiInfo  `json:"api"`
	Certificate CertInfo `json:"certificate"`
}

type ManagementInfoResponse

type ManagementInfoResponse struct {
	URLs           ManagementInfoURLs        `json:"urls"`
	ClientIdentity ApplicationClientIdentity `json:"clientIdentity"`
	Certificate    CertInfo                  `json:"certificate"`
}

type ManagementInfoURLs

type ManagementInfoURLs struct {
	*RuntimeURLs
	RenewCertUrl  string `json:"renewCertUrl"`
	RevokeCertURL string `json:"revokeCertUrl"`
}

type RevocationBody

type RevocationBody struct {
	Hash string
}

type RuntimeURLs

type RuntimeURLs struct {
	MetadataUrl string `json:"metadataUrl"`
	EventsUrl   string `json:"eventsUrl"`
}

type SecuredConnectorClient

type SecuredConnectorClient interface {
	GetMgmInfo(t *testing.T, url string) (*ManagementInfoResponse, *Error)
	RenewCertificate(t *testing.T, url string, csr string) (*CrtResponse, *Error)
	RevokeCertificate(t *testing.T, url string) *Error
}

func NewSecuredConnectorClient

func NewSecuredConnectorClient(skipVerify bool, key *rsa.PrivateKey, certs []byte) SecuredConnectorClient

type TestConfig

type TestConfig struct {
	InternalAPIUrl string
	ExternalAPIUrl string
	GatewayUrl     string
	SkipSslVerify  bool
	Central        bool
}

func ReadConfig

func ReadConfig() (TestConfig, error)

type TokenResponse

type TokenResponse struct {
	URL   string `json:"url"`
	Token string `json:"token"`
}

Jump to

Keyboard shortcuts

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