tests

package
v2.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 102 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EdgeClientApiPath     = "/edge/client/v1"
	EdgeManagementApiPath = "/edge/management/v1"
)
View Source
const Ha3DataDir = "testdata/ha-3-data"

Ha3DataDir is the parent raft data directory used by the Ha3 config set. It is cleaned by StartHaCluster before each run and must contain the cluster.dataDir of every ha-3 controller.

Variables

View Source
var DefaultATS = ConfigSet{
	Name:           "default-ats",
	CtrlConfig:     "testdata/configs/default-ats/ctrl.yml",
	EdgeRouter:     "testdata/configs/default-ats/edge-router.yml",
	TunnelerRouter: "testdata/configs/default-ats/tunneler-router.yml",
	TransitRouter:  "testdata/configs/default-ats/transit-router.yml",
	FabricRouters: []string{
		"testdata/configs/default-ats/fabric-router-1.yml",
		"testdata/configs/default-ats/fabric-router-2.yml",
	},
}

DefaultATS is the standard full-stack config set used by the majority of the integration test suite. It covers the controller, edge router, tunneler router, transit router, and the fabric-only router pair used by link tests.

View Source
var DefaultFormats strfmt.Registry = NewRegistry()
View Source
var DisabledOidcAutoBinding = ConfigSet{
	Name:       "disabled-oidc-auto-binding",
	CtrlConfig: "testdata/configs/disabled-oidc-auto-binding/ctrl.yml",
}

DisabledOidcAutoBinding is a controller-only config set with the edge-oidc binding omitted from the web listener AND disableOidcAutoBinding set to true. Used to verify that the auto-binding behaviour is suppressed when the operator opts out, leaving OIDC absent from the running controller.

View Source
var DualOidcServers = ConfigSet{
	Name:       "dual-oidc-servers",
	CtrlConfig: "testdata/configs/dual-oidc-servers/ctrl.yml",
}

DualOidcServers is a controller-only config set with two web server entries, each on a different port and each hosting the edge-oidc API. Used to verify that the OIDC discovery document returns issuer-specific endpoint URLs that reflect the port the client connected to.

View Source
var Ha3 = ConfigSet{
	Name:       "ha-3",
	CtrlConfig: "testdata/configs/ha-3/ctrl1.yml",
	PeerCtrlConfigs: []string{
		"testdata/configs/ha-3/ctrl2.yml",
		"testdata/configs/ha-3/ctrl3.yml",
	},
	EdgeRouter: "testdata/configs/ha-3/edge-router.yml",
}

Ha3 is a three-controller raft cluster config set whose edge signing CA root is distinct from the ctrl-channel root CA. Each controller signs identity certs with its own intermediate under the shared signing root. Used to exercise first-party client cert validation when the signing CA and ctrl-channel CA differ, including certs issued by a controller other than the one a router is subscribed to.

View Source
var NoExplicitOIDC = ConfigSet{
	Name:       "no-explicit-oidc",
	CtrlConfig: "testdata/configs/no-explicit-oidc/ctrl.yml",
}

NoExplicitOIDC is a controller-only config set with the edge-oidc binding omitted from the web listener. Used to verify that the controller's ensureOidcOnClientApiServer validator automatically adds the OIDC API when it is not explicitly present in the configuration.

View Source
var WildcardOidcServer = ConfigSet{
	Name:       "wildcard-oidc-server",
	CtrlConfig: "testdata/configs/wildcard-oidc-server/ctrl.yml",
}

WildcardOidcServer is a controller-only config set that supplies a wildcard (*.wildcard.test) server certificate via alt_server_certs alongside an ordinary primary server cert, modeling a controller fronted by a wildcard (e.g. LetsEncrypt) certificate. Used to verify that the OIDC discovery document served to a concrete host under the wildcard advertises an issuer derived from that request host, rather than a literal-wildcard issuer or a 404.

Functions

func IsJwt

func IsJwt(token string) bool

func IsURI

func IsURI(rawurl string) bool

func NewRegistry

func NewRegistry() strfmt.Registry

func NewVersionProviderTest

func NewVersionProviderTest() versions.VersionProvider

func ST

func ST(t time.Time) *strfmt.DateTime

ST returns a pointer to a strfmt.Date time. A helper function for creating rest_model types

func ToPtr

func ToPtr[T any](in T) *T

Types

type ClientHelperClient

type ClientHelperClient struct {
	*edgeApis.ClientApiClient
	// contains filtered or unexported fields
}

func (*ClientHelperClient) CompleteJwtTokenEnrollmentToCertAuth

func (helper *ClientHelperClient) CompleteJwtTokenEnrollmentToCertAuth(enrollmentJwt string) (*edgeApis.CertCredentials, error)

func (*ClientHelperClient) CompleteJwtTokenEnrollmentToTokenAuth

