helpers

package
v8.7.8-mod Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	DebugCommandPrefix        = "\nCMD>"
	DebugCommandPrefixWithDir = "\nCMD %s>"
	DebugOutPrefix            = "OUT: "
	DebugErrPrefix            = "ERR: "
)
View Source
const (
	GUIDRegex                                  = `[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}`
	ISO8601Regex                               = `\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{1,3}[+-]\d{4}`
	StaticfileBuildpackStartCommand            = `\$HOME/boot.sh|sh boot.sh`
	ModernStaticfileBuildpackStartCommand      = `$HOME/boot.sh`
	ModernStaticfileBuildpackStartCommandRegex = `\$HOME/boot\.sh`
	UserFriendlyDateRegex                      = `[A-Z][a-z]{2} \d{2} [A-Z][a-z]{2} \d{2}:\d{2}:\d{2} [A-Z]+ \d{4}`
)
View Source
const (
	ReadableDateTimeRegex = `\w{3} \d{1,2} \w{3} \d{2}:\d{2}:\d{2} \w{3,5} \d{4}`
	TimestampRegex        = `\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`
)
View Source
const (
	DefaultV2Version         string = "2.131.0"
	DefaultV3Version         string = "3.66.0"
	DefaultAuthorizationPath string = ""
)
View Source
const MaxTestPort = 1034

MaxTestPort should be defined by the CF router group for integration tests.

View Source
const MinTestPort = 1024

MinTestPort should be defined by the CF router group for integration tests.

View Source
const NonUAAOrigin = "cli-oidc-provider"
View Source
const V7 = true

Variables

View Source
var CcRootCache *ccRoot

CcRootCache is a pointer to a cache of the CC root response

Functions

func AddEmptyPaginatedResponse

func AddEmptyPaginatedResponse(server *ghttp.Server, path string)

AddEmptyPaginatedResponse adds a mock handler to the given server which returns a response with no resources.

func AddFiftyOneOrgs

func AddFiftyOneOrgs(server *ghttp.Server)

AddFiftyOneOrgs adds a mock handler to the given server which returns 51 orgs on GET requests to /v3/organizations?order_by=name. It also paginates, so page 2 can be requested with /v3/organizations?page=2&per_page=50.

func AddFiftyOneSpaces

func AddFiftyOneSpaces(server *ghttp.Server)

AddFiftyOneSpaces adds mock handlers to the given http server which includes an organization which will contain 51 spaces

func AddHandler

func AddHandler(ser *ghttp.Server, method string, pathAndQuery string, status int, body []byte)

AddHandler adds a mock handler to the server making a request specified by "method" to the endpoint specified by "pathAndQuery", returning a response with status code "status" and response body "body".

func AddLoginRoutes

func AddLoginRoutes(s *Server)

AddLoginRoutes adds a mock handler to the given server which returns an access token and a 200 status code on POST requests to /oauth/token.

func AddMfa

func AddMfa(server *Server, password string, mfaToken string)

AddMfa adds a mock handler to the given server which returns a login response and a 200 status code on GET requests to the /login endpoint. It adds another mock handler to validate the given password and MFA token upon POST requests to /oauth/token.

func AddOrReplaceEnvironment

func AddOrReplaceEnvironment(env []string, newEnvName string, newEnvVal string) []string

AddOrReplaceEnvironment will update environment if it already exists or will add a new environment with the given environment name and details.

func AppGUID

func AppGUID(appName string) string

AppGUID returns the GUID for an app in the currently targeted space.

func AppJSON

func AppJSON(appName string) string

AppJSON returns the JSON representation of an app by name.

func BuildConfigurablePlugin

func BuildConfigurablePlugin(pluginType string, name string, version string, pluginCommands []PluginCommand) string

BuildConfigurablePlugin builds a plugin of type pluginType from the integration/assets/<pluginType> directory with the given name, version, and commands. Available pluginTypes: configurable_plugin, configurable_plugin_fails_uninstall, test_plugin, test_plugin_fails_metadata, test_plugin_with_command_overrides, test_plugin_with_panic.

func BuildTokenString

func BuildTokenString(expiration time.Time) string

BuildTokenString returns a string typed JSON web token with the specified expiration time

func BuildpackGUIDByNameAndStack

func BuildpackGUIDByNameAndStack(buildpackName string, stackName string) string

func BuildpackWithStack

func BuildpackWithStack(f func(buildpackArchive string), stackName string)

BuildpackWithStack makes a simple buildpack for the given stack (using MakeBuildpackArchive) and yields it to the given function, removing the zip at the end.

func BuildpackWithoutStack

func BuildpackWithoutStack(f func(buildpackArchive string))

BuildpackWithoutStack makes a simple buildpack without a stack (using MakeBuildpackArchive) and yields it to the given function, removing the zip at the end.

func BuildpacksOutputRegex

func BuildpacksOutputRegex(fields BuildpackFields) string

BuildpacksOutputRegex takes a BuildpackFields struct and returns a regex matching a line in the output of 'cf buildpacks' representing the given buildpack.

func CF

func CF(args ...string) *Session

CF runs a 'cf' command with given arguments.

