ablytest

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = ably.Logger{Level: ably.LogNone}
View Source
var Environment = "sandbox"
View Source
var NoBinaryProtocol bool
View Source
var Timeout = 30 * time.Second

Functions

func MergeOptions

func MergeOptions(opts ...*ably.ClientOptions) *ably.ClientOptions

func MessagePipe

func MessagePipe(in <-chan *proto.ProtocolMessage, out chan<- *proto.ProtocolMessage) func(string, *url.URL) (proto.Conn, error)

func MustQuery

func MustQuery(req *http.Request) url.Values

func NewHTTPClient

func NewHTTPClient() *http.Client

func NewTokenParams

func NewTokenParams(query url.Values) *ably.TokenParams

func Query

func Query(req *http.Request) (url.Values, error)

func Wait

func Wait(res ably.Result, err error) error

Types

type AuthReverseProxy

type AuthReverseProxy struct {
	TokenQueue []*ably.TokenDetails // when non-nil pops the token from the queue instead querying Ably servers
	Listener   net.Listener         // listener which accepts token request connections
	// contains filtered or unexported fields
}

AuthReverseProxy serves token requests by reverse proxying them to the Ably servers. Use URL method for creating values for AuthURL option and Callback method - for AuthCallback ones.

func MustAuthReverseProxy

func MustAuthReverseProxy(opts *ably.ClientOptions) *AuthReverseProxy

MustAuthReverseProxy panics when creating the proxy fails.

func NewAuthReverseProxy

func NewAuthReverseProxy(opts *ably.ClientOptions) (*AuthReverseProxy, error)

NewAuthReverseProxy creates new auth reverse proxy. The given opts are used to create a Auth client, used to reverse proxying token requests.

func (*AuthReverseProxy) Callback

func (srv *AuthReverseProxy) Callback(responseType string) func(*ably.TokenParams) (interface{}, error)

Callback gives new AuthCallback. Available response types are the same as for URL method.

func (*AuthReverseProxy) Close

func (srv *AuthReverseProxy) Close() error

Close makes the proxy server stop accepting connections.

func (*AuthReverseProxy) ServeHTTP

func (srv *AuthReverseProxy) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements the http.Handler interface.

func (*AuthReverseProxy) URL

func (srv *AuthReverseProxy) URL(responseType string) string

URL gives new AuthURL for the requested responseType. Available response types are:

  • "token", which responds with (ably.TokenDetails).Token as a string
  • "details", which responds with ably.TokenDetails
  • "request", which responds with ably.TokenRequest

type Channel

type Channel struct {
	Name     string     `json:"name"`
	Presence []Presence `json:"presence,omitempty"`
}

type Config

type Config struct {
	ID          string       `json:"id,omitempty"`
	AppID       string       `json:"appId,omitempty"`
	AccountID   string       `json:"accountId,omitempty"`
	Status      int          `json:"status,omitempty"`
	Created     int          `json:"created,omitempty"`
	Modified    int          `json:"modified,omitempty"`
	TLSOnly     bool         `json:"tlsOnly,omitempty"`
	Labels      string       `json:"labels,omitempty"`
	Keys        []Key        `json:"keys"`
	Namespaces  []Namespace  `json:"namespaces"`
	Channels    []Channel    `json:"channels"`
	Connections []Connection `json:"connections,omitempty"`
}

func DefaultConfig

func DefaultConfig() *Config

type Connection

type Connection struct {
	Name string `json:"name"`
	Key  string `json:"key"`
}

type CryptoData

type CryptoData struct {
	Algorithm string `json:"algorithm"`
	Mode      string `json:"mode"`
	KeyLen    int    `json:"keylength"`
	Key       string `json:"key"`
	IV        string `json:"iv"`
	Items     []struct {
		Encoded   proto.Message `json:"encoded"`
		Encrypted proto.Message `json:"encrypted"`
	} `json:"items"`
}

func LoadCryptoData

func LoadCryptoData(rel string) (*CryptoData, []byte, []byte, error)

type HostRecorder

type HostRecorder struct {
	Hosts map[string]struct{}
	// contains filtered or unexported fields
}

func NewRecorder

func NewRecorder(httpClient *http.Client) *HostRecorder

func (*HostRecorder) Options

func (hr *HostRecorder) Options(host string) *ably.ClientOptions

type Key

type Key struct {
	ID            string `json:"id,omitempty"`
	ScopeID       string `json:"scopeId,omitempty"`
	Status        int    `json:"status,omitempty"`
	Type          int    `json:"type,omitempty"`
	Value         string `json:"value,omitempty"`
	Created       int    `json:"created,omitempty"`
	Modified      int    `json:"modified,omitempty"`
	RawCapability string `json:"capability,omitempty"`
	Expires       int    `json:"expired,omitempty"`
	Privileged    bool   `json:"privileged,omitempty"`
}

func (*Key) Capability

func (k *Key) Capability() ably.Capability

type MessageRecorder

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

MessageRecorder

func NewMessageRecorder

func NewMessageRecorder() *MessageRecorder

NewMessageRecorder gives new spy value that records incoming and outgoing ProtocolMessages and dialed endpoints.

For use with Dial field of ClientOptions.

func (*MessageRecorder) Dial

func (rec *MessageRecorder) Dial(proto string, u *url.URL) (proto.Conn, error)

Dial

func (*MessageRecorder) Received

func (rec *MessageRecorder) Received() []*proto.ProtocolMessage

Received

func (*MessageRecorder) Sent

func (rec *MessageRecorder) Sent() []*proto.ProtocolMessage