func (helper *ClientHelperClient) CompleteJwtTokenEnrollmentToTokenAuth(enrollmentJwt string) error

func (*ClientHelperClient) CompleteOttCaEnrollment

func (helper *ClientHelperClient) CompleteOttCaEnrollment(enrollmentToken string, clientCert []*x509.Certificate, clientKey crypto.PrivateKey) (*edgeApis.CertCredentials, error)

func (*ClientHelperClient) CompleteOttEnrollment

func (helper *ClientHelperClient) CompleteOttEnrollment(enrollmentToken string) (*edgeApis.CertCredentials, error)

func (*ClientHelperClient) CompleteOttGenericEnrollment

func (helper *ClientHelperClient) CompleteOttGenericEnrollment(enrollmentToken string) (*edgeApis.CertCredentials, error)

func (*ClientHelperClient) CompleteUpdbEnrollment

func (helper *ClientHelperClient) CompleteUpdbEnrollment(enrollmentToken string, username string, password string) (*edgeApis.UpdbCredentials, error)

func (*ClientHelperClient) CreateCurrentApiSessionCertificate added in v2.0.3

func (helper *ClientHelperClient) CreateCurrentApiSessionCertificate() (*rest_model.CurrentAPISessionCertificateCreateResponse, error)

CreateCurrentApiSessionCertificate generates a new key and CSR, then submits it to create an API session certificate for the currently authenticated API Session.

func (*ClientHelperClient) CreateTotpMfaEnrollment

func (helper *ClientHelperClient) CreateTotpMfaEnrollment() (*rest_model.DetailMfa, error)

func (*ClientHelperClient) EnrollTotpMfa

func (helper *ClientHelperClient) EnrollTotpMfa() (*TotpProvider, *rest_model.DetailMfa, error)

func (*ClientHelperClient) ExtendCertsWithAuthenticatorId

func (helper *ClientHelperClient) ExtendCertsWithAuthenticatorId(authenticatorId string) (*edgeApis.CertCredentials, error)

func (*ClientHelperClient) GetCurrentApiSessionDetail

func (helper *ClientHelperClient) GetCurrentApiSessionDetail() (*rest_model.CurrentAPISessionDetail, error)

func (*ClientHelperClient) GetTotpMfa

func (helper *ClientHelperClient) GetTotpMfa() (*rest_model.DetailMfa, error)

func (*ClientHelperClient) GetTotpToken

func (helper *ClientHelperClient) GetTotpToken(code string) (*rest_model.TotpToken, error)

func (*ClientHelperClient) GetVersion

func (helper *ClientHelperClient) GetVersion() (*rest_model.Version, error)

func (*ClientHelperClient) ListCurrentApiSessionCertificates added in v2.0.3

func (helper *ClientHelperClient) ListCurrentApiSessionCertificates() (rest_model.CurrentAPISessionCertificateList, error)

ListCurrentApiSessionCertificates returns the API session certificates visible to the currently authenticated API Session.

func (*ClientHelperClient) OidcAccessToken

func (helper *ClientHelperClient) OidcAccessToken(credentials edgeApis.Credentials) (string, *common.AccessClaims, error)

OidcAccessToken authenticates via OIDC with the given credentials and returns the raw access token string plus its parsed claims. The caller must set CaPool on the credentials before calling if the controller uses a self-signed certificate.

func (*ClientHelperClient) OidcAuthorize

func (helper *ClientHelperClient) OidcAuthorize(credentials edgeApis.Credentials) (*edgeApis.OidcAuthorizeResult, error)

OidcAuthorize starts an OIDC PKCE authorization flow and returns an OidcAuthorizeResult for use when tests need to make raw HTTP calls to the OP login endpoints. The Exchange function in the result completes the flow by trading an authorization code for OIDC tokens.

func (*ClientHelperClient) QueryCurrentApiSession

func (helper *ClientHelperClient) QueryCurrentApiSession() (*rest_model.CurrentAPISessionDetail, error)

func (*ClientHelperClient) RawLegacyAuthRequest

func (helper *ClientHelperClient) RawLegacyAuthRequest(credentials edgeApis.Credentials) (*clientAuthentication.AuthenticateOK, error)

func (*ClientHelperClient) RawOidcAuthRequest

func (helper *ClientHelperClient) RawOidcAuthRequest(credentials edgeApis.Credentials) (*oidc.Tokens[*oidc.IDTokenClaims], *edgeApis.OidcAuthResponses, error)

RawOidcAuthRequest performs a raw OIDC PKCE authentication flow with no TOTP providers, returning the resulting tokens, all intermediate HTTP responses, and any error.

func (*ClientHelperClient) RawOidcAuthRequestWithProviders