func CFWithEnv

func CFWithEnv(envVars map[string]string, args ...string) *Session

CFWithEnv runs a 'cf' command with specified environment variables and given arguments.

func CFWithStdin

func CFWithStdin(stdin io.Reader, args ...string) *Session

CFWithStdin runs a 'cf' command with a custom stdin and given arguments.

func CheckEnvironmentTargetedCorrectly

func CheckEnvironmentTargetedCorrectly(targetedOrganizationRequired bool, targetedSpaceRequired bool, testOrg string, command ...string)

CheckEnvironmentTargetedCorrectly will confirm if the command requires an API to be targeted and logged in to run. It can optionally check if the command requires org and space to be targeted.

func CheckExpectedLabels

func CheckExpectedLabels(url string, list bool, expected MetadataLabels)

func CheckSpaceAndOrgTargetedCorrectly

func CheckSpaceAndOrgTargetedCorrectly(command ...string)

func ClearTarget

func ClearTarget()

ClearTarget logs out and logs back into the CLI using LogoutCF and LoginCF.

func ClientCredentialsTestMode

func ClientCredentialsTestMode() bool

func ConfirmStagingLogs

func ConfirmStagingLogs(session *Session)

ConfirmStagingLogs checks session for log output indicating that staging is working.

func ConvertPathToRegularExpression

func ConvertPathToRegularExpression(path string) string

ConvertPathToRegularExpression converts a windows file path into a string which may be embedded in a ginkgo-compatible regular expression.

func CreateAndTargetOrg

func CreateAndTargetOrg() string

CreateAndTargetOrg creates a randomly-named org and targets it.

func CreateApp

func CreateApp(app string)

CreateApp creates an empty app in CloudController with no package or droplet

func CreateManagedServiceInstance

func CreateManagedServiceInstance(offering, plan, name string, additional ...string)

CreateManagedServiceInstance also waits for completion

func CreateOrg

func CreateOrg(org string)

CreateOrg creates an org with the given name using 'cf create-org'.

func CreateOrgAndSpace

func CreateOrgAndSpace(org string, space string)

CreateOrgAndSpace creates an org and a space in that org with specified names.

func CreateOrgAndSpaceUnlessExists

func CreateOrgAndSpaceUnlessExists(org string, space string)

CreateOrgAndSpaceUnlessExists creates an org and a space in that org with specified names only if these don't exist yet.

func CreateSecurityGroup

func CreateSecurityGroup(s resources.SecurityGroup)

CreateSecurityGroup Creates a new security group on the API using the 'cf create-security-group'

func CreateSpace

func CreateSpace(space string)

CreateSpace creates a space with the given name using 'cf create-space'.

func CreateSpaceInOrg

func CreateSpaceInOrg(space string, org string)

CreateSpaceInOrg creates a space with the given name using 'cf create-space'.

func CreateStack

func CreateStack(names ...string) string

CreateStack creates a new stack with the user provided name. If a name is not provided, a random name is used

func CreateStackWithGUID

func CreateStackWithGUID() (string, string)

CreateStackWithGUID creates a stack with a random name and returns its name and guid

func CreateUser

func CreateUser() (string, string)

CreateUser creates a user with a random username and password and returns both.

func CreateUserInOrgRole

func CreateUserInOrgRole(org, role string) (string, string)

CreateUserInOrgRole creates a user with a random username and password and gives them the specified role within a specific org. The new user's username and password are returned.

func CreateUserInSpaceRole

func CreateUserInSpaceRole(org, space, role string) (string, string)

CreateUserInSpaceRole creates a user with a random username and password and gives them the specified role within a specific space. The new user's username and password are returned.

func Curl

func Curl(obj interface{}, url string, props ...interface{})

Curl runs a 'cf curl' command with a URL format string, allowing props to be interpolated into the URL string with fmt.Sprintf. The JSON response is unmarshaled into given obj.

func CustomCF

func CustomCF(cfEnv CFEnv, args ...string) *Session

CustomCF runs a 'cf' command with a custom environment and given arguments.

func DebugCustomCF

func DebugCustomCF(cfEnv CFEnv, args ...string) *Session

DebugCustomCF runs a 'cf' command with a custom environment and given arguments, with CF_LOG_LEVEL set to 'debug'.

func DefaultSharedDomain

func DefaultSharedDomain() string

DefaultSharedDomain runs 'cf domains' to find the default domain, caching the result so that the same domain is returned each time it is called.

func DeleteBuildpackIfOnOldCCAPI

func DeleteBuildpackIfOnOldCCAPI(buildpackName string)

DeleteBuildpackIfOnOldCCAPI deletes the buildpack if the CC API targeted by the current test run is <= 2.80.0. Before this version, some entities would receive and invalid next_url in paginated requests. Since our test run now generally creates more than 50 buildpacks, we need to delete test buildpacks after use if we are targeting an older CC API. see https://github.com/cloudfoundry/capi-release/releases/tag/1.45.0

func DeleteSecurityGroup

func DeleteSecurityGroup(s resources.SecurityGroup)

DeleteSecurityGroup Deletes a security group on the API using the 'cf delete-security-group'

