mock

package
v0.0.0-...-676ba0e Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FakeFederatedToken = "FakeFederatedToken"
	FakeAccessToken    = "FakeAccessToken"
	FakeTrustDomain    = "FakeTrustDomain"
	// FakeSubjectToken is a fake JWT token without signing, anyone can change it if needed by base64 decoding or using online tool like https://jwt.io/.
	FakeSubjectToken = "" // nolint: lll
	/* 751-byte string literal not displayed */
	FakeProjectNum       = "1234567"
	FakeGKEClusterURL    = "https://container.googleapis.com/v1/projects/fakeproject/locations/fakelocation/clusters/fakecluster"
	FakeExpiresInSeconds = 3600
)

Functions

This section is empty.

Types

type AuthorizationServer

type AuthorizationServer struct {
	Port int
	URL  string
	// contains filtered or unexported fields
}

AuthorizationServer mocks google secure token server. nolint: maligned

func StartNewServer

func StartNewServer(t *testing.T, conf Config) (*AuthorizationServer, error)

StartNewServer creates a mock server and starts it. The server listens on port for requests. If port is 0, a randomly chosen port is in use.

func (*AuthorizationServer) BlockAccessTokenRequest

func (ms *AuthorizationServer) BlockAccessTokenRequest(block bool)

func (*AuthorizationServer) BlockFederatedTokenRequest

func (ms *AuthorizationServer) BlockFederatedTokenRequest(block bool)

func (*AuthorizationServer) EnableDynamicAccessToken

func (ms *AuthorizationServer) EnableDynamicAccessToken(enable bool)

EnableDynamicAccessToken sets the issued access token to token

func (*AuthorizationServer) NumGetAccessTokenCalls

func (ms *AuthorizationServer) NumGetAccessTokenCalls() int

func (*AuthorizationServer) NumGetFederatedTokenCalls

func (ms *AuthorizationServer) NumGetFederatedTokenCalls() int

func (*AuthorizationServer) SetAccessToken

func (ms *AuthorizationServer) SetAccessToken(token string)

SetAccessToken sets the issued access token to token

func (*AuthorizationServer) SetGenAcsTokenError

func (ms *AuthorizationServer) SetGenAcsTokenError(err error)

func (*AuthorizationServer) SetGenFedTokenError

func (ms *AuthorizationServer) SetGenFedTokenError(err error)

func (*AuthorizationServer) SetTokenLifeTime

func (ms *AuthorizationServer) SetTokenLifeTime(d int)

SetTokenLifeTime sets life time of issued access token to d seconds

func (*AuthorizationServer) Start

func (ms *AuthorizationServer) Start(port int) error

Start starts the mock server.

func (*AuthorizationServer) Stop

func (ms *AuthorizationServer) Stop() error

Stop stops he mock server.

type Config

type Config struct {
	Port         int
	SubjectToken string
	TrustDomain  string
	AccessToken  string
}

type Duration

type Duration struct {
	// Signed seconds of the span of time. Must be from -315,576,000,000
	// to +315,576,000,000 inclusive. Note: these bounds are computed from:
	// 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
	Seconds int64 `json:"seconds"`
}

Jump to

Keyboard shortcuts

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