func (helper *ClientHelperClient) RawOidcAuthRequestWithProviders(credentials edgeApis.Credentials, enrollProvider edgeApis.TotpEnrollmentProvider, codeProvider edgeApis.TotpCodeProvider) (*oidc.Tokens[*oidc.IDTokenClaims], *edgeApis.OidcAuthResponses, error)

RawOidcAuthRequestWithProviders performs a raw OIDC PKCE authentication flow with optional TOTP enrollment and code providers, returning the resulting tokens, all intermediate HTTP responses, and any error. Nil providers are ignored; supply only those needed for the scenario under test.

func (*ClientHelperClient) VerifyTotpMfaEnrollment

func (helper *ClientHelperClient) VerifyTotpMfaEnrollment(code string) (*rest_model.DetailMfa, error)

type Config

type Config struct {
	Id           string
	ConfigTypeId string
	Name         string
	Data         map[string]interface{}
	Tags         map[string]interface{}
	// contains filtered or unexported fields
}

type ConfigSet

type ConfigSet struct {
	Name            string   // display name matching the testdata/configs subdirectory
	CtrlConfig      string   // controller config file; empty if the set does not define one
	PeerCtrlConfigs []string // additional cluster-member controller configs, joined to the primary by StartHaCluster
	EdgeRouter      string   // edge router config; empty if the set does not define one
	TunnelerRouter  string   // tunneler-enabled edge router config; empty if not defined
	TransitRouter   string   // transit router config; empty if not defined
	FabricRouters   []string // fabric-only router configs, ordered by 1-based index
}

ConfigSet describes a named collection of config files for a single test scenario. All file paths are relative to the tests/ working directory.

type ControllerHelper

type ControllerHelper struct {
	*server.Controller
}

ControllerHelper wraps a server.Controller with test-oriented helper methods. All methods return values and errors; none accept *testing.T. Because it embeds *server.Controller, all controller methods are available directly.

func (*ControllerHelper) CreateRevocation

func (h *ControllerHelper) CreateRevocation(id string, expiresAt time.Time) error

CreateRevocation writes a revocation entry with the given id and ExpiresAt directly to the controller DB. Useful for planting entries (e.g. with a past ExpiresAt) in tests.

func (*ControllerHelper) DeleteExpiredRevocations

func (h *ControllerHelper) DeleteExpiredRevocations() (int, error)

DeleteExpiredRevocations calls DeleteExpired on the revocation manager and returns the total number of entries removed.

func (*ControllerHelper) FlushRevocationBatcher

func (h *ControllerHelper) FlushRevocationBatcher()

FlushRevocationBatcher synchronously drains any pending batched revocations so that tests can verify they were persisted.

func (*ControllerHelper) ReadRevocation

func (h *ControllerHelper) ReadRevocation(id string) (*model.Revocation, error)

ReadRevocation returns the revocation with the given id from the controller DB, or (nil, nil) if not found.

type CustomAssertions

type CustomAssertions struct {
	*require.Assertions
}

func NewCustomAssertions

func NewCustomAssertions(t require.TestingT) *CustomAssertions

func (*CustomAssertions) ApiError

func (c *CustomAssertions) ApiError(err error)

func (*CustomAssertions) ApiErrorWithCode

func (c *CustomAssertions) ApiErrorWithCode(err error, code string)

type EdgeRouterHelper

type EdgeRouterHelper struct {
	*router.Router
}

EdgeRouterHelper wraps a router.Router with test-oriented helper methods. All methods return values; none accept *testing.T. Because it embeds *router.Router, all router methods are available directly.

func (*EdgeRouterHelper) HasRevocation

func (h *EdgeRouterHelper) HasRevocation(id string) bool

HasRevocation reports whether the given id is currently present in the router's RDM revocations map.

func (*EdgeRouterHelper) WaitForRevocation

func (h *EdgeRouterHelper) WaitForRevocation(id string, timeout time.Duration) bool

WaitForRevocation polls the router's RDM until id appears in the revocations map or timeout elapses. Returns true if the entry is found within the timeout.

func (*EdgeRouterHelper) WaitForRevocationGone

func (h *EdgeRouterHelper) WaitForRevocationGone(id string, timeout time.Duration) bool

WaitForRevocationGone polls the router's RDM until id is absent from the revocations map or timeout elapses. Returns true if gone within the timeout.

type JsonMarshallable

type JsonMarshallable interface {
	MarshalJSON() ([]byte, error)
}

type ManagementHelperClient

type ManagementHelperClient struct {
	*edgeApis.ManagementApiClient
	// contains filtered or unexported fields
}

func (*ManagementHelperClient) AuthenticateOidc

func (helper *ManagementHelperClient) AuthenticateOidc(creds edgeApis.Credentials) (*edgeApis.ApiSessionOidc, error)