Sent

func (*MessageRecorder) URL

func (rec *MessageRecorder) URL() []*url.URL

URL

type Namespace

type Namespace struct {
	ID        string `json:"id"`
	Created   int    `json:"created,omitempty"`
	Modified  int    `json:"modified,omitempty"`
	Persisted bool   `json:"persisted,omitempty"`
}

type Presence

type Presence struct {
	ClientID string `json:"clientId"`
	Data     string `json:"data"`
	Encoding string `json:"encoding,omitempty"`
}

type ResultGroup

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

ResultGroup is like sync.WaitGroup, but for ably.Result values.

ResultGroup blocks till last added ably.Result has completed successfully.

If at least ably.Result value failed, ResultGroup returns first encountered error immadiately.

func (*ResultGroup) Add

func (rg *ResultGroup) Add(res ably.Result, err error)

func (*ResultGroup) Wait

func (rg *ResultGroup) Wait() error

type RoundTripRecorder

type RoundTripRecorder struct {
	*http.Transport
	// contains filtered or unexported fields
}

RoundTripRecorder is a http.Transport wrapper which records HTTP request/response pairs.

func (*RoundTripRecorder) Hijack

Hijack injects http.Transport into the wrapper.

func (*RoundTripRecorder) Len

func (rec *RoundTripRecorder) Len() int

Len gives number of recorded request/response pairs.

It is save to call Len() before calling Stop().

func (*RoundTripRecorder) Request

func (rec *RoundTripRecorder) Request(n int) *http.Request

Request gives nth recorded http.Request.

func (*RoundTripRecorder) Requests

func (rec *RoundTripRecorder) Requests() []*http.Request

Requests gives all HTTP requests in order they were recorded.

func (*RoundTripRecorder) Reset

func (rec *RoundTripRecorder) Reset()

Reset resets the recorder requests and responses.

func (*RoundTripRecorder) Response

func (rec *RoundTripRecorder) Response(n int) *http.Response

Response gives nth recorded http.Response.

func (*RoundTripRecorder) Responses

func (rec *RoundTripRecorder) Responses() []*http.Response

Responses gives all HTTP responses in order they were recorded.

func (*RoundTripRecorder) RoundTrip

func (rec *RoundTripRecorder) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface.

func (*RoundTripRecorder) Stop

func (rec *RoundTripRecorder) Stop()

Stop makes the recorder stop recording new requests/responses.

type Sandbox

type Sandbox struct {
	Config      *Config
	Environment string
	// contains filtered or unexported fields
}

func MustSandbox

func MustSandbox(config *Config) *Sandbox

func NewRealtimeClient

func NewRealtimeClient(opts *ably.ClientOptions) (*Sandbox, *ably.RealtimeClient)

func NewRestClient

func NewRestClient(opts *ably.ClientOptions) (*Sandbox, *ably.RestClient)

func NewSandbox

func NewSandbox(config *Config) (*Sandbox, error)

func (*Sandbox) Close

func (app *Sandbox) Close() error

func (*Sandbox) Key

func (app *Sandbox) Key() string

func (*Sandbox) KeyParts

func (app *Sandbox) KeyParts() (name, secret string)

func (*Sandbox) NewRealtimeClient

func (app *Sandbox) NewRealtimeClient(opts ...*ably.ClientOptions) *ably.RealtimeClient

func (*Sandbox) Options

func (app *Sandbox) Options(opts ...*ably.ClientOptions) *ably.ClientOptions

func (*Sandbox) URL

func (app *Sandbox) URL(paths ...string) string

type StateRecorder

type StateRecorder struct {
	Timeout time.Duration // times out waiting for states after this duration; 15s by default
	// contains filtered or unexported fields
}

StateRecorder provides:

  • send ably.State channel for recording state transitions
  • goroutine-safe access to recorded state enums

func NewStateChanRecorder

func NewStateChanRecorder(buffer int) *StateRecorder

NewStateChanRecorder gives new recorder which records channel-related state transitions only.

func NewStateConnRecorder

func NewStateConnRecorder(buffer int) *StateRecorder

NewStateConnRecorder gives new recorder which records connection-related state transitions only.

func NewStateRecorder

func NewStateRecorder(buffer int) *StateRecorder

NewStateRecorder gives new recorder which purpose is to record states via (*ClientOptions).Listener channel.

If buffer is > 0, the recorder will use it as a buffer to ensure all states transitions are received. If buffer is <= 0, the recorder will not buffer any states, which can result in some of them being dropped.

func (*StateRecorder) Add

func (rec *StateRecorder) Add(state ably.StateEnum)

Add appends state to the list of recorded ones, used to ensure ordering of the states by injecting values at certain points of the test.

func (*StateRecorder) Channel

func (rec *StateRecorder) Channel() chan<- ably.State

func (*StateRecorder) Errors

func (rec *StateRecorder) Errors() []error

Errors gives copy of the error that recorded events hold. It returns only non-nil errors. If none of the recorded states contained an error, the method returns nil.

func (*StateRecorder) States

func (rec *StateRecorder) States() []ably.StateEnum

States gives copy of the recorded states, safe for use while the recorder is still running.

func (*StateRecorder) Stop

func (rec *StateRecorder) Stop()

Stop stops separate recording gorouting and waits until it terminates.

func (*StateRecorder) WaitFor

func (rec *StateRecorder) WaitFor(states []ably.StateEnum) error

WaitFor blocks until we observe the given exact states were recorded.

Jump to

Keyboard shortcuts

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