func DeleteStack

func DeleteStack(name string)

DeleteStack deletes a specific stack

func DeleteUser

func DeleteUser(username string)

DeleteUser deletes the user specified by username.

func DestroyHomeDir

func DestroyHomeDir(homeDir string)

DestroyHomeDir safely removes the given directory checking for errors.

func DisableFeatureFlag

func DisableFeatureFlag(flagName string)

DisableFeatureFlag disables given feature flag with 'cf disable-feature-flag'.

func DomainName

func DomainName(prefix ...string) string

DomainName returns a random domain name, with a given prefix if provided.

func EnableFeatureFlag

func EnableFeatureFlag(flagName string)

EnableFeatureFlag enables given feature flag with 'cf enable-feature-flag'.

func EnsureMinimumNumberOfStacks

func EnsureMinimumNumberOfStacks(num int) []string

EnsureMinimumNumberOfStacks ensures there are at least <num> stacks in the foundation by creating new ones if there are fewer than the specified number

func ExpiredAccessToken

func ExpiredAccessToken() string

ExpiredAccessToken returns an example expired bearer token.

func FetchStacks

func FetchStacks() []string

FetchStacks returns all the stack names present in the foundation.

func FindOrCreateTCPRouterGroup

func FindOrCreateTCPRouterGroup(node int) string

FindOrCreateTCPRouterGroup uses the routing API to find a router group with name INTEGRATION-TCP-NODE-<node>, or create one if it does not exist. Returns the name of the router group.

func GenerateHigherName

func GenerateHigherName(randomNameGenerator func() string, names ...string) string

GenerateHigherName will use the passed randomNameGenerator to generate a name with a higher sort value than all the passed names

func GenerateLowerName

func GenerateLowerName(randomNameGenerator func() string, names ...string) string

GenerateLowerName will use the passed randomNameGenerator to generate a name with a lower sort value than all the passed names

func GetAPI

func GetAPI() string

GetAPI gets the value of the CF_INT_API environment variable, if set, and prefixes it with "https://" if the value doesn't already start with "http". If the variable is not set, returns "https://api.bosh-lite.com".

func GetAPIVersionV2

func GetAPIVersionV2() string

GetAPIVersionV2 returns the V2 api version of the targeted API

func GetAppDroplet

func GetAppDroplet(appGUID string) string

func GetConfig

func GetConfig() *configv3.Config

GetConfig loads a CF config JSON file and returns the parsed struct.

func GetCredentials

func GetCredentials() (string, string)

GetCredentials returns back the credentials for the user or client to authenticate with Cloud Foundry.

func GetFirstAppPackageGuid

func GetFirstAppPackageGuid(appName string) string

func GetIsolationSegmentGUID

func GetIsolationSegmentGUID(name string) string

GetIsolationSegmentGUID gets the Isolation Segment GUID by passing along the given isolation segment name as a query parameter in the /v3/isolation_segments?names=name endpoint.

func GetOrgGUID

func GetOrgGUID(orgName string) string

GetOrgGUID gets the GUID of an org with the given name.

func GetPackageFirstDroplet

func GetPackageFirstDroplet(packageGUID string) string

func GetSpaceGUID

func GetSpaceGUID(spaceName string) string

GetSpaceGUID gets the GUID of a space with the given name.

func GetsDefaultEnvVarValue

func GetsDefaultEnvVarValue(stream []byte) string

func GetsEnablementValue

func GetsEnablementValue(stream []byte) bool

func InstallConfigurablePlugin

func InstallConfigurablePlugin(pluginType string, name string, version string, pluginCommands []PluginCommand)

InstallConfigurablePlugin builds and installs a plugin called 'configurable_plugin' with the given name, version, and commands.

func IsUAAVersionAtLeast

func IsUAAVersionAtLeast(minVersion string) bool

IsUAAVersionAtLeast returns true if the UAA version >= minVersion, false otherwise.

func IsVersionMet

func IsVersionMet(minVersion string) bool

IsVersionMet verifies the targeted API meets the minimum required version

func IsWindows

func IsWindows() bool

func LoginAs

func LoginAs(username, password string)

LoginAs logs into the CLI with 'cf auth' and the given username and password, retrying up to 3 times on failures.

func LoginCF

func LoginCF() string

LoginCF logs into the CLI using the username and password from the CF_INT_USERNAME and CF_INT_PASSWORD environment variables, respectively, defaulting to "admin" for each if either is not set.

func LoginCFWithClientCredentials

func LoginCFWithClientCredentials() string

LoginCFWithClientCredentials logs into the CLI using client credentials from the CF_INT_CLIENT_ID and CF_INT_CLIENT_SECRET environment variables and returns the client ID. If these environment variables are not set, it skips the current test.

func LogoutCF

func LogoutCF()

LogoutCF logs out of the CLI.

func MakeBuildpackArchive

func MakeBuildpackArchive(stackName string) string

MakeBuildpackArchive makes a simple buildpack zip for a given stack.

func MapRouteToApplication

func MapRouteToApplication(app string, domain string, host string, path string)

MapRouteToApplication maps a route to an app using 'cf map-route' and asserts that the mapping exists.