AuthenticateOidc sets the client to use OIDC, authenticates with the given credentials, and returns the OIDC API session. Returns an error if authentication fails or the session is not an OIDC session.

func (*ManagementHelperClient) CreateAndEnrollOttIdentity

func (helper *ManagementHelperClient) CreateAndEnrollOttIdentity(isAdmin bool, roleAttributes ...string) (*rest_model.IdentityDetail, *edgeApis.CertCredentials, error)

func (*ManagementHelperClient) CreateAndEnrollOttIdentityWithPermissions added in v2.0.4

func (helper *ManagementHelperClient) CreateAndEnrollOttIdentityWithPermissions(isAdmin bool, permissions []string, roleAttributes ...string) (*rest_model.IdentityDetail, *edgeApis.CertCredentials, error)

CreateAndEnrollOttIdentityWithPermissions creates an identity carrying the given management permissions, such as "identity.read" or "enrollment", completes its ott enrollment, and returns the identity along with the certificate credentials it enrolled with.

func (*ManagementHelperClient) CreateAuthPolicy

func (helper *ManagementHelperClient) CreateAuthPolicy(authPolicy *rest_model.AuthPolicyCreate) (*rest_model.AuthPolicyDetail, error)

func (*ManagementHelperClient) CreateCa

func (helper *ManagementHelperClient) CreateCa(testCa *ca) (*rest_model.CreateLocation, error)

func (*ManagementHelperClient) CreateEnrollmentOtt

func (helper *ManagementHelperClient) CreateEnrollmentOtt(identityId *string, expiresAt *time.Time) (*rest_model.CreateLocation, error)

func (*ManagementHelperClient) CreateEnrollmentOttCa

func (helper *ManagementHelperClient) CreateEnrollmentOttCa(identityId *string, caId *string, expiresAt *time.Time) (*rest_model.CreateLocation, error)

func (*ManagementHelperClient) CreateEnrollmentUpdb

func (helper *ManagementHelperClient) CreateEnrollmentUpdb(identityId *string, username *string, expiresAt *time.Time) (*rest_model.CreateLocation, error)

func (*ManagementHelperClient) CreateExtJwtSigner

func (*ManagementHelperClient) CreateIdentity

func (helper *ManagementHelperClient) CreateIdentity(name string, isAdmin bool, roleAttributes ...string) (*rest_model.CreateLocation, error)

func (*ManagementHelperClient) CreateIdentityWithPermissions added in v2.0.4

func (helper *ManagementHelperClient) CreateIdentityWithPermissions(name string, isAdmin bool, permissions []string, roleAttributes ...string) (*rest_model.CreateLocation, error)

CreateIdentityWithPermissions creates an identity carrying the given management permissions, such as "identity.read" or "enrollment". A nil or empty slice leaves the identity with none.

func (*ManagementHelperClient) CreateOttCaEnabledCa added in v2.0.4

func (helper *ManagementHelperClient) CreateOttCaEnabledCa(name string) (*rest_model.CreateLocation, error)

CreateOttCaEnabledCa creates a third-party CA with ott-ca enrollment enabled, generating its certificate, so that ott-ca enrollments can be created against it.

func (*ManagementHelperClient) CreatePostureCheck

func (*ManagementHelperClient) CreatePostureCheckMac

func (helper *ManagementHelperClient) CreatePostureCheckMac(addresses []string, attributes []string) (*rest_model.PostureCheckMacAddressDetail, error)

func (*ManagementHelperClient) CreatePostureCheckOs

func (helper *ManagementHelperClient) CreatePostureCheckOs(operatingSystems []*rest_model.OperatingSystem, attributes []string) (*rest_model.PostureCheckOperatingSystemDetail, error)

func (*ManagementHelperClient) CreatePostureCheckProcess

func (helper *ManagementHelperClient) CreatePostureCheckProcess(process *rest_model.Process, attributes []string) (*rest_model.PostureCheckProcessDetail, error)

func (*ManagementHelperClient) CreatePostureCheckProcessMulti

func (helper *ManagementHelperClient) CreatePostureCheckProcessMulti(processes []*rest_model.ProcessMulti, semantic rest_model.Semantic, attributes []string) (*rest_model.PostureCheckProcessMultiDetail, error)

func (*ManagementHelperClient) CreateRevocation

func (helper *ManagementHelperClient) CreateRevocation(id string, revocationType rest_model.RevocationTypeEnum) (*rest_model.CreateLocation, error)

CreateRevocation creates a new revocation entry for the given id and type via the Management API.

func (*ManagementHelperClient) CreateTotpMfaEnrollment

func (helper *ManagementHelperClient) CreateTotpMfaEnrollment() (*rest_model.DetailMfa, error)

func (*ManagementHelperClient) CreateUpdbIdentityWithAuthPolicy

