testhelpers

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VaultAppRoleRoleName = "test-approle"

	VaultAppRoleRenewPolicy = "approle-renew-policy"
)
View Source
const (
	VaultAwsRoleName = "test-aws"
)
View Source
const (
	VaultReadSecretPolicy = "read-secret-policy"
)

Variables

View Source
var BadSettingsMap = map[string]interface{}{
	"TEST_NAME":            "string test",
	"TEST_INTEGER":         100,
	"TEST_FLOAT":           "abc",
	"TEST_SERVER_IP":       "127.0.0.1.2",
	"TEST_SERVER_PORT":     8001,
	"TEST_SERVER_POOLSIZE": 64,
	"TEST_SERVER_ALLOWED":  "[ \"127.0.0.1\", \"::1\" ]",
	"TEST_NODE_url":        "http://127.0.0.1:8003",
	"TEST_NODE_apiToken":   "some-api-access-token",
	"TEST_MONGODB_URL":     "mongodb://user:pass@127.0.0.1:27017",
}
View Source
var GoodSettings = TestSettings{
	Name:              "string test",
	PtrToName:         addressOf[string]("string test"),
	IntegerValue:      100,
	PtrToIntegerValue: addressOf[int](100),
	FloatValue:        100.3,
	PtrToFloatValue:   addressOf[float64](100.3),
	Server: TestSettingsServer{
		Ip:               "127.0.0.1",
		Port:             8001,
		PoolSize:         64,
		AllowedAddresses: []string{"127.0.0.1", "::1"},
	},
	Node: &TestSettingsNode{
		Url:      "http://127.0.0.1:8003",
		ApiToken: "some-api-access-token",
	},
	MongoDB: TestSettingsMongoDB{
		Url: "mongodb://user:pass@127.0.0.1:27017/sample_database?replSet=rs0",
	},
}
View Source
var GoodSettingsMap = map[string]interface{}{
	"TEST_NAME":            "string test",
	"TEST_INTEGER":         100,
	"TEST_FLOAT":           100.3,
	"TEST_SERVER_IP":       "127.0.0.1",
	"TEST_SERVER_PORT":     "8001",
	"TEST_SERVER_POOLSIZE": 64,
	"TEST_SERVER_ALLOWED":  "[ \"127.0.0.1\", \"::1\" ]",
	"TEST_NODE_URL":        "http://127.0.0.1:8003",
	"TEST_NODE_APITOKEN":   "some-api-access-token",
	"TEST_MONGODB_URL":     "mongodb://user:pass@127.0.0.1:27017/sample_database?replSet=rs0",
}

Functions

func CreateAppRoleRoleForReadSecretPolicy

func CreateAppRoleRoleForReadSecretPolicy(t *testing.T, client *api.Client)

func CreateAppRoleSecretID

func CreateAppRoleSecretID(t *testing.T, client *api.Client) string

func CreateAwsRoleForReadSecretPolicy

func CreateAwsRoleForReadSecretPolicy(t *testing.T, client *api.Client)

func CreateRootVaultClient

func CreateRootVaultClient(t *testing.T, vaultAddr string) *api.Client

func DumpValidationErrors

func DumpValidationErrors(t *testing.T, err error)

func EnableAppRoleAuthEngine

func EnableAppRoleAuthEngine(t *testing.T, client *api.Client)

func EnableAwsAuthEngine

func EnableAwsAuthEngine(t *testing.T, client *api.Client)

func EnsureAwsEC2Instance

func EnsureAwsEC2Instance(t *testing.T)

func EnsureVaultAvailability

func EnsureVaultAvailability(t *testing.T) string

func GetAppRoleRoleID

func GetAppRoleRoleID(t *testing.T, client *api.Client) string

func GetEC2InstanceVpcId

func GetEC2InstanceVpcId(t *testing.T) string

func PathFromSecretKey

func PathFromSecretKey(key string) string

func QuoteValue added in v0.2.0

func QuoteValue(v string) string

func ScopedEnvVars added in v0.2.0

func ScopedEnvVars(vars map[string]string) func()

func ToKeys added in v0.2.0

func ToKeys(srcMap map[string]interface{}) []string

func ToStringStringMap added in v0.2.0

func ToStringStringMap(srcMap map[string]interface{}) map[string]string

func WriteVaultSecrets added in v0.2.0

func WriteVaultSecrets(t *testing.T, client *api.Client, key string, secrets map[string]interface{})

Types

type AtomicError

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

func NewAtomicError

func NewAtomicError() *AtomicError

func (*AtomicError) Err

func (ae *AtomicError) Err() error

func (*AtomicError) Set

func (ae *AtomicError) Set(err error)

type TestSettings

type TestSettings struct {
	Name              string   `config:"TEST_NAME" validate:"required,min=1,max=64"`
	PtrToName         *string  `config:"TEST_NAME" validate:"required,min=1,max=64"`
	IntegerValue      int      `config:"TEST_INTEGER" validate:"required,number"`
	PtrToIntegerValue *int     `config:"TEST_INTEGER" validate:"required,number"`
	FloatValue        float64  `config:"TEST_FLOAT" validate:"required,number"`
	PtrToFloatValue   *float64 `config:"TEST_FLOAT" validate:"required,number"`

	Server TestSettingsServer

	Node *TestSettingsNode

	MongoDB TestSettingsMongoDB
}

type TestSettingsMongoDB

type TestSettingsMongoDB struct {
	Url string `config:"TEST_MONGODB_URL" validate:"required,url"`
}

type TestSettingsNode

type TestSettingsNode struct {
	Url      string `config:"TEST_NODE_URL" validate:"required,url"`
	ApiToken string `config:"TEST_NODE_APITOKEN" validate:"required,ascii,min=1,max=64"`
}

type TestSettingsServer

type TestSettingsServer struct {
	Ip               string   `config:"TEST_SERVER_IP" validate:"required,ip"`
	Port             int      `config:"TEST_SERVER_PORT" validate:"required,min=0,max=65535"`
	PoolSize         int      `config:"TEST_SERVER_POOLSIZE" validate:"required,gte=1"`
	AllowedAddresses []string `config:"TEST_SERVER_ALLOWED" is-json:"1" validate:"required"`
}

Jump to

Keyboard shortcuts

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