apptest

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory)

Run runs the entire workspace app test suite against deployments minted by the provided factory.

appHostIsPrimary is true if the app host is also the primary coder API server. This disables any tests that test API passthrough or rely on the app server not being the API server. nolint:revive

Types

type App

type App struct {
	Username      string
	WorkspaceName string
	// AgentName is optional, except for when proxying to a port. AgentName is
	// always ignored when making a path app URL.
	//
	// Set WorkspaceName to `workspace.agent` if you want to generate a path app
	// URL with an agent name.
	AgentName     string
	AppSlugOrPort string

	Query string
}

App is similar to httpapi.ApplicationURL but with a Query field.

type Deployment

type Deployment struct {
	Options *DeploymentOptions

	// SDKClient should be logged in as the admin user.
	SDKClient      *codersdk.Client
	FirstUser      codersdk.CreateFirstUserResponse
	PathAppBaseURL *url.URL
}

Deployment is a license-agnostic deployment with all the fields that apps tests need.

type DeploymentFactory

type DeploymentFactory func(t *testing.T, opts *DeploymentOptions) *Deployment

DeploymentFactory generates a deployment with an API client, a path base URL, and a subdomain app host URL.

type DeploymentOptions

type DeploymentOptions struct {
	AppHost                              string
	DisablePathApps                      bool
	DisableSubdomainApps                 bool
	DangerousAllowPathAppSharing         bool
	DangerousAllowPathAppSiteOwnerAccess bool
	ServeHTTPS                           bool
	// contains filtered or unexported fields
}

DeploymentOptions are the options for creating a *Deployment with a DeploymentFactory.

type Details added in v0.23.0

type Details struct {
	*Deployment

	Me codersdk.User

	Workspace *codersdk.Workspace
	Agent     *codersdk.WorkspaceAgent
	AppPort   uint16

	Apps struct {
		Fake          App
		Owner         App
		Authenticated App
		Public        App
		Port          App
	}
}

Details are the full test details returned from setupProxyTestWithFactory.

func (*Details) AppClient added in v0.23.0

func (d *Details) AppClient(t *testing.T) *codersdk.Client

AppClient returns a *codersdk.Client that will route all requests to the app server. API requests will fail with this client. Any redirect responses are not followed by default.

The client is authenticated as the first user by default.

func (*Details) PathAppURL added in v0.23.0

func (d *Details) PathAppURL(app App) *url.URL

PathAppURL returns the URL for the given path app.

func (*Details) SubdomainAppURL added in v0.23.0

func (d *Details) SubdomainAppURL(app App) *url.URL

SubdomainAppURL returns the URL for the given subdomain app.

Jump to

Keyboard shortcuts

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