func (helper *ManagementHelperClient) CreateUpdbIdentityWithAuthPolicy(authPolicyId string) (*edgeApis.UpdbCredentials, error)

func (*ManagementHelperClient) EnrollTotpMfa

func (helper *ManagementHelperClient) EnrollTotpMfa() (*TotpProvider, *rest_model.DetailMfa, error)

func (*ManagementHelperClient) GetAuthPolicy

func (helper *ManagementHelperClient) GetAuthPolicy(id string) (*rest_model.AuthPolicyDetail, error)

func (*ManagementHelperClient) GetCa

func (helper *ManagementHelperClient) GetCa(caId string) (*rest_model.CaDetail, error)

func (*ManagementHelperClient) GetCurrentApiSessionDetail

func (helper *ManagementHelperClient) GetCurrentApiSessionDetail() (*rest_model.CurrentAPISessionDetail, error)

func (*ManagementHelperClient) GetCurrentApiSessionDetailResponse

func (helper *ManagementHelperClient) GetCurrentApiSessionDetailResponse() (*managementCurrentApiSession.GetCurrentAPISessionOK, error)

func (*ManagementHelperClient) GetEnrollment

func (helper *ManagementHelperClient) GetEnrollment(enrollmentId string) (*rest_model.EnrollmentDetail, error)

func (*ManagementHelperClient) GetExtJwtSigner

func (helper *ManagementHelperClient) GetExtJwtSigner(id string) (*rest_model.ExternalJWTSignerDetail, error)

func (*ManagementHelperClient) GetIdentity

func (helper *ManagementHelperClient) GetIdentity(identityId string) (*rest_model.IdentityDetail, error)

func (*ManagementHelperClient) GetIdentityAuthenticators

func (helper *ManagementHelperClient) GetIdentityAuthenticators(identityId string) ([]*rest_model.AuthenticatorDetail, error)

func (*ManagementHelperClient) GetOidcAccessToken

func (helper *ManagementHelperClient) GetOidcAccessToken() (string, *common.AccessClaims, error)

GetOidcAccessToken extracts the access token and its parsed claims from the client's current OIDC session. Returns an error if the session is not OIDC.

func (*ManagementHelperClient) GetPostureCheck

func (helper *ManagementHelperClient) GetPostureCheck(id string) (rest_model.PostureCheckDetail, error)

func (*ManagementHelperClient) GetRevocation

func (helper *ManagementHelperClient) GetRevocation(id string) (*rest_model.RevocationDetail, error)

GetRevocation retrieves a single revocation entry by its id via the Management API.

func (*ManagementHelperClient) GetTotpMfa

func (helper *ManagementHelperClient) GetTotpMfa() (*rest_model.DetailMfa, error)

func (*ManagementHelperClient) GetTotpToken

func (helper *ManagementHelperClient) GetTotpToken(code string) (*rest_model.TotpToken, error)

func (*ManagementHelperClient) GetVersion

func (helper *ManagementHelperClient) GetVersion() (*rest_model.Version, error)

func (*ManagementHelperClient) GetVersionResponse

func (helper *ManagementHelperClient) GetVersionResponse() (*managementInformational.ListVersionOK, error)

func (*ManagementHelperClient) ListIdentitiesByFilter added in v2.0.4

func (helper *ManagementHelperClient) ListIdentitiesByFilter(filter string) ([]*rest_model.IdentityDetail, error)

ListIdentitiesByFilter returns all identities matching the supplied ziti filter expression.

func (*ManagementHelperClient) ListIdentityEnrollments added in v2.0.4

func (helper *ManagementHelperClient) ListIdentityEnrollments(identityId string) ([]*rest_model.EnrollmentDetail, error)

ListIdentityEnrollments returns the outstanding enrollments of an identity, as the /identities/{id}/enrollments subresource renders them for the calling session.

func (*ManagementHelperClient) ListRevocations

func (helper *ManagementHelperClient) ListRevocations() (rest_model.RevocationList, error)

ListRevocations retrieves all revocation entries via the Management API.

func (*ManagementHelperClient) PatchExtJwtSigner

func (helper *ManagementHelperClient) PatchExtJwtSigner(id string, patch *rest_model.AuthPolicyPatch) (*rest_model.AuthPolicyDetail, error)

func (*ManagementHelperClient) PatchIdentity

func (*ManagementHelperClient) RefreshEnrollmentJwt

func (helper *ManagementHelperClient) RefreshEnrollmentJwt(id string) (*rest_model.EnrollmentDetail, error)

func (*ManagementHelperClient) RequireIdentitySdkInfoUpdated added in v2.0.3

func (helper *ManagementHelperClient) RequireIdentitySdkInfoUpdated(identityId string, appId string) *rest_model.IdentityDetail