func NewAppName

func NewAppName() string

NewAppName provides a random name prefixed with INTEGRATION-APP

func NewBuildpackName

func NewBuildpackName() string

NewBuildpackName provides a random name prefixed with INTEGRATION-BUILDPACK

func NewDomainName

func NewDomainName(prefix ...string) string

NewDomainName provides a random domain name prefixed with integration. If prefix is provided the domain name will have structure "integration-prefix-randomstring.com" else it will have structure "integration-randomstring.com"

func NewHostName

func NewHostName() string

NewHostName provides a random name prefixed with `host`

func NewIsolationSegmentName

func NewIsolationSegmentName(infix ...string) string

NewIsolationSegmentName provides a random name prefixed with INTEGRATION-ISOLATION-SEGMENT

func NewOrgName

func NewOrgName() string

NewOrgName provides a random name prefixed with INTEGRATION-ORG

func NewOrgQuotaName

func NewOrgQuotaName() string

NewOrgQuotaName provides a random name prefixed with ORG-QUOTA

func NewPassword

func NewPassword() string

NewPassword provides a random string prefixed with INTEGRATION-PASSWORD

func NewPath

func NewPath() string

NewPath provides a random path prefixed with /PATH

func NewPlanName

func NewPlanName() string

NewPlanName provides a random name prefixed with INTEGRATION-PLAN

func NewPluginRepositoryServer

func NewPluginRepositoryServer(pluginRepo PluginRepository) *Server

NewPluginRepositoryServer is used to configure and start a new plugin repo server, exposing the plugins contained in the pluginRepo.

func NewPluginRepositoryTLSServer

func NewPluginRepositoryTLSServer(pluginRepo PluginRepository) *Server

NewPluginRepositoryTLSServer is used to configure and start a new TLS plugin repo server, exposing the plugins contained in the pluginRepo.

func NewRouterGroupName

func NewRouterGroupName() string

NewRouterGroupName provides a random name prefixed with INTEGRATION-ROUTER-GROUP

func NewSecurityGroup

func NewSecurityGroup(name string, protocol string, destination string, ports *string, description *string) resources.SecurityGroup

NewSecurityGroup returns a new security group with the given attributes

func NewSecurityGroupName

func NewSecurityGroupName(infix ...string) string

NewSecurityGroupName provides a random name prefixed with INTEGRATION-SEC-GROUP. If an infix is provided, it is placed between INTEGRATION-SEC-GROUP and the random string.

func NewServiceBrokerName

func NewServiceBrokerName() string

NewServiceBrokerName provides a random name prefixed with INTEGRATION-SERVICE-BROKER

func NewServiceInstanceName

func NewServiceInstanceName() string

NewServiceInstanceName provides a random name prefixed with INT-SI

func NewServiceOfferingName

func NewServiceOfferingName() string

NewServiceOfferingName provides a random name prefixed with INTEGRATION-SERVICE

func NewSpaceName

func NewSpaceName() string

NewSpaceName provides a random name prefixed with INTEGRATION-SPACE

func NewStackName

func NewStackName() string

NewStackName provides a random name prefixed with INTEGRATION-STACK

func NewUsername

func NewUsername() string

NewUsername provides a random name prefixed with INTEGRATION-USER

func ParseTokenString

func ParseTokenString(token string) jwt.JWT

ParseTokenString takes a string typed token and returns a jwt.JWT struct representation of that token

func PluginPlatform

func PluginPlatform() string

PluginPlatform returns the platform string for Unix.

func PreferredStack

func PreferredStack() string

PreferredStack returns the cflinuxfs3 stack name if it present, otherwise cflinuxfs2 is returned.

func PrefixedRandomName

func PrefixedRandomName(namePrefix string) string

PrefixedRandomName provides a random name with structure "namePrefix-randomstring"

func QuickDeleteApp

func QuickDeleteApp(appName string)

QuickDeleteApp deletes the app with the given name, if provided, using 'cf curl /v3/app... -X DELETE'.

func QuickDeleteOrg

func QuickDeleteOrg(orgName string)

QuickDeleteOrg deletes the org with the given name, if provided, using 'cf curl /v2/organizations... -X DELETE'.

func QuickDeleteOrgIfExists

func QuickDeleteOrgIfExists(orgName string)

QuickDeleteOrgIfExists deletes the org with the given name, if it exists, using 'cf curl /v2/organizations... -X DELETE'.

func QuickDeleteSpace

func QuickDeleteSpace(spaceName string)

QuickDeleteSpace deletes the space with the given name, if it exists, using 'cf curl /v2/spaces... -X DELETE'.

func QuotaName

func QuotaName(name ...string) string

QuotaName provides a random name prefixed with INTEGRATION-QUOTA. If given a name, it structures the name like INTEGRATION-QUOTA-name-randomstring.

func RandomName

func RandomName() string

RandomName provides a random string

func RandomPort

func RandomPort() int

RandomPort returns a port number that has not yet been used, starting at 1024 and increasing by one each time it is called. It errors if the number increases above 1123.

func RandomURL

func RandomURL() string

func ReadManifest

func ReadManifest(path string) map[string]interface{}

