Version: v4.10.10+incompatible Latest Latest

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

Go to latest
Published: Jun 14, 2019 License: AGPL-3.0, Apache-2.0 Imports: 36 Imported by: 0




View Source
const (
	FILE_TEAM_ID = "noteam"

	PREVIEW_IMAGE_TYPE   = "image/jpeg"
	THUMBNAIL_IMAGE_TYPE = "image/jpeg"
View Source
const (
	PAGE_DEFAULT          = 0
	PER_PAGE_MAXIMUM      = 200
View Source
const (
View Source
const (
	MAXIMUM_PLUGIN_FILE_SIZE = 50 * 1024 * 1024
View Source
const (
View Source


View Source
var MEDIA_CONTENT_TYPES = [...]string{
View Source
var UNSAFE_CONTENT_TYPES = [...]string{


func CanManageChannel

func CanManageChannel(c *Context, channel *model.Channel) bool

func CheckBadRequestStatus

func CheckBadRequestStatus(t *testing.T, resp *model.Response)

func CheckCreatedStatus

func CheckCreatedStatus(t *testing.T, resp *model.Response)

func CheckErrorMessage

func CheckErrorMessage(t *testing.T, resp *model.Response, errorId string)

func CheckEtag

func CheckEtag(t *testing.T, data interface{}, resp *model.Response)

func CheckForbiddenStatus

func CheckForbiddenStatus(t *testing.T, resp *model.Response)

func CheckInternalErrorStatus

func CheckInternalErrorStatus(t *testing.T, resp *model.Response)

func CheckNoError

func CheckNoError(t *testing.T, resp *model.Response)

func CheckNotFoundStatus

func CheckNotFoundStatus(t *testing.T, resp *model.Response)

func CheckNotImplementedStatus

func CheckNotImplementedStatus(t *testing.T, resp *model.Response)

func CheckOKStatus

func CheckOKStatus(t *testing.T, resp *model.Response)

func CheckUnauthorizedStatus

func CheckUnauthorizedStatus(t *testing.T, resp *model.Response)

func CheckUserSanitization

func CheckUserSanitization(t *testing.T, user *model.User)

func GenerateTestAppName

func GenerateTestAppName() string

func GenerateTestChannelName

func GenerateTestChannelName() string

func GenerateTestId

func GenerateTestId() string

func GenerateTestTeamName

func GenerateTestTeamName() string

func GenerateTestUsername

func GenerateTestUsername() string

func Handle404

func Handle404(w http.ResponseWriter, r *http.Request)

func Logout

func Logout(c *Context, w http.ResponseWriter, r *http.Request)

func NewInvalidParamError

func NewInvalidParamError(parameter string) *model.AppError

func NewInvalidUrlParamError

func NewInvalidUrlParamError(parameter string) *model.AppError

func OpenGraphDataWithProxyAddedToImageURLs

func OpenGraphDataWithProxyAddedToImageURLs(ogdata *opengraph.OpenGraph, toProxyURL func(string) string) *opengraph.OpenGraph

func ReturnStatusOK

func ReturnStatusOK(w http.ResponseWriter)

func StopTestStore

func StopTestStore()

func UseTestStore

func UseTestStore(container *storetest.RunningContainer, settings *model.SqlSettings)

UseTestStore sets the container and corresponding settings to use for tests. Once the tests are complete (e.g. at the end of your TestMain implementation), you should call StopTestStore.


type API

type API struct {
	App        *app.App
	BaseRoutes *Routes

func Init

func Init(a *app.App, root *mux.Router, full bool) *API

func (*API) ApiHandler

func (api *API) ApiHandler(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func (*API) ApiHandlerTrustRequester

func (api *API) ApiHandlerTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func (*API) ApiSessionRequired

func (api *API) ApiSessionRequired(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func (*API) ApiSessionRequiredMfa

func (api *API) ApiSessionRequiredMfa(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func (*API) ApiSessionRequiredTrustRequester

func (api *API) ApiSessionRequiredTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func (*API) InitBrand

func (api *API) InitBrand()

func (*API) InitChannel

func (api *API) InitChannel()

func (*API) InitCluster

func (api *API) InitCluster()

func (*API) InitCommand

func (api *API) InitCommand()

func (*API) InitCompliance

func (api *API) InitCompliance()

func (*API) InitDataRetention

func (api *API) InitDataRetention()

func (*API) InitElasticsearch

func (api *API) InitElasticsearch()

func (*API) InitEmoji

func (api *API) InitEmoji()

func (*API) InitFile

func (api *API) InitFile()

func (*API) InitImage

func (api *API) InitImage()

func (*API) InitJob

func (api *API) InitJob()

func (*API) InitLdap

func (api *API) InitLdap()

func (*API) InitOAuth

func (api *API) InitOAuth()

func (*API) InitOpenGraph

func (api *API) InitOpenGraph()

func (*API) InitPlugin

func (api *API) InitPlugin()

func (*API) InitPost

func (api *API) InitPost()

func (*API) InitPreference

func (api *API) InitPreference()

func (*API) InitReaction

func (api *API) InitReaction()

func (*API) InitRole

func (api *API) InitRole()

func (*API) InitSaml

func (api *API) InitSaml()

func (*API) InitStatus

func (api *API) InitStatus()

func (*API) InitSystem

func (api *API) InitSystem()

func (*API) InitTeam

func (api *API) InitTeam()

func (*API) InitUser

func (api *API) InitUser()

func (*API) InitWebSocket

func (api *API) InitWebSocket()

func (*API) InitWebhook

func (api *API) InitWebhook()

func (*API) InitWebrtc

func (api *API) InitWebrtc()

type ApiParams

type ApiParams struct {
	UserId         string
	TeamId         string
	InviteId       string
	TokenId        string
	ChannelId      string
	PostId         string
	FileId         string
	Filename       string
	PluginId       string
	CommandId      string
	HookId         string
	ReportId       string
	EmojiId        string
	AppId          string
	Email          string
	Username       string
	TeamName       string
	ChannelName    string
	PreferenceName string
	EmojiName      string
	Category       string
	Service        string
	JobId          string
	JobType        string
	ActionId       string
	RoleId         string
	RoleName       string
	Page           int
	PerPage        int
	LogsPerPage    int
	Permanent      bool

func ApiParamsFromRequest

func ApiParamsFromRequest(r *http.Request) *ApiParams

type Context

type Context struct {
	App       *app.App
	Session   model.Session
	Params    *ApiParams
	Err       *model.AppError
	T         goi18n.TranslateFunc
	RequestId string
	IpAddress string
	Path      string
	// contains filtered or unexported fields

func (*Context) GetSiteURLHeader

func (c *Context) GetSiteURLHeader() string

func (*Context) HandleEtag

func (c *Context) HandleEtag(etag string, routeName string, w http.ResponseWriter, r *http.Request) bool

func (*Context) IsSystemAdmin

func (c *Context) IsSystemAdmin() bool

func (*Context) LogAudit

func (c *Context) LogAudit(extraInfo string)

func (*Context) LogAuditWithUserId

func (c *Context) LogAuditWithUserId(userId, extraInfo string)

func (*Context) LogDebug

func (c *Context) LogDebug(err *model.AppError)

func (*Context) LogError

func (c *Context) LogError(err *model.AppError)

func (*Context) LogInfo

func (c *Context) LogInfo(err *model.AppError)

func (*Context) MfaRequired

func (c *Context) MfaRequired()

func (*Context) RemoveSessionCookie

func (c *Context) RemoveSessionCookie(w http.ResponseWriter, r *http.Request)

func (*Context) RequireActionId

func (c *Context) RequireActionId() *Context

func (*Context) RequireAppId

func (c *Context) RequireAppId() *Context

func (*Context) RequireCategory

func (c *Context) RequireCategory() *Context

func (*Context) RequireChannelId

func (c *Context) RequireChannelId() *Context

func (*Context) RequireChannelName

func (c *Context) RequireChannelName() *Context

func (*Context) RequireCommandId

func (c *Context) RequireCommandId() *Context

func (*Context) RequireEmail

func (c *Context) RequireEmail() *Context

func (*Context) RequireEmojiId

func (c *Context) RequireEmojiId() *Context

func (*Context) RequireEmojiName

func (c *Context) RequireEmojiName() *Context

func (*Context) RequireFileId

func (c *Context) RequireFileId() *Context

func (*Context) RequireFilename

func (c *Context) RequireFilename() *Context

func (*Context) RequireHookId

func (c *Context) RequireHookId() *Context

func (*Context) RequireInviteId

func (c *Context) RequireInviteId() *Context

func (*Context) RequireJobId

func (c *Context) RequireJobId() *Context

func (*Context) RequireJobType

func (c *Context) RequireJobType() *Context

func (*Context) RequirePluginId

func (c *Context) RequirePluginId() *Context

func (*Context) RequirePostId

func (c *Context) RequirePostId() *Context

func (*Context) RequirePreferenceName

func (c *Context) RequirePreferenceName() *Context

func (*Context) RequireReportId

func (c *Context) RequireReportId() *Context

func (*Context) RequireRoleId

func (c *Context) RequireRoleId() *Context

func (*Context) RequireRoleName

func (c *Context) RequireRoleName() *Context

func (*Context) RequireService

func (c *Context) RequireService() *Context

func (*Context) RequireTeamId

func (c *Context) RequireTeamId() *Context

func (*Context) RequireTeamName

func (c *Context) RequireTeamName() *Context

func (*Context) RequireTokenId

func (c *Context) RequireTokenId() *Context

func (*Context) RequireUserId

func (c *Context) RequireUserId() *Context

func (*Context) RequireUsername

func (c *Context) RequireUsername() *Context

func (*Context) SessionRequired

func (c *Context) SessionRequired()

func (*Context) SetInvalidParam

func (c *Context) SetInvalidParam(parameter string)

func (*Context) SetInvalidUrlParam

func (c *Context) SetInvalidUrlParam(parameter string)

func (*Context) SetPermissionError

func (c *Context) SetPermissionError(permission *model.Permission)

func (*Context) SetSiteURLHeader

func (c *Context) SetSiteURLHeader(url string)

type Routes

type Routes struct {
	Root    *mux.Router // ”
	ApiRoot *mux.Router // 'api/v4'

	Users          *mux.Router // 'api/v4/users'
	User           *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}'
	UserByUsername *mux.Router // 'api/v4/users/username/{username:[A-Za-z0-9_-\.]+}'
	UserByEmail    *mux.Router // 'api/v4/users/email/{email}'

	Teams              *mux.Router // 'api/v4/teams'
	TeamsForUser       *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/teams'
	Team               *mux.Router // 'api/v4/teams/{team_id:[A-Za-z0-9]+}'
	TeamForUser        *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/teams/{team_id:[A-Za-z0-9]+}'
	TeamByName         *mux.Router // 'api/v4/teams/name/{team_name:[A-Za-z0-9_-]+}'
	TeamMembers        *mux.Router // 'api/v4/teams/{team_id:[A-Za-z0-9_-]+}/members'
	TeamMember         *mux.Router // 'api/v4/teams/{team_id:[A-Za-z0-9_-]+}/members/{user_id:[A-Za-z0-9_-]+}'
	TeamMembersForUser *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/teams/members'

	Channels                 *mux.Router // 'api/v4/channels'
	Channel                  *mux.Router // 'api/v4/channels/{channel_id:[A-Za-z0-9]+}'
	ChannelForUser           *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/channels/{channel_id:[A-Za-z0-9]+}'
	ChannelByName            *mux.Router // 'api/v4/teams/{team_id:[A-Za-z0-9]+}/channels/name/{channel_name:[A-Za-z0-9_-]+}'
	ChannelByNameForTeamName *mux.Router // 'api/v4/teams/name/{team_name:[A-Za-z0-9_-]+}/channels/name/{channel_name:[A-Za-z0-9_-]+}'
	ChannelsForTeam          *mux.Router // 'api/v4/teams/{team_id:[A-Za-z0-9]+}/channels'
	ChannelMembers           *mux.Router // 'api/v4/channels/{channel_id:[A-Za-z0-9]+}/members'
	ChannelMember            *mux.Router // 'api/v4/channels/{channel_id:[A-Za-z0-9]+}/members/{user_id:[A-Za-z0-9]+}'
	ChannelMembersForUser    *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/teams/{team_id:[A-Za-z0-9]+}/channels/members'

	Posts           *mux.Router // 'api/v4/posts'
	Post            *mux.Router // 'api/v4/posts/{post_id:[A-Za-z0-9]+}'
	PostsForChannel *mux.Router // 'api/v4/channels/{channel_id:[A-Za-z0-9]+}/posts'
	PostsForUser    *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/posts'
	PostForUser     *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/posts/{post_id:[A-Za-z0-9]+}'

	Files *mux.Router // 'api/v4/files'
	File  *mux.Router // 'api/v4/files/{file_id:[A-Za-z0-9]+}'

	Plugins *mux.Router // 'api/v4/plugins'
	Plugin  *mux.Router // 'api/v4/plugins/{plugin_id:[A-Za-z0-9_-]+}'

	PublicFile *mux.Router // 'files/{file_id:[A-Za-z0-9]+}/public'

	Commands *mux.Router // 'api/v4/commands'
	Command  *mux.Router // 'api/v4/commands/{command_id:[A-Za-z0-9]+}'

	Hooks         *mux.Router // 'api/v4/hooks'
	IncomingHooks *mux.Router // 'api/v4/hooks/incoming'
	IncomingHook  *mux.Router // 'api/v4/hooks/incoming/{hook_id:[A-Za-z0-9]+}'
	OutgoingHooks *mux.Router // 'api/v4/hooks/outgoing'
	OutgoingHook  *mux.Router // 'api/v4/hooks/outgoing/{hook_id:[A-Za-z0-9]+}'

	OAuth     *mux.Router // 'api/v4/oauth'
	OAuthApps *mux.Router // 'api/v4/oauth/apps'
	OAuthApp  *mux.Router // 'api/v4/oauth/apps/{app_id:[A-Za-z0-9]+}'

	OpenGraph *mux.Router // 'api/v4/opengraph'

	SAML       *mux.Router // 'api/v4/saml'
	Compliance *mux.Router // 'api/v4/compliance'
	Cluster    *mux.Router // 'api/v4/cluster'

	Image *mux.Router // 'api/v4/image'

	LDAP *mux.Router // 'api/v4/ldap'

	Elasticsearch *mux.Router // 'api/v4/elasticsearch'

	DataRetention *mux.Router // 'api/v4/data_retention'

	Brand *mux.Router // 'api/v4/brand'

	System *mux.Router // 'api/v4/system'

	Jobs *mux.Router // 'api/v4/jobs'

	Preferences *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/preferences'

	License *mux.Router // 'api/v4/license'

	Public *mux.Router // 'api/v4/public'

	Reactions *mux.Router // 'api/v4/reactions'

	Roles *mux.Router // 'api/v4/roles'

	Emojis      *mux.Router // 'api/v4/emoji'
	Emoji       *mux.Router // 'api/v4/emoji/{emoji_id:[A-Za-z0-9]+}'
	EmojiByName *mux.Router // 'api/v4/emoji/name/{emoji_name:[A-Za-z0-9_-\.]+}'

	ReactionByNameForPostForUser *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/posts/{post_id:[A-Za-z0-9]+}/reactions/{emoji_name:[A-Za-z0-9_-+]+}'

	Webrtc *mux.Router // 'api/v4/webrtc'

type TestHelper

type TestHelper struct {
	App *app.App

	Client              *model.Client4
	BasicUser           *model.User
	BasicUser2          *model.User
	TeamAdminUser       *model.User
	BasicTeam           *model.Team
	BasicChannel        *model.Channel
	BasicPrivateChannel *model.Channel
	BasicChannel2       *model.Channel
	BasicPost           *model.Post

	SystemAdminClient *model.Client4
	SystemAdminUser   *model.User
	// contains filtered or unexported fields

func Setup

func Setup() *TestHelper

func SetupEnterprise

func SetupEnterprise() *TestHelper

func (*TestHelper) AddPermissionToRole

func (me *TestHelper) AddPermissionToRole(permission string, roleName string)

func (*TestHelper) AddUserToChannel

func (me *TestHelper) AddUserToChannel(user *model.User, channel *model.Channel) *model.ChannelMember

func (*TestHelper) CreateChannelWithClient

func (me *TestHelper) CreateChannelWithClient(client *model.Client4, channelType string) *model.Channel

func (*TestHelper) CreateChannelWithClientAndTeam

func (me *TestHelper) CreateChannelWithClientAndTeam(client *model.Client4, channelType string, teamId string) *model.Channel

func (*TestHelper) CreateClient

func (me *TestHelper) CreateClient() *model.Client4

func (*TestHelper) CreateMessagePost

func (me *TestHelper) CreateMessagePost(message string) *model.Post

func (*TestHelper) CreateMessagePostWithClient

func (me *TestHelper) CreateMessagePostWithClient(client *model.Client4, channel *model.Channel, message string) *model.Post

func (*TestHelper) CreatePinnedPost

func (me *TestHelper) CreatePinnedPost() *model.Post

func (*TestHelper) CreatePinnedPostWithClient

func (me *TestHelper) CreatePinnedPostWithClient(client *model.Client4, channel *model.Channel) *model.Post

func (*TestHelper) CreatePost

func (me *TestHelper) CreatePost() *model.Post

func (*TestHelper) CreatePostWithClient

func (me *TestHelper) CreatePostWithClient(client *model.Client4, channel *model.Channel) *model.Post

func (*TestHelper) CreatePrivateChannel

func (me *TestHelper) CreatePrivateChannel() *model.Channel

func (*TestHelper) CreatePublicChannel

func (me *TestHelper) CreatePublicChannel() *model.Channel

func (*TestHelper) CreateTeam

func (me *TestHelper) CreateTeam() *model.Team

func (*TestHelper) CreateTeamWithClient

func (me *TestHelper) CreateTeamWithClient(client *model.Client4) *model.Team

func (*TestHelper) CreateUser

func (me *TestHelper) CreateUser() *model.User

func (*TestHelper) CreateUserWithClient

func (me *TestHelper) CreateUserWithClient(client *model.Client4) *model.User

func (*TestHelper) CreateWebSocketClient

func (me *TestHelper) CreateWebSocketClient() (*model.WebSocketClient, *model.AppError)

func (*TestHelper) GenerateTestEmail

func (me *TestHelper) GenerateTestEmail() string

func (*TestHelper) InitBasic

func (me *TestHelper) InitBasic() *TestHelper

func (*TestHelper) InitSystemAdmin

func (me *TestHelper) InitSystemAdmin() *TestHelper

func (*TestHelper) LinkUserToTeam

func (me *TestHelper) LinkUserToTeam(user *model.User, team *model.Team)

func (*TestHelper) LoginBasic

func (me *TestHelper) LoginBasic()

func (*TestHelper) LoginBasic2

func (me *TestHelper) LoginBasic2()

func (*TestHelper) LoginBasic2WithClient

func (me *TestHelper) LoginBasic2WithClient(client *model.Client4)

func (*TestHelper) LoginBasicWithClient

func (me *TestHelper) LoginBasicWithClient(client *model.Client4)

func (*TestHelper) LoginSystemAdmin

func (me *TestHelper) LoginSystemAdmin()

func (*TestHelper) LoginSystemAdminWithClient

func (me *TestHelper) LoginSystemAdminWithClient(client *model.Client4)

func (*TestHelper) LoginTeamAdmin

func (me *TestHelper) LoginTeamAdmin()

func (*TestHelper) LoginTeamAdminWithClient

func (me *TestHelper) LoginTeamAdminWithClient(client *model.Client4)

func (*TestHelper) MakeUserChannelAdmin

func (me *TestHelper) MakeUserChannelAdmin(user *model.User, channel *model.Channel)

func (*TestHelper) RemovePermissionFromRole

func (me *TestHelper) RemovePermissionFromRole(permission string, roleName string)

func (*TestHelper) RestoreDefaultRolePermissions

func (me *TestHelper) RestoreDefaultRolePermissions(data map[string][]string)

func (*TestHelper) SaveDefaultRolePermissions

func (me *TestHelper) SaveDefaultRolePermissions() map[string][]string

func (*TestHelper) TearDown

func (me *TestHelper) TearDown()

func (*TestHelper) UpdateActiveUser

func (me *TestHelper) UpdateActiveUser(user *model.User, active bool)

func (*TestHelper) UpdateUserToNonTeamAdmin

func (me *TestHelper) UpdateUserToNonTeamAdmin(user *model.User, team *model.Team)

func (*TestHelper) UpdateUserToTeamAdmin

func (me *TestHelper) UpdateUserToTeamAdmin(user *model.User, team *model.Team)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL