Documentation
¶
Index ¶
- func GetPrivateKey(t *testing.T, identityIndex int) string
- func GetTestClient(t *testing.T, identityIndex int) *protect.Client
- func ParseProperties(filename string) (map[string]string, error)
- func SkipIfInsufficientIdentities(t *testing.T, required int)
- func SkipIfNotEnabled(t *testing.T)
- type Identity
- type TestConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPrivateKey ¶
GetPrivateKey returns the PEM-encoded private key for the identity at the given 1-based index. Returns empty string if the identity has no private key.
func GetTestClient ¶
GetTestClient creates a ProtectClient from the identity at the given 1-based index. The client is configured with SuperAdmin keys for integrity verification.
func ParseProperties ¶
ParseProperties parses a .properties file (key=value format). Supports # comments, blank lines, and literal \n escape in values (for PEM keys).
func SkipIfInsufficientIdentities ¶
SkipIfInsufficientIdentities skips the test if fewer than required identities are configured.
func SkipIfNotEnabled ¶
SkipIfNotEnabled skips the test if integration/e2e tests are not enabled.
Types ¶
type Identity ¶
type Identity struct {
Index int
Name string
APIKey string
APISecret string
PrivateKey string // PEM string
PublicKey string // PEM string
}
Identity represents a user identity with optional API credentials, private key, and public key.
func (*Identity) HasAPICredentials ¶
HasAPICredentials returns true if this identity has both API key and secret.
func (*Identity) HasPrivateKey ¶
HasPrivateKey returns true if this identity has a private key.
func (*Identity) HasPublicKey ¶
HasPublicKey returns true if this identity has a public key.
type TestConfig ¶
TestConfig holds multi-identity test configuration.
func LoadConfig ¶
func LoadConfig() *TestConfig
LoadConfig loads configuration from test.properties file with environment variable overrides. The properties file is searched in multiple locations relative to the project root. Environment variables: PROTECT_API_HOST, PROTECT_MIN_VALID_SIGNATURES, PROTECT_API_KEY_N, PROTECT_API_SECRET_N, PROTECT_PRIVATE_KEY_N, PROTECT_PUBLIC_KEY_N.
func (*TestConfig) GetIdentity ¶
func (c *TestConfig) GetIdentity(index int) *Identity
GetIdentity returns the identity with the given 1-based index (supports gaps).
func (*TestConfig) GetIdentityCount ¶
func (c *TestConfig) GetIdentityCount() int
GetIdentityCount returns the number of configured identities.
func (*TestConfig) GetSuperAdminKeys ¶
func (c *TestConfig) GetSuperAdminKeys() []string
GetSuperAdminKeys returns all public keys from identities that have them.
func (*TestConfig) IsEnabled ¶
func (c *TestConfig) IsEnabled() bool
IsEnabled returns true if tests should run. Tests are enabled if PROTECT_INTEGRATION_TEST=true or any identity has API credentials.