RequireIdentitySdkInfoUpdated polls until the identity reports appId as its SDK app id, returning the identity as read and failing the test if it does not appear within 10 seconds. The controller applies sdk/env info updates on a background queue, so they are not guaranteed to be visible by the time authentication returns.

func (*ManagementHelperClient) VerifyCa

func (helper *ManagementHelperClient) VerifyCa(id string, token string, cert *x509.Certificate, key crypto.Signer) error

func (*ManagementHelperClient) VerifyTotpMfaEnrollment

func (helper *ManagementHelperClient) VerifyTotpMfaEnrollment(code string) (*rest_model.DetailMfa, error)

type ManagerHelpers

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

ManagerHelpers provides direct access to controller manager operations, bypassing the REST API. Accessible via TestContext.Managers after StartServer() has been called.

func (*ManagerHelpers) CreateAuthPolicy

func (m *ManagerHelpers) CreateAuthPolicy(policy *model.AuthPolicy) error

CreateAuthPolicy creates an auth policy via the manager. The policy's Id field is populated on success.

func (*ManagerHelpers) CreateIdentity

func (m *ManagerHelpers) CreateIdentity(identity *model.Identity) error

CreateIdentity creates an identity via the manager. The identity's Id field is populated on success.

func (*ManagerHelpers) CreateUpdbAuthenticator

func (m *ManagerHelpers) CreateUpdbAuthenticator(identityId, username, password string) error

CreateUpdbAuthenticator creates a username/password authenticator for the given identity.

func (*ManagerHelpers) NewIdentityWithUpdb

func (m *ManagerHelpers) NewIdentityWithUpdb(authPolicyId string) (*model.Identity, *updbAuthenticator, error)

NewIdentityWithUpdb creates a non-admin identity with random credentials attached to the given auth policy, and registers a UPDB authenticator for it. Returns the identity, credentials, and any error.

type SessionRequest

type SessionRequest struct {
	ServiceId string `json:"serviceId"`
}

type SingularClientTransportPool

type SingularClientTransportPool struct {
	ApiClientTransport *edgeApis.ApiClientTransport
}

SingularClientTransportPool is a transport pool that only allows a single transport to be used, implements ClientTransportPool

func (*SingularClientTransportPool) Add

func (s *SingularClientTransportPool) Add(apiUrl *url.URL, transport runtime.ClientTransport)

func (*SingularClientTransportPool) GetActiveTransport

func (s *SingularClientTransportPool) GetActiveTransport() *edgeApis.ApiClientTransport

func (*SingularClientTransportPool) GetApiUrls

func (s *SingularClientTransportPool) GetApiUrls() []*url.URL

func (*SingularClientTransportPool) IterateTransportsRandomly

func (s *SingularClientTransportPool) IterateTransportsRandomly() chan<- *edgeApis.ApiClientTransport

func (*SingularClientTransportPool) Remove

func (s *SingularClientTransportPool) Remove(apiUrl *url.URL)

func (*SingularClientTransportPool) SetActiveTransport

func (s *SingularClientTransportPool) SetActiveTransport(transport *edgeApis.ApiClientTransport)

func (*SingularClientTransportPool) Submit

func (s *SingularClientTransportPool) Submit(operation *runtime.ClientOperation) (any, error)

func (*SingularClientTransportPool) TryTransportForF

func (s *SingularClientTransportPool) TryTransportForF(cb func(*edgeApis.ApiClientTransport) (any, error)) (any, error)

func (*SingularClientTransportPool) TryTransportsForOp

func (s *SingularClientTransportPool) TryTransportsForOp(operation *runtime.ClientOperation) (any, error)

type TestConn

type TestConn struct {
	edge.Conn
	// contains filtered or unexported fields
}

func (*TestConn) ReadExpected

func (conn *TestConn) ReadExpected(expected string, timeout time.Duration)

func (*TestConn) ReadString

func (conn *TestConn) ReadString(maxSize int, timeout time.Duration) string

func (*TestConn) RequireClose

func (conn *TestConn) RequireClose()

func (*TestConn) WriteString

func (conn *TestConn) WriteString(val string, timeout time.Duration)

type TestContext

type TestContext struct {
	*CustomAssertions
	ApiHost                string
	AdminAuthenticator     *updbAuthenticator
	Managers               *ManagerHelpers
	AdminManagementSession *session
	AdminClientSession     *session
	RestClients            *zitirest.Clients

	EdgeController *server.Controller
	Req            *CustomAssertions

	LogLevel         string
	ControllerConfig *config.Config
	// contains filtered or unexported fields
}

func GetTestContext

func GetTestContext() *TestContext

func NewTestContext

func NewTestContext(t *testing.T) *TestContext

func NewTestContextWithConfigSet

func NewTestContextWithConfigSet(t *testing.T, cs ConfigSet) *TestContext

