### Install go-version Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/credhub-service-broker/vendor/github.com/hashicorp/go-version/README.md Install the go-version library using the standard go get command. ```bash $ go get github.com/hashicorp/go-version ``` -------------------------------- ### Install go.yaml.in/yaml/v3 Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/catnip/vendor/go.yaml.in/yaml/v3/README.md Use 'go get' to install the v3 of the yaml package. ```bash go get go.yaml.in/yaml/v3 ``` -------------------------------- ### Install go-diodes Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/code.cloudfoundry.org/go-diodes/README.md Use go get to install the go-diodes library. ```bash go get code.cloudfoundry.org/go-diodes ``` -------------------------------- ### Docker App Lifecycle Example Source: https://context7.com/cloudfoundry/cf-acceptance-tests/llms.txt Illustrates the sequence of operations for managing a Docker application lifecycle, from creation to starting. ```go // Docker app lifecycle example: // appGuid := CreateDockerApp(appName, spaceGuid, `{"foo":"bar"}`) // packageGuid := CreateDockerPackage(appGuid, "cloudfoundry/diego-docker-app:latest") // buildGuid := StageDockerPackage(packageGuid) // WaitForBuildToStage(buildGuid) // dropletGuid := GetDropletFromBuild(buildGuid) // AssignDropletToApp(appGuid, dropletGuid) // StartApp(appGuid) ``` -------------------------------- ### Install UUID package Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/credhub-service-broker/vendor/github.com/satori/go.uuid/README.md Use the standard go get command to fetch the package. ```bash $ go get github.com/satori/go.uuid ``` -------------------------------- ### Install the YAML package Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/gopkg.in/yaml.v3/README.md Use the go get command to add the package to your project. ```bash go get gopkg.in/yaml.v3 ``` -------------------------------- ### Install utfbom package Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/go.step.sm/crypto/internal/utils/utfbom/README.md Use the go get command to add the package to your Go workspace. ```bash go get -u github.com/dimchansky/utfbom ``` -------------------------------- ### Install NOAA with go get Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/cloudfoundry/noaa/v2/README.md Use 'go get' to import the NOAA project and all its dependencies into your $GOPATH. ```bash $ echo $GOPATH /Users/myuser/go $ go get github.com/cloudfoundry/noaa $ ls ~/go/src/github.com/cloudfoundry/ noaa/ sonde-go/ ``` -------------------------------- ### Initialize and Start a SOCKS5 Server Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/credhub-service-broker/vendor/github.com/cloudfoundry/go-socks5/README.md Creates a basic SOCKS5 server configuration and starts the server on a specified local address and port. ```go // Create a SOCKS5 server conf := &socks5.Config{} server, err := socks5.New(conf) if err != nil { panic(err) } // Create SOCKS5 proxy on localhost port 8000 if err := server.ListenAndServe("tcp", "127.0.0.1:8000"); err != nil { panic(err) } ``` -------------------------------- ### Basic Chi Router Setup Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/catnip/vendor/github.com/go-chi/chi/v5/README.md Sets up a minimal Chi router with a logger middleware and a simple GET route. Use this for basic web server functionality. ```go package main import ( "net/http" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" ) func main() { r := chi.NewRouter() r.Use(middleware.Logger) r.Get("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("welcome")) }) http.ListenAndServe(":3000", r) } ``` -------------------------------- ### Install Ginkgo Locally Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/onsi/ginkgo/v2/CONTRIBUTING.md Installs the Ginkgo binary locally using Go modules. Ensure you have Go installed and configured. ```bash go install ./... ``` -------------------------------- ### Install chi router Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/catnip/vendor/github.com/go-chi/chi/v5/README.md Use the go get command to add the chi v5 package to your Go project. ```sh go get -u github.com/go-chi/chi/v5 ``` -------------------------------- ### Example output Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/gopkg.in/yaml.v3/README.md The expected output generated by the provided Go example code. ```text --- t: {Easy! {2 [3 4]}} --- t dump: a: Easy! b: c: 2 d: [3, 4] --- m: map[a:Easy! b:map[c:2 d:[3 4]]] --- m dump: a: Easy! b: c: 2 d: - 3 - 4 ``` -------------------------------- ### Create V3 App with Environment Variables Source: https://context7.com/cloudfoundry/cf-acceptance-tests/llms.txt Creates a v3 application with specified name, space GUID, and environment variables. Returns the GUID of the newly created app. ```go package v3_helpers import ( "encoding/json" "fmt" "github.com/cloudfoundry/cf-test-helpers/v2/cf" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) // CreateApp - Create a v3 app with environment variables func CreateApp(appName, spaceGuid, environmentVariables string) string { session := cf.Cf("curl", "/v3/apps", "-X", "POST", "-d", fmt.Sprintf(`{"name":"%s", "relationships": {"space": {"data": {"guid": "%s"}}}, "environment_variables":%s}`, appName, spaceGuid, environmentVariables)) bytes := session.Wait().Out.Contents() var app struct { Guid string `json:"guid"` } json.Unmarshal(bytes, &app) return app.Guid } ``` -------------------------------- ### Install pgzip and dependencies Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/klauspost/pgzip/README.md Commands to install the pgzip package and its required dependencies. ```bash go get github.com/klauspost/pgzip/... ``` ```bash go get -u github.com/klauspost/compress ``` -------------------------------- ### Install Archiver CLI with Go Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/mholt/archiver/v3/README.md Installs the runnable 'arc' binary to your Go bin directory using 'go install'. Ensure your Go bin directory is in your PATH. ```go go install github.com/mholt/archiver/v3/cmd/arc@latest ``` -------------------------------- ### Middleware Handler Example Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/catnip/vendor/github.com/go-chi/chi/v5/README.md An example of a standard net/http middleware handler in Go. ```APIDOC ## Middleware Handler Example ### Description This example demonstrates a standard `net/http` middleware handler that sets a value on the request context. ### Code ```go // HTTP middleware setting a value on the request context func MyMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // create new context from `r` request context, and assign key "user" to value of "123" ctx := context.WithValue(r.Context(), "user", "123") // call the next handler in the chain, passing the response writer and // the updated request object with the new context value. next.ServeHTTP(w, r.WithContext(ctx)) }) } ``` ``` -------------------------------- ### Install lz4 package Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/pierrec/lz4/v4/README.md Use the go toolchain to fetch the lz4 package. ```bash go get github.com/pierrec/lz4/v4 ``` -------------------------------- ### Request Handler Example Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/catnip/vendor/github.com/go-chi/chi/v5/README.md An example of a standard net/http request handler in Go that accesses context values. ```APIDOC ## Request Handler Example ### Description This example shows a standard `net/http` request handler that retrieves a value previously set on the request context by a middleware. ### Code ```go // HTTP handler accessing data from the request context. func MyRequestHandler(w http.ResponseWriter, r *http.Request) { // here we read from the request context and fetch out "user" key set in // the MyMiddleware example above. user := r.Context().Value("user").(string) // respond to the client w.Write([]byte(fmt.Sprintf("hi %s", user))) } ``` ``` -------------------------------- ### Install lz4c CLI tool Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/pierrec/lz4/v4/README.md Install the command line interface tool for LZ4 file operations. ```bash go install github.com/pierrec/lz4/v4/cmd/lz4c ``` -------------------------------- ### GET /env Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/nora/README.md Prints out the entire environment as JSON. ```APIDOC ## GET /env ### Description Prints out the entire environment as JSON. ### Method GET ### Endpoint /env ### Response #### Success Response (200) - **environment** (object) - A JSON object containing all environment variables. ``` -------------------------------- ### GET /config/all Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/service_broker/README.md Fetches the entire state of the broker, including configuration, instances, and bindings. ```APIDOC ## GET /config/all ### Description Retrieves the full state of the broker, encompassing configuration, service instances, and bindings. ### Method GET ### Endpoint /config/all ### Response #### Success Response (200) - **state** (object) - The complete state of the broker. ``` -------------------------------- ### GET / Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/nora/README.md Hello Nora endpoint. ```APIDOC ## GET / ### Description Hello Nora endpoint. ### Method GET ### Endpoint / ### Response #### Success Response (200) - **message** (string) - A greeting message. ``` -------------------------------- ### Implement Standard Middleware Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/catnip/vendor/github.com/go-chi/chi/v5/README.md Example of a net/http middleware that injects a value into the request context. ```go // HTTP middleware setting a value on the request context func MyMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // create new context from `r` request context, and assign key `"user"` // to value of `"123"` ctx := context.WithValue(r.Context(), "user", "123") // call the next handler in the chain, passing the response writer and // the updated request object with the new context value. // // note: context.Context values are nested, so any previously set // values will be accessible as well, and the new `"user"` key // will be accessible from this point forward. next.ServeHTTP(w, r.WithContext(ctx)) }) } ``` -------------------------------- ### POST /stress_testers Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/dora/README.md Starts the stress tester with specified CPU and I/O load. ```APIDOC ## POST /stress_testers ### Description Starts the stress tester process with specified CPU and I/O load. ### Method POST ### Endpoint /stress_testers ### Query Parameters - **cpu** (integer) - Optional - The number of CPU processes to start. - **io** (integer) - Optional - The number of I/O processes to start. ### Response #### Success Response (200) - **body** (string) - Confirmation message that the stress tester has started. ``` -------------------------------- ### GET /ready/:new_ready_state Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/dora/README.md Sets the readiness state of the application. Accepts 'true' or 'false'. ```APIDOC ## GET /ready/:new_ready_state ### Description Sets the readiness state of the application. When `new_ready_state` is `false`, subsequent calls to `/ready` will respond with status code 500. When `new_ready_state` is `true`, subsequent calls to `/ready` will respond with status code 200. ### Method GET ### Endpoint /ready/:new_ready_state ### Path Parameters - **new_ready_state** (boolean) - Required - The new readiness state ('true' or 'false'). ### Response #### Success Response (200) - **body** (string) - Confirmation of the readiness state change. ``` -------------------------------- ### Stage Docker Package Source: https://context7.com/cloudfoundry/cf-acceptance-tests/llms.txt Stages a Docker package to prepare it for deployment. Requires the package GUID. ```go // StageDockerPackage - Stage a Docker package func StageDockerPackage(packageGuid string) string { stageBody := fmt.Sprintf(`{"lifecycle": { "type" : "docker", "data": {} }, "package": { "guid" : "%s"}}`, packageGuid) session := cf.Cf("curl", "/v3/builds", "-X", "POST", "-d", stageBody) bytes := session.Wait().Out.Contents() var build struct { Guid string `json:"guid"` } json.Unmarshal(bytes, &build) return build.Guid } ``` -------------------------------- ### Install Archiver Package Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/mholt/archiver/v3/README.md Use this command to add the archiver package as a dependency in your Go project. ```bash go get github.com/mholt/archiver/v3 ``` -------------------------------- ### Download and Navigate to Project Sources Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/catnip/vendor/github.com/go-chi/chi/v5/CONTRIBUTING.md Use these commands to download the project sources and switch to the project directory. Ensure Go is installed and configured. ```bash go get -u -d github.com/go-chi/chi cd $GOPATH/src/github.com/go-chi/chi ``` -------------------------------- ### Configure and use pgzip writer Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/klauspost/pgzip/README.md Example of initializing a writer, setting concurrency parameters, and writing data. ```go var b bytes.Buffer w := gzip.NewWriter(&b) w.SetConcurrency(100000, 10) w.Write([]byte("hello, world\n")) w.Close() ``` -------------------------------- ### Build and Run App Logs Sample Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/cloudfoundry/noaa/v2/README.md Build the 'app_logs' sample application and run it to stream logs for a particular application. Requires APP_GUID to be set. ```bash go build -o bin/app_logs samples/app_logs/main.go bin/app_logs ``` -------------------------------- ### GET /id Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/dora/README.md Retrieves the unique identifier (instance GUID) of the current application instance. ```APIDOC ## GET /id ### Description Returns the instance ID of the application. ### Method GET ### Endpoint /id ### Response #### Success Response (200) - **body** (string) - The instance ID. ``` -------------------------------- ### Install Compression Library Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/dsnet/compress/README.md Command to fetch the library using the Go toolchain. Requires Go 1.9 or higher. ```bash go get -u github.com/dsnet/compress ``` -------------------------------- ### Build and Run Container Metrics Sample Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/cloudfoundry/noaa/v2/README.md Build the 'container_metrics' sample application and run it to stream container metrics for a specified application ID. Refer to the sample's README.md for test environment setup. ```bash go build -o bin/container_metrics samples/container_metrics/consumer/main.go bin/container_metrics ``` -------------------------------- ### Build and Run Firehose Sample Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/cloudfoundry/noaa/v2/README.md Build the 'firehose' sample application and run it to stream metrics data and logs for all applications. Each subscriber receives the entire stream, with data distributed evenly among clients with a common subscription_id. ```bash go build -o bin/firehose samples/firehose/main.go bin/firehose ``` -------------------------------- ### Preview Documentation Changes Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/onsi/ginkgo/v2/CONTRIBUTING.md Builds and serves the Ginkgo documentation locally using Jekyll. Requires Ruby and Bundler to be installed. ```bash bundle && bundle exec jekyll serve ``` -------------------------------- ### Create Deployment for Droplet Source: https://context7.com/cloudfoundry/cf-acceptance-tests/llms.txt Deploys a specific droplet to an application. Requires both the application GUID and the droplet GUID. ```go // CreateDeploymentForDroplet - Deploy a specific droplet func CreateDeploymentForDroplet(appGuid, dropletGuid string) string { deploymentRequestBody := fmt.Sprintf(`{"droplet": {"guid": "%s"}, "relationships": {"app": {"data": {"guid": "%s"}}}}`, dropletGuid, appGuid) session := cf.Cf("curl", "/v3/deployments", "-X", "POST", "-d", deploymentRequestBody).Wait() var deployment struct { Guid string `json:"guid"` } json.Unmarshal(session.Out.Contents(), &deployment) return deployment.Guid } ``` -------------------------------- ### GET /session Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/dora/README.md Sets up cookies for a sticky session via a GET request, allowing for easy browser experimentation. ```APIDOC ## GET /session ### Description Sets up cookies for a sticky session via a GET request. This endpoint is useful for experimenting with sticky sessions directly in a browser. ### Method GET ### Endpoint /session ### Response #### Success Response (200) - **Set-Cookie** (string) - Cookies, including `JSESSIONID` and `VCAP_ID`, to enable sticky sessions. ``` -------------------------------- ### Install Archiver CLI with webi on Windows Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/mholt/archiver/v3/README.md Installs the 'arc' command-line tool on Windows using webi. It uses PowerShell for execution. ```powershell curl.exe -fsS -A MS https://webinstall.dev/arc | powershell ``` -------------------------------- ### Run mkall.sh for Current OS/Arch (Old Build System) Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/golang.org/x/sys/unix/README.md Use this command to generate Go files for your current OS and architecture when using the old build system. Ensure GOOS and GOARCH are set correctly. ```bash mkall.sh ``` -------------------------------- ### Install Archiver CLI with webi on Linux/macOS Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/mholt/archiver/v3/README.md Installs the 'arc' command-line tool and its dependencies using webi. It adds the tool to ~/.local/bin/ and updates your PATH. ```bash curl -fsS https://webinstall.dev/arc | bash ``` -------------------------------- ### Push an application with standard configuration Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/README.md Use this pattern to push apps with defined memory limits, buildpacks, and domains. Ensure the suite's default constants are used unless specific test requirements dictate otherwise. ```go Expect(cf.Cf("push", appName, "-b", buildpackName, // specify buildpack "-m", DEFAULT_MEMORY_LIMIT, // specify memory limit "-d", Config.AppsDomain, // specify app domain ).Wait(Config.CfPushTimeoutDuration())).To(Exit(0)) ``` -------------------------------- ### Export App GUID Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/cloudfoundry/noaa/v2/README.md Export the APP_GUID environment variable by running '$ cf app APP --guid'. This is required for the app_logs sample application. ```bash export APP_GUID=55fdb274-d6c9-4b8c-9b1f-9b7e7f3a346c ``` -------------------------------- ### Manually install Archiver CLI binary Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/mholt/archiver/v3/README.md Provides steps for manually installing the 'arc' binary by downloading it from GitHub Releases and placing it in your system's PATH. ```bash chmod a+x ~/Downloads/arc_* mkdir -p ~/.local/bin mv ~/Downloads/arc_* ~/.local/bin/arc ``` ```bash chmod a+x ~/Downloads/arc_* sudo mkdir -p /usr/local/bin sudo mv ~/Downloads/arc_* /usr/local/bin/arc ``` ```bash echo 'PATH="$HOME:/.local/bin:$PATH"' >> ~/.bashrc ``` -------------------------------- ### Create Deployment Source: https://context7.com/cloudfoundry/cf-acceptance-tests/llms.txt Initiates a rolling deployment for an application using the v3 API. Requires the application GUID. ```go // CreateDeployment - Create a rolling deployment for an app func CreateDeployment(appGuid string) string { deploymentPath := "/v3/deployments" deploymentRequestBody := fmt.Sprintf(`{"relationships": {"app": {"data": {"guid": "%s"}}}}`, appGuid) session := cf.Cf("curl", deploymentPath, "-X", "POST", "-d", deploymentRequestBody).Wait() Expect(session).To(Exit(0)) var deployment struct { Guid string `json:"guid"` } bytes := session.Wait().Out.Contents() json.Unmarshal(bytes, &deployment) return deployment.Guid } ``` -------------------------------- ### Convert Format Strings to Structured Logs Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/go-logr/logr/README.md Examples of migrating legacy format-string logging to structured key-value pairs. ```go klog.V(4).Infof("Client is returning errors: code %v, error %v", responseCode, err) ``` ```go logger.Error(err, "client returned an error", "code", responseCode) ``` ```go klog.V(4).Infof("Got a Retry-After %ds response for attempt %d to %v", seconds, retries, url) ``` ```go logger.V(4).Info("got a retry-after response when requesting url", "attempt", retries, "after seconds", seconds, "url", url) ``` -------------------------------- ### GET /exit Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/nora/README.md Kills Nora. ```APIDOC ## GET /exit ### Description Kills Nora. ### Method GET ### Endpoint /exit ``` -------------------------------- ### GET /id Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/nora/README.md The id of the instance. ```APIDOC ## GET /id ### Description The id of the instance. ### Method GET ### Endpoint /id ### Response #### Success Response (200) - **id** (string) - The instance ID. ``` -------------------------------- ### Build and Run HTTP/2 Only App Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/http2/README.md Build the application using 'go build', then run it by setting the PORT environment variable. Test with 'curl' using the --http2 flag. ```bash go build ``` ```bash PORT=8080 ./http2 ``` ```bash curl localhost:8080 --http2 ``` -------------------------------- ### GET /redirect/:path Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/nora/README.md Redirects to :path. ```APIDOC ## GET /redirect/:path ### Description Redirects to :path. ### Method GET ### Endpoint /redirect/:path ### Parameters #### Path Parameters - **path** (string) - Required - The path to redirect to. ``` -------------------------------- ### GET /log/stop Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/dora/README.md Stops the log service. ```APIDOC ## GET /log/stop ### Description Stops the log service. ### Method GET ### Endpoint /log/stop ### Response #### Success Response (200) - **body** (string) - A confirmation message that the log service has been stopped. ``` -------------------------------- ### GET /print_err/:output Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/nora/README.md Logs :output as an error. ```APIDOC ## GET /print_err/:output ### Description Logs :output as an error. ### Method GET ### Endpoint /print_err/:output ### Parameters #### Path Parameters - **output** (string) - Required - The string to log as an error. ``` -------------------------------- ### Show mkall.sh Commands (Old Build System) Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/golang.org/x/sys/unix/README.md This command displays the build commands that will be executed by mkall.sh without actually running them. Useful for understanding the build process. ```bash mkall.sh -n ``` -------------------------------- ### GET /print/:output Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/nora/README.md Prints :output to the logs. ```APIDOC ## GET /print/:output ### Description Prints :output to the logs. ### Method GET ### Endpoint /print/:output ### Parameters #### Path Parameters - **output** (string) - Required - The string to print to the logs. ``` -------------------------------- ### Push Ruby Hello World App Source: https://context7.com/cloudfoundry/cf-acceptance-tests/llms.txt Use this helper to push the Ruby hello world application. It configures the Ruby buildpack and specifies the hello world asset. ```go // HelloWorldWithArgs - Push Ruby hello world app func HelloWorldWithArgs(appName string, args ...string) []string { pushArgs := []string{ "push", appName, "-b", Config.GetRubyBuildpackName(), "-p", assets.NewAssets().HelloWorld, } return append(pushArgs, args...) } ``` -------------------------------- ### GET /headers Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/nora/README.md Prints an array of the request headers. ```APIDOC ## GET /headers ### Description Prints an array of the request headers. ### Method GET ### Endpoint /headers ### Response #### Success Response (200) - **headers** (array) - An array of request headers. ``` -------------------------------- ### Create Root Logger Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/catnip/vendor/github.com/go-logr/logr/README.md Initialize the root logger in your application's main function. This sets up the chosen logging implementation with initial parameters. ```go func main() { // ... other setup code ... // Create the "root" logger. We have chosen the "logimpl" implementation, // which takes some initial parameters and returns a logr.Logger. logger := logimpl.New(param1, param2) // ... other setup code ... } ``` -------------------------------- ### Initialize the Root Logger Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/go-logr/logr/README.md Create a root logger instance using a specific implementation early in the application lifecycle. ```go func main() { // ... other setup code ... // Create the "root" logger. We have chosen the "logimpl" implementation, // which takes some initial parameters and returns a logr.Logger. logger := logimpl.New(param1, param2) // ... other setup code ... ``` -------------------------------- ### GET /config Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/service_broker/README.md Fetches the current configuration of the broker. ```APIDOC ## GET /config ### Description Retrieves the current configuration settings for the broker. ### Method GET ### Endpoint /config ### Response #### Success Response (200) - **config** (object) - The current broker configuration object. ``` -------------------------------- ### GET /myip Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/dora/README.md Returns the IP address of the application container. ```APIDOC ## GET /myip ### Description Returns the IP address of the application container. ### Method GET ### Endpoint /myip ### Response #### Success Response (200) - **body** (string) - The IP address of the container. ``` -------------------------------- ### Ginkgo Spec Example Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/vendor/github.com/onsi/ginkgo/v2/README.md Illustrates a typical Ginkgo test suite structure, including Describe, BeforeEach, When, Context, It, and assertions with Gomega's Expect. Use for defining complex test scenarios. ```go import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ... ) var _ = Describe("Checking books out of the library", Label("library"), func() { var library *libraries.Library var book *books.Book var valjean *users.User BeforeEach(func() { library = libraries.NewClient() book = &books.Book{ Title: "Les Miserables", Author: "Victor Hugo", } valjean = users.NewUser("Jean Valjean") }) When("the library has the book in question", func() { BeforeEach(func(ctx SpecContext) { Expect(library.Store(ctx, book)).To(Succeed()) }) Context("and the book is available", func() { It("lends it to the reader", func(ctx SpecContext) { Expect(valjean.Checkout(ctx, library, "Les Miserables")).To(Succeed()) Expect(valjean.Books()).To(ContainElement(book)) Expect(library.UserWithBook(ctx, book)).To(Equal(valjean)) }, SpecTimeout(time.Second * 5)) }) Context("but the book has already been checked out", func() { var javert *users.User BeforeEach(func(ctx SpecContext) { javert = users.NewUser("Javert") Expect(javert.Checkout(ctx, library, "Les Miserables")).To(Succeed()) }) It("tells the user", func(ctx SpecContext) { err := valjean.Checkout(ctx, library, "Les Miserables") Expect(err).To(MatchError("Les Miserables is currently checked out")) }, SpecTimeout(time.Second * 5)) It("lets the user place a hold and get notified later", func(ctx SpecContext) { Expect(valjean.Hold(ctx, library, "Les Miserables")).To(Succeed()) Expect(valjean.Holds(ctx)).To(ContainElement(book)) By("when Javert returns the book") Expect(javert.Return(ctx, library, book)).To(Succeed()) By("it eventually informs Valjean") notification := "Les Miserables is ready for pick up" Eventually(ctx, valjean.Notifications).Should(ContainElement(notification)) Expect(valjean.Checkout(ctx, library, "Les Miserables")).To(Succeed()) Expect(valjean.Books(ctx)).To(ContainElement(book)) Expect(valjean.Holds(ctx)).To(BeEmpty()) }, SpecTimeout(time.Second * 10)) }) }) When("the library does not have the book in question", func() { It("tells the reader the book is unavailable", func(ctx SpecContext) { err := valjean.Checkout(ctx, library, "Les Miserables") Expect(err).To(MatchError("Les Miserables is not in the library catalog")) }, SpecTimeout(time.Second * 5)) }) }) ``` ```go import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ... ) var _ = Describe("Checking books out of the library", Label("library"), func() { var library *libraries.Library var book *books.Book var valjean *users.User BeforeEach(func() { library = libraries.NewClient() book = &books.Book{ Title: "Les Miserables", Author: "Victor Hugo", } valjean = users.NewUser("Jean Valjean") }) When("the library has the book in question", func() { BeforeEach(func(ctx SpecContext) { Expect(library.Store(ctx, book)).To(Succeed()) }) Context("and the book is available", func() { It("lends it to the reader", func(ctx SpecContext) { Expect(valjean.Checkout(ctx, library, "Les Miserables")).To(Succeed()) Expect(valjean.Books()).To(ContainElement(book)) Expect(library.UserWithBook(ctx, book)).To(Equal(valjean)) }, SpecTimeout(time.Second * 5)) }) Context("but the book has already been checked out", func() { var javert *users.User BeforeEach(func(ctx SpecContext) { javert = users.NewUser("Javert") Expect(javert.Checkout(ctx, library, "Les Miserables")).To(Succeed()) }) It("tells the user", func(ctx SpecContext) { err := valjean.Checkout(ctx, library, "Les Miserables") Expect(err).To(MatchError("Les Miserables is currently checked out")) }, SpecTimeout(time.Second * 5)) It("lets the user place a hold and get notified later", func(ctx SpecContext) { Expect(valjean.Hold(ctx, library, "Les Miserables")).To(Succeed()) Expect(valjean.Holds(ctx)).To(ContainElement(book)) By("when Javert returns the book") Expect(javert.Return(ctx, library, book)).To(Succeed()) By("it eventually informs Valjean") notification := "Les Miserables is ready for pick up" Eventually(ctx, valjean.Notifications).Should(ContainElement(notification)) Expect(valjean.Checkout(ctx, library, "Les Miserables")).To(Succeed()) Expect(valjean.Books(ctx)).To(ContainElement(book)) Expect(valjean.Holds(ctx)).To(BeEmpty()) }, SpecTimeout(time.Second * 10)) }) }) When("the library does not have the book in question", func() { It("tells the reader the book is unavailable", func(ctx SpecContext) { err := valjean.Checkout(ctx, library, "Les Miserables") Expect(err).To(MatchError("Les Miserables is not in the library catalog")) }, SpecTimeout(time.Second * 5)) }) }) ``` -------------------------------- ### GET /env.json Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/dora/README.md Prints all environment variables as a JSON object. ```APIDOC ## GET /env.json ### Description Prints the entire environment as a JSON object. ### Method GET ### Endpoint /env.json ### Response #### Success Response (200) - **body** (object) - A JSON object representing the environment variables. ``` -------------------------------- ### Create V3 Bits Package Source: https://context7.com/cloudfoundry/cf-acceptance-tests/llms.txt Creates a 'bits' type package for a given application GUID. This is the first step in uploading application code. ```go // CreatePackage - Create a bits package for an app func CreatePackage(appGuid string) string { session := cf.Cf("curl", "/v3/packages", "-X", "POST", "-d", fmt.Sprintf(`{"relationships":{"app":{"data":{"guid":"%s"}}},"type":"bits"}`, appGuid)) bytes := session.Wait().Out.Contents() var pac struct { Guid string `json:"guid"` } json.Unmarshal(bytes, &pac) return pac.Guid } ``` -------------------------------- ### Push Windows Binary App Source: https://context7.com/cloudfoundry/cf-acceptance-tests/llms.txt Use this helper to push a Windows binary application. It configures the Windows stack, binary buildpack, and specifies the Windows catnip executable. ```go // WindowsCatnipWithArgs - Push Windows binary app func WindowsCatnipWithArgs(appName string, args ...string) []string { pushArgs := []string{ "push", appName, "-s", Config.GetWindowsStack(), "-b", Config.GetBinaryBuildpackName(), "-p", assets.NewAssets().Catnip, "-c", "./catnip.exe", } return append(pushArgs, args...) } ``` -------------------------------- ### GET / Source: https://github.com/cloudfoundry/cf-acceptance-tests/blob/develop/assets/dora/README.md A simple endpoint that returns a 'Hello Dora' message. ```APIDOC ## GET / ### Description Returns a greeting message. ### Method GET ### Endpoint / ### Response #### Success Response (200) - **body** (string) - A greeting message. ```