коммит произвёл
mattermod
родитель
72f3bb10c7
Коммит
6e6a44764c
@@ -4,6 +4,7 @@
|
|||||||
package api4
|
package api4
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -11,8 +12,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"encoding/base64"
|
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/v5/app"
|
"github.com/mattermost/mattermost-server/v5/app"
|
||||||
"github.com/mattermost/mattermost-server/v5/model"
|
"github.com/mattermost/mattermost-server/v5/model"
|
||||||
"github.com/mattermost/mattermost-server/v5/services/mailservice"
|
"github.com/mattermost/mattermost-server/v5/services/mailservice"
|
||||||
@@ -258,7 +257,7 @@ func TestUpdateTeam(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
Client := th.Client
|
Client := th.Client
|
||||||
|
|
||||||
team := &model.Team{DisplayName: "Name", Description: "Some description", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
|
team := &model.Team{DisplayName: "Name", Description: "Some description", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewRandomTeamName() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
|
||||||
team, _ = Client.CreateTeam(team)
|
team, _ = Client.CreateTeam(team)
|
||||||
|
|
||||||
team.Description = "updated description"
|
team.Description = "updated description"
|
||||||
@@ -377,7 +376,7 @@ func TestPatchTeam(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
Client := th.Client
|
Client := th.Client
|
||||||
|
|
||||||
team := &model.Team{DisplayName: "Name", Description: "Some description", CompanyName: "Some company name", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
|
team := &model.Team{DisplayName: "Name", Description: "Some description", CompanyName: "Some company name", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewRandomTeamName() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
|
||||||
team, _ = Client.CreateTeam(team)
|
team, _ = Client.CreateTeam(team)
|
||||||
|
|
||||||
patch := &model.TeamPatch{}
|
patch := &model.TeamPatch{}
|
||||||
@@ -465,7 +464,7 @@ func TestRegenerateTeamInviteId(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
Client := th.Client
|
Client := th.Client
|
||||||
|
|
||||||
team := &model.Team{DisplayName: "Name", Description: "Some description", CompanyName: "Some company name", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewId() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
|
team := &model.Team{DisplayName: "Name", Description: "Some description", CompanyName: "Some company name", AllowOpenInvite: false, InviteId: "inviteid0", Name: "z-z-" + model.NewRandomTeamName() + "a", Email: "success+" + model.NewId() + "@simulator.amazonses.com", Type: model.TEAM_OPEN}
|
||||||
team, _ = Client.CreateTeam(team)
|
team, _ = Client.CreateTeam(team)
|
||||||
|
|
||||||
assert.NotEqual(t, team.InviteId, "")
|
assert.NotEqual(t, team.InviteId, "")
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ func TestWebSocketStatuses(t *testing.T) {
|
|||||||
resp := <-WebSocketClient.ResponseChannel
|
resp := <-WebSocketClient.ResponseChannel
|
||||||
require.Equal(t, resp.Status, model.STATUS_OK, "should have responded OK to authentication challenge")
|
require.Equal(t, resp.Status, model.STATUS_OK, "should have responded OK to authentication challenge")
|
||||||
|
|
||||||
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewRandomTeamName() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||||
rteam, _ := Client.CreateTeam(&team)
|
rteam, _ := Client.CreateTeam(&team)
|
||||||
|
|
||||||
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
|
||||||
|
|||||||
@@ -595,7 +595,7 @@ func TestImportImportChannel(t *testing.T) {
|
|||||||
scheme2 := th.SetupChannelScheme()
|
scheme2 := th.SetupChannelScheme()
|
||||||
|
|
||||||
// Import a Team.
|
// Import a Team.
|
||||||
teamName := model.NewId()
|
teamName := model.NewRandomTeamName()
|
||||||
th.App.ImportTeam(&TeamImportData{
|
th.App.ImportTeam(&TeamImportData{
|
||||||
Name: &teamName,
|
Name: &teamName,
|
||||||
DisplayName: ptrStr("Display Name"),
|
DisplayName: ptrStr("Display Name"),
|
||||||
@@ -862,7 +862,7 @@ func TestImportImportUser(t *testing.T) {
|
|||||||
data.Password = ptrStr("TestPassword")
|
data.Password = ptrStr("TestPassword")
|
||||||
|
|
||||||
// Test team and channel memberships
|
// Test team and channel memberships
|
||||||
teamName := model.NewId()
|
teamName := model.NewRandomTeamName()
|
||||||
th.App.ImportTeam(&TeamImportData{
|
th.App.ImportTeam(&TeamImportData{
|
||||||
Name: &teamName,
|
Name: &teamName,
|
||||||
DisplayName: ptrStr("Display Name"),
|
DisplayName: ptrStr("Display Name"),
|
||||||
@@ -1570,7 +1570,7 @@ func TestImportImportPost(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
// Create a Team.
|
// Create a Team.
|
||||||
teamName := model.NewId()
|
teamName := model.NewRandomTeamName()
|
||||||
th.App.ImportTeam(&TeamImportData{
|
th.App.ImportTeam(&TeamImportData{
|
||||||
Name: &teamName,
|
Name: &teamName,
|
||||||
DisplayName: ptrStr("Display Name"),
|
DisplayName: ptrStr("Display Name"),
|
||||||
@@ -2510,7 +2510,7 @@ func TestImportPostAndRepliesWithAttachments(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|
||||||
// Create a Team.
|
// Create a Team.
|
||||||
teamName := model.NewId()
|
teamName := model.NewRandomTeamName()
|
||||||
th.App.ImportTeam(&TeamImportData{
|
th.App.ImportTeam(&TeamImportData{
|
||||||
Name: &teamName,
|
Name: &teamName,
|
||||||
DisplayName: ptrStr("Display Name"),
|
DisplayName: ptrStr("Display Name"),
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ func TestImportBulkImport(t *testing.T) {
|
|||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = true })
|
||||||
|
|
||||||
teamName := model.NewId()
|
teamName := model.NewRandomTeamName()
|
||||||
channelName := model.NewId()
|
channelName := model.NewId()
|
||||||
username := model.NewId()
|
username := model.NewId()
|
||||||
username2 := model.NewId()
|
username2 := model.NewId()
|
||||||
|
|||||||
@@ -146,6 +146,15 @@ func NewId() string {
|
|||||||
return b.String()
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewRandomTeamName is a NewId that will be a valid team name.
|
||||||
|
func NewRandomTeamName() string {
|
||||||
|
teamName := NewId()
|
||||||
|
for IsReservedTeamName(teamName) {
|
||||||
|
teamName = NewId()
|
||||||
|
}
|
||||||
|
return teamName
|
||||||
|
}
|
||||||
|
|
||||||
func NewRandomString(length int) string {
|
func NewRandomString(length int) string {
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
str := make([]byte, length+8)
|
str := make([]byte, length+8)
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ func createTeam(ss store.Store, userId string) *model.Team {
|
|||||||
m.DisplayName = "DisplayName"
|
m.DisplayName = "DisplayName"
|
||||||
m.Type = model.TEAM_OPEN
|
m.Type = model.TEAM_OPEN
|
||||||
m.Email = "test@example.com"
|
m.Email = "test@example.com"
|
||||||
m.Name = "z-z-z" + model.NewId() + "b"
|
m.Name = "z-z-z" + model.NewRandomTeamName() + "b"
|
||||||
t, _ := ss.Team().Save(&m)
|
t, _ := ss.Team().Save(&m)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user