testhelpers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIKeyTypeServer = "Server"
	APIKeyTypeClient = "Client"
	APIKeyExpiredAt  = ""
)

APIKeyName ...

View Source
const (
	DefaultProjectIdentifier = "CF_SystemTest"
	DefaultProjectDesc       = "CF System Test project"
	DefaultProjectName       = "CF System Test"
	DefaultSegment           = "group"
	DefaultSegmentName       = "groupName"
)

DefaultProjectIdentifier ...

View Source
const (
	DefaultTagName = "default"
)

DefaultTagName ...

Variables

View Source
var AuthToken string

AuthToken used to authenticate with the remote service

Functions

func AddAPIKey

func AddAPIKey(reqBody admin.AddAPIKeyJSONRequestBody, projectIdentifier string, envIdentifier string) (*admin.AddAPIKeyResponse, error)

AddAPIKey ...

func AddAuthToken

func AddAuthToken(ctx context.Context, req *http.Request) error

AddAuthToken adds the appropriate token to the request. If we are using a JWT it sets the authorization header, and if were using a PAT/SAT it sets the x-api-key header

func Authenticate

func Authenticate(apiKey string, url string, target *client.Target) (*client.AuthenticateResponse, error)

Authenticate is wrapper around the rest client for the Auth API

func AuthenticateSDKClient

func AuthenticateSDKClient(key string, url string, target *client.Target) (token string, claims domain.Claims, err error)

AuthenticateSDKClient performs an auth request and returns the token and environment to use

func CreateDefaultProject

func CreateDefaultProject() (string, error)

CreateDefaultProject ...

func CreateEnvironment

func CreateEnvironment(projectIdentifier string, environment, environmentName string) (*http.Response, error)

CreateEnvironment ...

func CreateEnvironmentRemote

func CreateEnvironmentRemote(projectIdentifier string, environment, environmentName string) (*http.Response, error)

CreateEnvironmentRemote ...

func CreateFeatureFlag

CreateFeatureFlag ...

func CreateProject

func CreateProject(projectReq admin.CreateProjectJSONRequestBody) (*http.Response, error)

CreateProject ...

func CreateProjectLocal

func CreateProjectLocal(projectReq admin.CreateProjectJSONRequestBody) (*admin.CreateProjectResponse, error)

CreateProjectLocal ...

func CreateProjectRemote

func CreateProjectRemote(identifier string) (*http.Response, error)

CreateProjectRemote ...

func CreateSegment

CreateSegment ...

func DecodeClaims

func DecodeClaims(tokenString string) (domain.Claims, error)

DecodeClaims ...

func DefaultClient

func DefaultClient() *admin.Client

DefaultClient returns the default admin client

func DefaultEvaluationClient

func DefaultEvaluationClient(url string) *client.Client

DefaultEvaluationClient creates a default client for the evaluation service

func DeleteProject

func DeleteProject(identifier string) (*http.Response, error)

DeleteProject ...

func DeleteProjectRemote

func DeleteProjectRemote(identifier string) (*http.Response, error)

DeleteProjectRemote ...

func GenerateBooleanFeatureFlagBody

func GenerateBooleanFeatureFlagBody(projectIdentifier string, id int) admin.CreateFeatureFlagJSONRequestBody

GenerateBooleanFeatureFlagBody ...

func GenerateProjectIdentifier

func GenerateProjectIdentifier(seed string) string

GenerateProjectIdentifier ...

func GenerateStringFeatureFlagBody

func GenerateStringFeatureFlagBody(projectIdentifier string, id int) admin.CreateFeatureFlagJSONRequestBody

GenerateStringFeatureFlagBody ...

func GetAddAPIKeyBody

func GetAddAPIKeyBody(identifier string, apiKeyType string, name string, description string, expiredAt string) admin.AddAPIKeyJSONRequestBody

GetAddAPIKeyBody ...

func GetAuthToken

func GetAuthToken() string

GetAuthToken ...

func GetCertClient

func GetCertClient() *http.Client

GetCertClient returns a custom http client which defines a certificate authority and trusts our certs from the /cert folder this avoids any errors when run locally and doesn't require the certs to be manually trusted on your machine

func GetClientURL

func GetClientURL() string

GetClientURL ...

func GetDefaultAccount

func GetDefaultAccount() string

GetDefaultAccount ...

func GetDefaultEnvironment

func GetDefaultEnvironment() string

GetDefaultEnvironment ...

func GetDefaultOrg

func GetDefaultOrg() string

GetDefaultOrg ...

func GetEnvironment

func GetEnvironment(projectIdentifier string, environment string) (*admin.GetEnvironmentResponse, error)

GetEnvironment ...

func GetPlatformBaseURL

func GetPlatformBaseURL() string

GetPlatformBaseURL ...

func GetSegmentRequestBody

func GetSegmentRequestBody(project string, environment string, segmentIdentifier string, segmentName string, included *[]string,
	excluded *[]string, tags *[]admin.Tag, clauses *[]admin.Clause) admin.CreateSegmentJSONRequestBody

GetSegmentRequestBody ...

func GetUserAccessToken

func GetUserAccessToken() string

GetUserAccessToken ...

func IsPlaformEnabled

func IsPlaformEnabled() bool

IsPlaformEnabled ...

func ReadProject

func ReadProject(identifier admin.Identifier) (*admin.GetProjectResponse, error)

ReadProject ...

func SetAuthToken

func SetAuthToken(token string)

SetAuthToken ...

func SetupAuth

func SetupAuth()

Types

type CreateRemoteProject

type CreateRemoteProject struct {
	Project PlatformProject `json:"project"`
}

CreateRemoteProject ...

type Environment

type Environment struct {
	Identifier string
	Name       string
	Project    string
	Keys       []v1.ApiKey
	Targets    []v1.Target
	Segments   map[string]Segment
}

Environment contains entities that we will use to drive test data

func (Environment) ToEnvironment

func (e Environment) ToEnvironment() v1.Environment

ToEnvironment converts the test environment to a v1.Environment for use in API calls

type PlatformEnvironment

type PlatformEnvironment struct {
	Name              string `json:"name"`
	Identifier        string `json:"identifier"`
	ProjectIdentifier string `json:"projectIdentifier"`
	OrgIdentifier     string `json:"orgIdentifier"`
	Type              string `json:"type"`
}

PlatformEnvironment ...

type PlatformProject

type PlatformProject struct {
	Name          string `json:"name"`
	OrgIdentifier string `json:"orgIdentifier"`
	Description   string `json:"description"`
	Identifier    string `json:"identifier"`
}

PlatformProject ...

type Segment

type Segment struct {
	Included []string
}

Segment are groups of targets

type TestProject

type TestProject struct {
	Account           string
	Organization      string
	ProjectIdentifier string
	Environment       Environment
	Flags             map[string]v1.FeatureFlagRequest
}

TestProject represents a project that we will create during tests

func SetupTestProject

func SetupTestProject() (TestProject, error)

SetupTestProject creates a new project and environment for the tests

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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