func SayPath

func SayPath(format string, path string) types.GomegaMatcher

SayPath is used to assert that a path is printed within streaming output. On Windows, it uses a case-insensitive match and escapes the path.

func ServiceInstanceGUID

func ServiceInstanceGUID(serviceInstanceName string) string

func SetAPI

func SetAPI() (string, bool)

SetAPI sets the API endpoint to the value of the CF_INT_API environment variable, or "https://api.bosh-lite.com" if not set. If the SKIP_SSL_VALIDATION environment variable is set, it will use the '--skip-ssl-validation' flag. It returns the API URL and a boolean indicating if SSL validation was skipped.

func SetConfig

func SetConfig(cb func(conf *configv3.Config))

SetConfig allows for a given function to modify a CF config JSON and writes the result back down to the filesystem.

func SetConfigContent

func SetConfigContent(dir string, rawConfig string)

SetConfigContent writes given raw config into given directory as "config.json".

func SetHomeDir

func SetHomeDir() string

SetHomeDir sets CF_HOME and CF_PLUGIN_HOME to a temp directory and outputs the created directory through GinkgoWriter.

func SetOrgRole

func SetOrgRole(username, org, role string, isClient bool)

SetOrgRole sets the org role with `cf set-org-role`.

func SetSpaceRole

func SetSpaceRole(username, org, space, role string, isClient bool)

SetSpaceRole sets the space role with `cf set-org-role`.

func SetupBuildpackWithStack

func SetupBuildpackWithStack(buildpackName, stack string)

SetupBuildpackWithStack makes and uploads a buildpack for the given stack.

func SetupBuildpackWithoutStack

func SetupBuildpackWithoutStack(buildpackName string)

SetupBuildpackWithoutStack makes and uploads a buildpack without a stack.

func SetupCF

func SetupCF(org string, space string)

SetupCF logs into the CLI with LoginCF, creates the given org and space, and targets that org and space.

func SetupCFWithGeneratedOrgAndSpaceNames

func SetupCFWithGeneratedOrgAndSpaceNames() string

SetupCFWithGeneratedOrgAndSpaceNames logs into the CLI with LoginCF, creates the org and space with generated names, and targets that org and space. Returns the generated org so that it can be deleted easily in cleanup step of the test.

func SetupCFWithOrgOnly

func SetupCFWithOrgOnly(org string)

SetupCFWithOrgOnly logs into the CLI with LoginCF, creates the given org, and targets it.

func SetupReadOnlyOrgAndSpace

func SetupReadOnlyOrgAndSpace() (string, string)

SetupReadOnlyOrgAndSpace creates a randomly-named org containing two randomly-named spaces. It creates a new CF_HOME directory to run these commands, then deletes it afterwards.

func SetupSynchronizedSuite

func SetupSynchronizedSuite(setup func())

SetupSynchronizedSuite runs a setup function in its own CF context, creating and destroying a home directory around it.

func Sha1Sum

func Sha1Sum(path string) string

Sha1Sum calculates the SHA1 sum of a file.

func SkipIfClientCredentialsNotSet

func SkipIfClientCredentialsNotSet() (string, string)

SkipIfClientCredentialsNotSet will skip the test when either CF_INT_CLIENT_ID or CF_INT_CLIENT_SECRET are not set.

func SkipIfClientCredentialsTestMode

func SkipIfClientCredentialsTestMode()

func SkipIfCustomClientCredentialsNotSet

func SkipIfCustomClientCredentialsNotSet() (string, string)

SkipIfCustomClientCredentialsNotSet will skip the test when either CF_INT_CUSTOM_CLIENT_ID or CF_INT_CUSTOM_CLIENT_SECRET are not set.

func SkipIfNoRoutingAPI

func SkipIfNoRoutingAPI()

SkipIfNoRoutingAPI is used to skip tests if the routing API is not present

func SkipIfOIDCCredentialsNotSet

func SkipIfOIDCCredentialsNotSet() (string, string)

SkipIfOIDCCredentialsNotSet returns back the username and the password for OIDC origin, or skips the test if those values are not set.

func SkipIfPrivateDockerInfoNotSet

func SkipIfPrivateDockerInfoNotSet() (string, string, string)

SkipIfPrivateDockerInfoNotSet skips the test if CF_INT_DOCKER_IMAGE, CF_INT_DOCKER_USERNAME, or CF_INT_DOCKER_PASSWORD environment variables are not defined.

func SkipIfUAAVersionAtLeast

func SkipIfUAAVersionAtLeast(version string)

SkipIfUAAVersionAtLeast is used to skip tests if the UAA version >= the specified version.

func SkipIfUAAVersionLessThan

func SkipIfUAAVersionLessThan(version string)

SkipIfUAAVersionLessThan is used to skip tests if the UAA version is < the specified version

func SkipIfV7

func SkipIfV7()

SkipIfV7 is used to skip tests if the target build is V7.

func SkipIfV7AndVersionLessThan

func SkipIfV7AndVersionLessThan(minVersion string)

SkipIfV7AndVersionLessThan is used to skip tests if the target build is V7 and API version < the specified version If minVersion contains the prefix 3 then the v3 version is checked, otherwise the v2 version is used.

