summaryrefslogtreecommitdiffstats
path: root/app/team_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-03-29 14:20:36 -0700
committerGitHub <noreply@github.com>2018-03-29 14:20:36 -0700
commit59606791a7b18b0a80626d5ec7f05b90b51c779d (patch)
tree6cd0ba11f8f55b03c81a4ac92d11a413be8c1727 /app/team_test.go
parent6fcdf4abc6068a0b7de021a6f7ca26b19cce4ed3 (diff)
downloadchat-59606791a7b18b0a80626d5ec7f05b90b51c779d.tar.gz
chat-59606791a7b18b0a80626d5ec7f05b90b51c779d.tar.bz2
chat-59606791a7b18b0a80626d5ec7f05b90b51c779d.zip
MM-9999 Fix unwanted team invite_id in email invites. (#8550)
* Fix unwanted team invite_id in email invites. * Removing unused translation.
Diffstat (limited to 'app/team_test.go')
-rw-r--r--app/team_test.go67
1 files changed, 0 insertions, 67 deletions
diff --git a/app/team_test.go b/app/team_test.go
index cdfec12da..95f4b83d6 100644
--- a/app/team_test.go
+++ b/app/team_test.go
@@ -7,15 +7,7 @@ import (
"strings"
"testing"
- "fmt"
-
- "sync/atomic"
-
"github.com/mattermost/mattermost-server/model"
- "github.com/mattermost/mattermost-server/store"
- "github.com/mattermost/mattermost-server/store/storetest"
- "github.com/mattermost/mattermost-server/utils"
- "github.com/stretchr/testify/assert"
)
func TestCreateTeam(t *testing.T) {
@@ -402,65 +394,6 @@ func TestSanitizeTeams(t *testing.T) {
})
}
-func TestAddUserToTeamByHashMismatchedInviteId(t *testing.T) {
- mockStore := &storetest.Store{}
- defer mockStore.AssertExpectations(t)
-
- teamId := model.NewId()
- userId := model.NewId()
- inviteSalt := model.NewId()
-
- inviteId := model.NewId()
- teamInviteId := model.NewId()
-
- // generate a fake email invite - stolen from SendInviteEmails() in email.go
- props := make(map[string]string)
- props["email"] = model.NewId() + "@mattermost.com"
- props["id"] = teamId
- props["display_name"] = model.NewId()
- props["name"] = model.NewId()
- props["time"] = fmt.Sprintf("%v", model.GetMillis())
- props["invite_id"] = inviteId
- data := model.MapToJson(props)
- hash := utils.HashSha256(fmt.Sprintf("%v:%v", data, inviteSalt))
-
- // when the server tries to validate the invite, it will pull the user from our mock store
- // this can return nil, because we'll fail before we get to trying to use it
- mockStore.UserStore.On("Get", userId).Return(
- storetest.NewStoreChannel(store.StoreResult{
- Data: nil,
- Err: nil,
- }),
- )
-
- // the server will also pull the team. the one we return has a different invite id than the one in the email invite we made above
- mockStore.TeamStore.On("Get", teamId).Return(
- storetest.NewStoreChannel(store.StoreResult{
- Data: &model.Team{
- InviteId: teamInviteId,
- },
- Err: nil,
- }),
- )
-
- app := App{
- Srv: &Server{
- Store: mockStore,
- },
- config: atomic.Value{},
- }
- app.config.Store(&model.Config{
- EmailSettings: model.EmailSettings{
- InviteSalt: inviteSalt,
- },
- })
-
- // this should fail because the invite ids are mismatched
- team, err := app.AddUserToTeamByHash(userId, hash, data)
- assert.Nil(t, team)
- assert.Equal(t, "api.user.create_user.signup_link_mismatched_invite_id.app_error", err.Id)
-}
-
func TestJoinUserToTeam(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()