apitest

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertResponseError

func AssertResponseError(t *testing.T, rr *httptest.ResponseRecorder, statusCode int, expReqErr *types.ExternalError)

func AssertResponseExpected

func AssertResponseExpected(t *testing.T, rr *httptest.ResponseRecorder, expResponse interface{}, gotTarget interface{})

func AssertResponseForbidden

func AssertResponseForbidden(t *testing.T, rr *httptest.ResponseRecorder)

func AssertResponseInternalServerError

func AssertResponseInternalServerError(t *testing.T, rr *httptest.ResponseRecorder)

func AuthenticateUserWithCookie

func AuthenticateUserWithCookie(
	t *testing.T,
	config *config.Config,
	user *models.User,
	badUserIDType bool,
) *http.Cookie

AuthenticateUserWithCookie uses the session store to create a cookie for a user

func AuthenticateUserWithToken

func AuthenticateUserWithToken(t *testing.T, config *config.Config, userID uint) string

AuthenticateUserWithToken uses the JWT token generator to create a token for a user

func CreateTestUser

func CreateTestUser(t *testing.T, config *config.Config, verified bool) *models.User

func GetRequestAndRecorder

func GetRequestAndRecorder(t *testing.T, method, route string, requestObj interface{}) (*http.Request, *httptest.ResponseRecorder)

func LoadConfig

func LoadConfig(t *testing.T, failingRepoMethods ...string) *config.Config

func NewFailingDecoderValidator

func NewFailingDecoderValidator(config *config.Config) shared.RequestDecoderValidator

func NewFakeUserNotifier

func NewFakeUserNotifier() notifier.UserNotifier

func NewTestConfigLoader

func NewTestConfigLoader(canQuery bool, failingRepoMethods ...string) config.ConfigLoader

func WithAuthenticatedUser

func WithAuthenticatedUser(t *testing.T, req *http.Request, user *models.User) *http.Request

func WithProject

func WithProject(t *testing.T, req *http.Request, proj *models.Project) *http.Request

func WithRequestScopes

func WithRequestScopes(t *testing.T, req *http.Request, reqScopes map[types.PermissionScope]*types.RequestAction) *http.Request

func WithURLParams

func WithURLParams(t *testing.T, req *http.Request, params map[string]string) *http.Request

Types

type FakeUserNotifier

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

FakeUserNotifier just stores data about a single notification, without sending the data anywhere

func (*FakeUserNotifier) GetGithubRelinkEmailLastOpts

func (f *FakeUserNotifier) GetGithubRelinkEmailLastOpts() *notifier.SendGithubRelinkEmailOpts

func (*FakeUserNotifier) GetPasswordResetEmailLastOpts

func (f *FakeUserNotifier) GetPasswordResetEmailLastOpts() *notifier.SendPasswordResetEmailOpts

func (*FakeUserNotifier) GetSendEmailVerificationLastOpts

func (f *FakeUserNotifier) GetSendEmailVerificationLastOpts() *notifier.SendEmailVerificationOpts

func (*FakeUserNotifier) GetSendProjectInviteEmailLastOpts

func (f *FakeUserNotifier) GetSendProjectInviteEmailLastOpts() *notifier.SendProjectInviteEmailOpts

func (*FakeUserNotifier) SendEmailVerification

func (f *FakeUserNotifier) SendEmailVerification(opts *notifier.SendEmailVerificationOpts) error

func (*FakeUserNotifier) SendGithubRelinkEmail

func (f *FakeUserNotifier) SendGithubRelinkEmail(opts *notifier.SendGithubRelinkEmailOpts) error

func (*FakeUserNotifier) SendPasswordResetEmail

func (f *FakeUserNotifier) SendPasswordResetEmail(opts *notifier.SendPasswordResetEmailOpts) error

func (*FakeUserNotifier) SendProjectInviteEmail

func (f *FakeUserNotifier) SendProjectInviteEmail(opts *notifier.SendProjectInviteEmailOpts) error

type TestConfigLoader

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

func (*TestConfigLoader) LoadConfig

func (t *TestConfigLoader) LoadConfig() (*config.Config, error)

Jump to

Keyboard shortcuts

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