Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallbackData ¶
type CallbackData struct {
SessionID string
OriginalPort string
CallbackPath string
CapturedPath string // Path captured from OAuth redirect
CapturedQuery string // Query captured from OAuth redirect
Ready bool // Whether callback data is ready
}
CallbackData holds data for an OAuth callback session.
type GitCredRequest ¶
type GitCredRequest struct {
Action string // "get", "store", or "erase"
Host string
Protocol string
Username string
}
GitCredRequest represents a git credential request.
type MockHostProxy ¶
type MockHostProxy struct {
Server *httptest.Server
OpenedURLs []string // URLs received at /open/url
Callbacks map[string]*CallbackData // Registered callback sessions
GitCreds []GitCredRequest // Git credential requests
// contains filtered or unexported fields
}
MockHostProxy provides a mock implementation of the clawker host proxy for testing container scripts that communicate with the host.
func NewMockHostProxy ¶
func NewMockHostProxy(t *testing.T) *MockHostProxy
NewMockHostProxy creates a new MockHostProxy and starts the server. The server is automatically stopped when the test completes.
func (*MockHostProxy) GetGitCreds ¶
func (m *MockHostProxy) GetGitCreds() []GitCredRequest
GetGitCreds returns a copy of the git credential requests.
func (*MockHostProxy) GetOpenedURLs ¶
func (m *MockHostProxy) GetOpenedURLs() []string
GetOpenedURLs returns a copy of the opened URLs.
func (*MockHostProxy) SetCallbackReady ¶
func (m *MockHostProxy) SetCallbackReady(sessionID, path, query string)
SetCallbackReady simulates an OAuth callback being received.
func (*MockHostProxy) SetHealthOK ¶
func (m *MockHostProxy) SetHealthOK(ok bool)
SetHealthOK controls the health check response.
type MockManager ¶ added in v0.1.2
type MockManager struct {
EnsureErr error // Error returned by EnsureRunning
Running bool // Value returned by IsRunning
URL string // Value returned by ProxyURL
}
MockManager is a test double for hostproxy.HostProxyService. It never spawns subprocesses, making it safe for unit tests.
func NewFailingMockManager ¶ added in v0.1.2
func NewFailingMockManager(err error) *MockManager
NewFailingMockManager returns a MockManager whose EnsureRunning returns the given error.
func NewMockManager ¶ added in v0.1.2
func NewMockManager() *MockManager
NewMockManager returns a MockManager that starts not running. EnsureRunning transitions it to running (since EnsureErr is nil).
func NewRunningMockManager ¶ added in v0.1.2
func NewRunningMockManager(url string) *MockManager
NewRunningMockManager returns a MockManager that reports as running with the given proxy URL.
func (*MockManager) EnsureRunning ¶ added in v0.1.2
func (m *MockManager) EnsureRunning() error
func (*MockManager) IsRunning ¶ added in v0.1.2
func (m *MockManager) IsRunning() bool
func (*MockManager) ProxyURL ¶ added in v0.1.2
func (m *MockManager) ProxyURL() string