NewTestContextWithConfigSet creates a TestContext that uses the supplied ConfigSet instead of DefaultATS. All other behavior, including DB path and API host, is unchanged.

func (*TestContext) ClientApiUrl

func (ctx *TestContext) ClientApiUrl() *url.URL

func (*TestContext) ControllerCaPool

func (ctx *TestContext) ControllerCaPool() *x509.CertPool

func (*TestContext) CreateEnrollAndStartEdgeRouter

func (ctx *TestContext) CreateEnrollAndStartEdgeRouter(roleAttributes ...string) *EdgeRouterHelper

func (*TestContext) CreateEnrollAndStartEdgeRouterWithCfgTweaks

func (ctx *TestContext) CreateEnrollAndStartEdgeRouterWithCfgTweaks(cfgTweaks func(*routerEnv.Config), roleAttributes ...string) *EdgeRouterHelper

func (*TestContext) CreateEnrollAndStartHAEdgeRouter

func (ctx *TestContext) CreateEnrollAndStartHAEdgeRouter(roleAttributes ...string) *EdgeRouterHelper

func (*TestContext) CreateEnrollAndStartTunnelerEdgeRouter

func (ctx *TestContext) CreateEnrollAndStartTunnelerEdgeRouter(roleAttributes ...string)

func (*TestContext) CreateEnrollAndStartTunnelerEdgeRouterWithCfgTweaks

func (ctx *TestContext) CreateEnrollAndStartTunnelerEdgeRouterWithCfgTweaks(cfgTweaks func(*routerEnv.Config), roleAttributes ...string)

CreateEnrollAndStartTunnelerEdgeRouterWithCfgTweaks creates a tunneler-enabled edge router and allows the caller to modify the router config before startup.

func (*TestContext) DefaultClientApiClient

func (ctx *TestContext) DefaultClientApiClient() *resty.Client

func (*TestContext) DefaultManagementApiClient

func (ctx *TestContext) DefaultManagementApiClient() *resty.Client

func (*TestContext) EnrollFabricRouter

func (ctx *TestContext) EnrollFabricRouter(id string, name string, certFile string)

func (*TestContext) EnrollIdentity

func (ctx *TestContext) EnrollIdentity(identityId string) *ziti.Config

func (*TestContext) ManagementApiUrl

func (ctx *TestContext) ManagementApiUrl() *url.URL

func (*TestContext) NewAdminCredentials

func (ctx *TestContext) NewAdminCredentials() *edgeApis.UpdbCredentials

func (*TestContext) NewClientComponents

func (ctx *TestContext) NewClientComponents(apiPath string) (*resty.Client, *http.Client, *http.Transport)

func (*TestContext) NewClientComponentsWithClientCert

func (ctx *TestContext) NewClientComponentsWithClientCert(certs []*x509.Certificate, privateKey crypto.PrivateKey) (*resty.Client, *http.Client, *http.Transport)

func (*TestContext) NewControlChannelListener

func (ctx *TestContext) NewControlChannelListener() channel.UnderlayListener

func (*TestContext) NewEdgeClientApi

func (ctx *TestContext) NewEdgeClientApi(totpProvider func(chan string)) *ClientHelperClient

func (*TestContext) NewEdgeClientApiForHost added in v2.0.4

func (ctx *TestContext) NewEdgeClientApiForHost(apiHost string, totpProvider func(chan string)) *ClientHelperClient

NewEdgeClientApiForHost returns a ClientHelperClient targeting the given API host instead of the primary controller's. The CA pool is shared cluster-wide.

func (*TestContext) NewEdgeClientApiWithToken

func (ctx *TestContext) NewEdgeClientApiWithToken(accessToken string) *ClientHelperClient

NewEdgeClientApiWithToken returns a ClientHelperClient pre-loaded with the given raw OIDC access token. No authentication step is required.

func (*TestContext) NewEdgeManagementApi

func (ctx *TestContext) NewEdgeManagementApi(totpProvider func(chan string)) *ManagementHelperClient

func (*TestContext) NewEdgeManagementApiWithStaticToken

func (ctx *TestContext) NewEdgeManagementApiWithStaticToken(accessToken string) *ManagementHelperClient

NewEdgeManagementApiWithStaticToken creates a ManagementHelperClient that sends the given OIDC access token on every request. No refresh token is stored, so the token cannot be silently refreshed.

func (*TestContext) NewEdgeManagementApiWithToken

func (ctx *TestContext) NewEdgeManagementApiWithToken(accessToken string) *ManagementHelperClient

NewEdgeManagementApiWithToken returns a ManagementHelperClient pre-loaded with the given raw OIDC access token. No authentication step is required.

func (*TestContext) NewHttpClient

func (ctx *TestContext) NewHttpClient(transport *http.Transport) *http.Client

func (*TestContext) NewRestClient

func (ctx *TestContext) NewRestClient(i idlib.Identity) *resty.Client