func SkipIfVersionAtLeast

func SkipIfVersionAtLeast(maxVersion string)

SkipIfVersionLessThan is used to skip tests if the API version >= the specified version. If maxVersion contains the prefix 3 then the v3 version is checked, otherwise the v2 version is used.

func SkipIfVersionLessThan

func SkipIfVersionLessThan(minVersion string)

SkipIfVersionLessThan is used to skip tests if the API version < the specified version. If minVersion contains the prefix 3 then the v3 version is checked, otherwise the v2 version is used.

func SkipIfWindows

func SkipIfWindows()

func SkipSSLValidation

func SkipSSLValidation() bool

func StartAndTargetMockServerWithAPIVersions

func StartAndTargetMockServerWithAPIVersions(v2Version string, v3Version string) *Server

StartAndTargetMockServerWithAPIVersions starts and targets a server with the given V2 and V3 API versions.

func StartMockServerWithAPIVersions

func StartMockServerWithAPIVersions(v2Version string, v3Version string) *Server

StartMockServerWithAPIVersions starts a server with the given V2 and V3 API versions

func StartMockServerWithCustomAuthorizationEndpoint

func StartMockServerWithCustomAuthorizationEndpoint(authorizationPath string) *Server

StartMockServerWithAPIVersions starts a server with the given V2 and V3 API versions

func StartMockServerWithMinimumCLIVersion

func StartMockServerWithMinimumCLIVersion(minCLIVersion string) *Server

StartMockServerWithMinimumCLIVersion starts a server with the default V2 and V3 API versions and the given minimum CLI version.

func SwitchToNoRole

func SwitchToNoRole() string

SwitchToNoRole logs out of the CLI and logs back in as a newly-created user without a role.

func SwitchToOrgRole

func SwitchToOrgRole(org, role string) string

SwitchToOrgRole logs out of the CLI and logs back in as a newly-created user with the given org role in the given org.

func SwitchToSpaceRole

func SwitchToSpaceRole(org, space, role string) string

SwitchToSpaceRole logs out of the CLI and logs back in as a newly-created user with the given space role in the given space and org.

func TargetOrg

func TargetOrg(org string)

TargetOrg targets the given org with 'cf target'.

func TargetOrgAndSpace

func TargetOrgAndSpace(org string, space string)

TargetOrgAndSpace targets the given org and space with 'cf target'.

func TempDirAbsolutePath

func TempDirAbsolutePath(dir string, prefix string) string

TempDirAbsolutePath wraps `ioutil.TempDir`, ensuring symlinks are expanded before returning the path

func TempFileAbsolutePath

func TempFileAbsolutePath(dir string, pattern string) *os.File

TempFileAbsolutePath wraps `ioutil.TempFile`, ensuring symlinks are expanded before returning the path

func TempFileWithContent

func TempFileWithContent(contents string) string

TempFileWithContent writes a temp file with given content and return the file name.

func TurnOffColors

func TurnOffColors()

TurnOffColors sets CF_COLOR to 'false'.

func TurnOffExperimental

func TurnOffExperimental()

TurnOffExperimental unsets CF_CLI_EXPERIMENTAL.

func TurnOnExperimental

func TurnOnExperimental()

TurnOnExperimental sets CF_CLI_EXPERIMENTAL to 'true'.

func UnmapRouteFromApplication

func UnmapRouteFromApplication(app string, domain string, host string, path string)

UnmapRouteFromApplication unmaps a route from an app using 'cf unmap-route' and asserts that the mapping gets deleted.

func UnrefactoredCheckEnvironmentTargetedCorrectly

func UnrefactoredCheckEnvironmentTargetedCorrectly(targetedOrganizationRequired bool, targetedSpaceRequired bool, testOrg string, command ...string)

UnrefactoredCheckEnvironmentTargetedCorrectly will confirm if the command requires an API to be targeted and logged in to run. It can optionally check if the command requires org and space to be targeted.

func UnsetAPI

func UnsetAPI()

UnsetAPI unsets the currently set API endpoint for the CLI.

func VerifyAppPackageContentsV2

func VerifyAppPackageContentsV2(appName string, files ...string)

VerifyAppPackageContentsV2 verifies the contents of a V2 app package by downloading the package zip and verifying the zipped files match the passed files.

func VerifyAppPackageContentsV3

func VerifyAppPackageContentsV3(appName string, files ...string)

VerifyAppPackageContentsV3 verifies the contents of a V3 app package by downloading the package zip and verifying the zipped files match the passed files.

func WaitForAppDiskToTakeEffect

func WaitForAppDiskToTakeEffect(appName string, processIndex int, instanceIndex int, shouldRestartFirst bool, expectedDisk string)

func WaitForAppMemoryToTakeEffect

func WaitForAppMemoryToTakeEffect(appName string, processIndex int, instanceIndex int, shouldRestartFirst bool, expectedMemory string)

func WaitForLogRateLimitToTakeEffect

func WaitForLogRateLimitToTakeEffect(appName string, processIndex int, instanceIndex int, shouldRestartFirst bool, expectedLogRateLimit string)

