Documentation ¶
Index ¶
- Constants
- Variables
- func AssertEventIDsEqual(t *testing.T, gotEventIDs []string, wants []*gomatrixserverlib.HeaderedEvent)
- func AssertEventsEqual(t *testing.T, gots, wants []*gomatrixserverlib.HeaderedEvent)
- func ListenAndServe(t *testing.T, router http.Handler, withTLS bool) (apiURL string, cancel func())
- func NewMatrixKey(matrixKeyPath string) (err error)
- func NewRequest(t *testing.T, method, path string, opts ...HTTPRequestOpt) *http.Request
- func NewTLSKey(tlsKeyPath, tlsCertPath string) error
- func NewTLSKeyWithAuthority(...) error
- func PrepareDBConnectionString(t *testing.T, dbType DBType) (connStr string, close func())
- func Reversed(in []*gomatrixserverlib.HeaderedEvent) []*gomatrixserverlib.HeaderedEvent
- func RoomPreset(p Preset) roomModifier
- func RoomVersion(ver gomatrixserverlib.RoomVersion) roomModifier
- func UnsortedStringSliceEqual(first, second []string) bool
- func WithAllDatabases(t *testing.T, testFn func(t *testing.T, db DBType))
- func WithKeyID(keyID gomatrixserverlib.KeyID) eventModifier
- func WithOrigin(origin gomatrixserverlib.ServerName) eventModifier
- func WithPrivateKey(pkey ed25519.PrivateKey) eventModifier
- func WithStateKey(skey string) eventModifier
- func WithTimestamp(ts time.Time) eventModifier
- func WithUnsigned(unsigned interface{}) eventModifier
- type DBType
- type HTTPRequestOpt
- type NopJSONVerifier
- type Preset
- type Room
- func (r *Room) CreateAndInsert(t *testing.T, creator *User, eventType string, content interface{}, ...) *gomatrixserverlib.HeaderedEvent
- func (r *Room) CreateEvent(t *testing.T, creator *User, eventType string, content interface{}, ...) *gomatrixserverlib.HeaderedEvent
- func (r *Room) CurrentState() []*gomatrixserverlib.HeaderedEvent
- func (r *Room) Events() []*gomatrixserverlib.HeaderedEvent
- func (r *Room) ForwardExtremities() []string
- func (r *Room) InsertEvent(t *testing.T, he *gomatrixserverlib.HeaderedEvent)
- func (r *Room) MustGetAuthEventRefsForEvent(t *testing.T, needed gomatrixserverlib.StateNeeded) []gomatrixserverlib.EventReference
- type User
- type UserOpt
Constants ¶
const ( // ServerKeyFile is the name of the file holding the matrix server private key. ServerKeyFile = "server_key.pem" // TLSCertFile is the name of the file holding the TLS certificate used for federation. TLSCertFile = "tls_cert.pem" // TLSKeyFile is the name of the file holding the TLS key used for federation. TLSKeyFile = "tls_key.pem" )
Variables ¶
var ( // private keys that tests can use PrivateKeyA = ed25519.NewKeyFromSeed([]byte{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 77, }) PrivateKeyB = ed25519.NewKeyFromSeed([]byte{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 66, }) )
var Quiet = false
var Required = os.Getenv("DENDRITE_TEST_SKIP_NODB") == ""
Functions ¶
func AssertEventIDsEqual ¶
func AssertEventIDsEqual(t *testing.T, gotEventIDs []string, wants []*gomatrixserverlib.HeaderedEvent)
func AssertEventsEqual ¶
func AssertEventsEqual(t *testing.T, gots, wants []*gomatrixserverlib.HeaderedEvent)
func ListenAndServe ¶
ListenAndServe will listen on a random high-numbered port and attach the given router. Returns the base URL to send requests to. Call `cancel` to shutdown the server, which will block until it has closed.
func NewMatrixKey ¶
NewMatrixKey generates a new ed25519 matrix server key and writes it to a file.
func NewRequest ¶
func NewTLSKeyWithAuthority ¶
func PrepareDBConnectionString ¶
Prepare a sqlite or postgres connection string for testing. Returns the connection string to use and a close function which must be called when the test finishes. Calling this function twice will return the same database, which will have data from previous tests unless close() is called. TODO: namespace for concurrent package tests
func Reversed ¶
func Reversed(in []*gomatrixserverlib.HeaderedEvent) []*gomatrixserverlib.HeaderedEvent
Reverse a list of events
func RoomPreset ¶
func RoomPreset(p Preset) roomModifier
func RoomVersion ¶
func RoomVersion(ver gomatrixserverlib.RoomVersion) roomModifier
func UnsortedStringSliceEqual ¶
UnsortedStringSliceEqual returns true if the slices have same length & elements. Does not modify the given slice.
func WithAllDatabases ¶
Creates subtests with each known DBType
func WithKeyID ¶
func WithKeyID(keyID gomatrixserverlib.KeyID) eventModifier
func WithOrigin ¶
func WithOrigin(origin gomatrixserverlib.ServerName) eventModifier
func WithPrivateKey ¶
func WithPrivateKey(pkey ed25519.PrivateKey) eventModifier
func WithStateKey ¶
func WithStateKey(skey string) eventModifier
func WithTimestamp ¶
func WithUnsigned ¶
func WithUnsigned(unsigned interface{}) eventModifier
Types ¶
type HTTPRequestOpt ¶
func WithJSONBody ¶
func WithJSONBody(t *testing.T, body interface{}) HTTPRequestOpt
func WithQueryParams ¶
func WithQueryParams(qps map[string]string) HTTPRequestOpt
type NopJSONVerifier ¶
type NopJSONVerifier struct { }
NopJSONVerifier is a JSONVerifier that verifies nothing and returns no errors.
func (*NopJSONVerifier) VerifyJSONs ¶
func (t *NopJSONVerifier) VerifyJSONs(ctx context.Context, requests []gomatrixserverlib.VerifyJSONRequest) ([]gomatrixserverlib.VerifyJSONResult, error)
type Room ¶
type Room struct { ID string Version gomatrixserverlib.RoomVersion // contains filtered or unexported fields }
func (*Room) CreateAndInsert ¶
func (r *Room) CreateAndInsert(t *testing.T, creator *User, eventType string, content interface{}, mods ...eventModifier) *gomatrixserverlib.HeaderedEvent
func (*Room) CreateEvent ¶
func (r *Room) CreateEvent(t *testing.T, creator *User, eventType string, content interface{}, mods ...eventModifier) *gomatrixserverlib.HeaderedEvent
Create an event in this room but do not insert it. Does not modify the room in any way (depth, fwd extremities, etc) so is thread-safe.
func (*Room) CurrentState ¶
func (r *Room) CurrentState() []*gomatrixserverlib.HeaderedEvent
func (*Room) Events ¶
func (r *Room) Events() []*gomatrixserverlib.HeaderedEvent
func (*Room) ForwardExtremities ¶
func (*Room) InsertEvent ¶
func (r *Room) InsertEvent(t *testing.T, he *gomatrixserverlib.HeaderedEvent)
Add a new event to this room DAG. Not thread-safe.
func (*Room) MustGetAuthEventRefsForEvent ¶
func (r *Room) MustGetAuthEventRefsForEvent(t *testing.T, needed gomatrixserverlib.StateNeeded) []gomatrixserverlib.EventReference
type UserOpt ¶
type UserOpt func(*User)
func WithSigningServer ¶
func WithSigningServer(srvName gomatrixserverlib.ServerName, keyID gomatrixserverlib.KeyID, privKey ed25519.PrivateKey) UserOpt