func (*TestContext) NewRestClientWithDefaults

func (ctx *TestContext) NewRestClientWithDefaults() *resty.Client

func (*TestContext) NewTransport

func (ctx *TestContext) NewTransport() *http.Transport

func (*TestContext) NewTransportWithClientCert

func (ctx *TestContext) NewTransportWithClientCert(certs []*x509.Certificate, privateKey crypto.PrivateKey) *http.Transport

func (*TestContext) NewTransportWithIdentity

func (ctx *TestContext) NewTransportWithIdentity(i idlib.Identity) *http.Transport

func (*TestContext) NewWsMgmtChannel

func (ctx *TestContext) NewWsMgmtChannel(bindHandler channel.BindHandler) (channel.Channel, error)

func (*TestContext) NextTest

func (ctx *TestContext) NextTest(t *testing.T)

NextTest is an alias for testContextChanged and reflects the bbolt testing framework

func (*TestContext) PeerControllerApiHosts added in v2.0.4

func (ctx *TestContext) PeerControllerApiHosts() []string

PeerControllerApiHosts returns the API host:port of each peer controller, in PeerCtrlConfigs order.

func (*TestContext) RequireAdminClientApiLogin

func (ctx *TestContext) RequireAdminClientApiLogin()

func (*TestContext) RequireAdminManagementApiLogin

func (ctx *TestContext) RequireAdminManagementApiLogin()

func (*TestContext) RequireChildWith

func (ctx *TestContext) RequireChildWith(container *gabs.Container, attribute string, value interface{}) *gabs.Container

func (*TestContext) RequireGetNonNilPathValue

func (ctx *TestContext) RequireGetNonNilPathValue(container *gabs.Container, searchPath ...string) *gabs.Container

func (*TestContext) RequireNoChildWith

func (ctx *TestContext) RequireNoChildWith(container *gabs.Container, attribute string, value interface{}) *gabs.Container

func (*TestContext) RequireNotFoundError

func (ctx *TestContext) RequireNotFoundError(httpStatus int, body []byte) *gabs.Container

func (*TestContext) RequirePathExists

func (ctx *TestContext) RequirePathExists(container *gabs.Container, searchPath ...string)

func (*TestContext) StartHaCluster added in v2.0.4

func (ctx *TestContext) StartHaCluster(dataDir string) *ControllerHelper

StartHaCluster starts the config set's primary controller plus every PeerCtrlConfigs member, joins them into a single raft cluster, and waits until every member is a voter and is registered in the Controller store. dataDir is the parent raft data directory shared by the set's controllers (e.g. Ha3DataDir); it is removed first so each run bootstraps fresh.

func (*TestContext) StartServer

func (ctx *TestContext) StartServer() *ControllerHelper

func (*TestContext) StartServerFor

func (ctx *TestContext) StartServerFor(testDb string, clean bool) *ControllerHelper

func (*TestContext) StartServerWithConfigModifier

func (ctx *TestContext) StartServerWithConfigModifier(modifier func(*config.Config)) *ControllerHelper

StartServerWithConfigModifier starts the controller and edge layer, applying modifier to the loaded config before the controller is created. This lets a single test override settings (e.g., OIDC token durations) without affecting other tests that call StartServer with the shared default config.

func (*TestContext) T

func (ctx *TestContext) T() *testing.T

func (*TestContext) Teardown

func (ctx *TestContext) Teardown()

func (*TestContext) WrapConn

func (ctx *TestContext) WrapConn(conn edge.Conn, err error) *TestConn

func (*TestContext) WrapNetConn

func (ctx *TestContext) WrapNetConn(conn edge.Conn, err error) *TestConn

type TotpProvider

type TotpProvider struct {
	Secret          string
	Issuer          string
	Name            string
	ProvisioningUrl string
}

func (*TotpProvider) ApplyProvisioningUrl

func (t *TotpProvider) ApplyProvisioningUrl(provisioningUrl string) error

func (*TotpProvider) Code

func (t *TotpProvider) Code() string

func (*TotpProvider) FuncProvider

func (t *TotpProvider) FuncProvider() func(chan string)

type VersionProviderTest

type VersionProviderTest struct {
}

func (VersionProviderTest) AsVersionInfo

func (v VersionProviderTest) AsVersionInfo() *versions.VersionInfo

func (VersionProviderTest) Branch

func (v VersionProviderTest) Branch() string

func (VersionProviderTest) BuildDate

func (v VersionProviderTest) BuildDate() string

func (VersionProviderTest) EncoderDecoder

func (v VersionProviderTest) EncoderDecoder() versions.VersionEncDec

func (VersionProviderTest) Revision

func (v VersionProviderTest) Revision() string

func (VersionProviderTest) Version

func (v VersionProviderTest) Version() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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