func WithBananaPantsApp

func WithBananaPantsApp(f func(dir string))

WithBananaPantsApp creates a simple application to use with your CLI command (typically CF Push). When pushing, be aware of specifying '-b staticfile_buildpack" so that your app will correctly start up with the proper buildpack.

func WithCrashingApp

func WithCrashingApp(f func(dir string))

WithCrashingApp creates an application to use with your CLI command that will not successfully start its `web` process

func WithEmptyFilesApp

func WithEmptyFilesApp(f func(dir string))

func WithHelloWorldApp

func WithHelloWorldApp(f func(dir string))

WithHelloWorldApp creates a simple application to use with your CLI command (typically CF Push). When pushing, be aware of specifying '-b staticfile_buildpack" so that your app will correctly start up with the proper buildpack.

Example
var appName string

When("the app exists", func() {
	BeforeEach(func() {
		appName = helpers.PrefixedRandomName("app")

		helpers.WithHelloWorldApp(func(appDir string) {
			Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName)).Should(Exit(0))
		})
	})
})
Output:

func WithMultiBuildpackApp

func WithMultiBuildpackApp(f func(dir string))

WithMultiBuildpackApp creates a multi-buildpack application to use with the CF push command.

func WithMultiEndpointApp

func WithMultiEndpointApp(f func(dir string))

WithMultiEndpointApp creates a simple application to use with your CLI command (typically CF Push). It has multiple endpoints which are helpful when testing http healthchecks.

func WithNoResourceMatchedApp

func WithNoResourceMatchedApp(f func(dir string))

WithNoResourceMatchedApp creates a simple application to use with your CLI command (typically CF Push). When pushing, be aware of specifying '-b staticfile_buildpack" so that your app will correctly start up with the proper buildpack.

func WithProcfileApp

func WithProcfileApp(f func(dir string))

WithProcfileApp creates an application to use with your CLI command that contains Procfile defining web and worker processes.

func WithRandomHomeDir

func WithRandomHomeDir(action func())

WithRandomHomeDir sets CF_HOME and CF_PLUGIN_HOME to a temp directory and outputs the created directory through GinkgoWriter. Then it executes the provided function 'action'. Finally, it’s restoring the previous CF_HOME and CF_PLUGIN_HOME.

func WithSidecarApp

func WithSidecarApp(f func(dir string), appName string)

func WithTaskApp

func WithTaskApp(f func(dir string), appName string)

func WriteCommand

func WriteCommand(workingDir string, env map[string]string, args []string)

WriteCommand prints the working directory, the environment variables, and 'cf' with the given arguments. Environment variables that are passwords will be redacted.

func WriteManifest

func WriteManifest(path string, manifest map[string]interface{})

WriteManifest will write out a YAML manifest file at the specified path.

func Zipit

func Zipit(source, target, prefix string) error

Zipit zips the source into a .zip file in the target dir.

Types

type AppInstanceRow

type AppInstanceRow struct {
	Index   string
	State   string
	Since   string
	CPU     string
	Memory  string
	Disk    string
	LogRate string
	Details string
}

AppInstanceRow represents an instance of a V3 app's process, as displayed in the 'cf app' output.

type AppProcessTable

type AppProcessTable struct {
	Type          string
	Sidecars      string
	InstanceCount string
	MemUsage      string
	Instances     []AppInstanceRow
}

AppProcessTable represents a process of a V3 app, as displayed in the 'cf app' output.

type AppTable

type AppTable struct {
	Processes []AppProcessTable
}

AppTable represents a V3 app as a collection of processes, as displayed in the 'cf app' output.

func ParseV3AppProcessTable

func ParseV3AppProcessTable(input []byte) AppTable

ParseV3AppProcessTable parses bytes from 'cf app' stdout into an AppTable.

type Binary

type Binary struct {
	Checksum string `json:"checksum"`
	Platform string `json:"platform"`
	URL      string `json:"url"`
}

Binary represents the metadata need to retrieve one of the binaries that makes up a plugin.

type Buildpack

type Buildpack struct {
	GUID  string `json:"guid"`
	Name  string `json:"name"`
	Stack string `json:"stack"`
}

type BuildpackFields

type BuildpackFields struct {
	Position string
	Name     string
	Enabled  string
	Locked   string
	Filename string
	Stack    string
}

BuildpackFields represents a buildpack, displayed in the 'cf buildpacks' command.

type BuildpackList

type BuildpackList struct {
	Buildpacks []Buildpack `json:"resources"`
}

type CFEnv

type CFEnv struct {
	WorkingDirectory string
	EnvVars          map[string]string
	Stdin            io.Reader
}

CFEnv represents configuration for running a 'cf' command. It allows us to run a 'cf' command with a custom working directory, specific environment variables, and stdin.

type Domain

type Domain struct {
	Org  string
	Name string
}

Domain represents a domain scoped to an organization.

func NewDomain

func NewDomain(org string, name string) Domain

NewDomain constructs a new Domain with given owning organization and name.

func (Domain) Create

func (d Domain) Create()

Create uses 'cf create-domain' to create the domain in org d.Org with name d.Name.

func (Domain) CreateInternal

func (d Domain) CreateInternal()

CreateInternal uses 'cf create-shared-domain' to create an shared, internal domain with name d.Name.

func (Domain) CreatePrivate

func (d Domain) CreatePrivate()

CreatePrivate uses 'cf create-private-domain' to create the domain in org d.Org with name d.Name.

func (Domain) CreateShared

func (d Domain) CreateShared()

CreateShared uses 'cf create-shared-domain' to create an shared domain with name d.Name.

func (Domain) CreateWithRouterGroup

func (d Domain) CreateWithRouterGroup(routerGroup string)

CreateWithRouterGroup uses 'cf create-shared-domain' to create a shared domain with name d.Name and given router group.

func (Domain) Delete

func (d Domain) Delete()

Delete uses 'cf delete-domain' to delete the domain without asking for confirmation.

func (Domain) DeletePrivate

func (d Domain) DeletePrivate()

DeletePrivate uses 'cf delete-private-domain' to delete the domain without asking for confirmation.

func (Domain) DeleteShared

func (d Domain) DeleteShared()

DeleteShared uses 'cf delete-shared-domain' to delete the shared domain without asking for confirmation.

func (Domain) V7Share

func (d Domain) V7Share(orgName string)

V7Share uses 'cf share-private-domain' to share the domain with the given org.

type MetadataLabels

type MetadataLabels map[string]string

type Plugin

type Plugin struct {
	Name     string   `json:"name"`
	Version  string   `json:"version"`
	Binaries []Binary `json:"binaries"`
}

Plugin represents a plugin object provided by a plugin repo.

type PluginCommand

type PluginCommand struct {
	Name  string
	Alias string
	Help  string
}

PluginCommand represents metadata for a CLI plugin command.

type PluginRepository

type PluginRepository struct {
	Plugins []Plugin `json:"plugins"`
}

PluginRepository represents a repo response object describing a list of plugins available.

type PluginRepositoryServerWithPlugin

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

PluginRepositoryServerWithPlugin represents a server used to provide downloadable plugins.

func NewPluginRepositoryServerWithPlugin

func NewPluginRepositoryServerWithPlugin(pluginType string, pluginName string, version string, platform string, shouldCalculateChecksum bool) *PluginRepositoryServerWithPlugin

NewPluginRepositoryServerWithPlugin is used to create a server to provide a single configurable_plugin with user provided name, version, and platform.

func (*PluginRepositoryServerWithPlugin) Cleanup

func (pluginRepoServer *PluginRepositoryServerWithPlugin) Cleanup()

Close is used to destroy the repo server and cleanup any files

func (*PluginRepositoryServerWithPlugin) Init

func (pluginRepoServer *PluginRepositoryServerWithPlugin) Init(pluginType string, pluginName string, version string, platform string, shouldCalculateChecksum bool)

Init initializes a server to provide a single configurable_plugin with user provided name, version, and platform.

func (*PluginRepositoryServerWithPlugin) PluginSize

func (pluginRepoServer *PluginRepositoryServerWithPlugin) PluginSize() int64

PluginSize is used to get the size in bytes of the single plugin provided by the pluginRepoServer

func (*PluginRepositoryServerWithPlugin) URL

func (pluginRepoServer *PluginRepositoryServerWithPlugin) URL() string

URL is used to get the pluginRepo's server url

type Route

type Route struct {
	Domain string
	Host   string
	Path   string
	Port   int
	Space  string
}

Route represents a route.

func NewRoute

func NewRoute(space string, domain string, hostname string, path string) Route

NewRoute constructs a route with given space, domain, hostname, and path.

func NewTCPRoute

func NewTCPRoute(space string, domain string, port int) Route

NewTCPRoute constructs a TCP route with given space, domain, and port.

func (Route) Create

func (r Route) Create()

Create creates a route using the 'cf create-route' command.

func (Route) Delete

func (r Route) Delete()

Delete deletes a route using the 'cf delete-route' command.

func (Route) GUID

func (r Route) GUID() string

func (Route) String

func (r Route) String() string

String stringifies a route (e.g. "host.domain.com:port/path")

func (Route) V7Create

func (r Route) V7Create()

Create creates a route using the 'cf create-route' command.

type RouterGroup

type RouterGroup struct {
	Name            string
	ReservablePorts string
	// contains filtered or unexported fields
}

func NewRouterGroup

func NewRouterGroup(name, reservablePorts string) RouterGroup

func (*RouterGroup) Create

func (rg *RouterGroup) Create()

func (*RouterGroup) Delete

func (rg *RouterGroup) Delete()

type UAAVersion

type UAAVersion struct {
	App struct {
		Version string `json:"version"`
	} `json:"app"`
}

UAAVersion a struct representation of the UAA version

func (UAAVersion) Version

func (v UAAVersion) Version() string

Version returns the version of the targeted UAA

type User

type User struct {
	GUID      string
	Username  string
	Origin    string
	CreatedAt time.Time
}

func GetUsers

func GetUsers() []User

ListUsers returns all the users in the targeted environment.

func GetUsersV3

func GetUsersV3() []User

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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