diff options
author | Chris <ccbrown112@gmail.com> | 2017-11-02 16:24:11 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-11-02 17:24:11 -0400 |
commit | 9d32cd42085bbb37460d815c6c1a00ad881c4895 (patch) | |
tree | eb6963263ecd79ea4e5166a117a6be5ff9706687 /app/user_test.go | |
parent | fed5324ce505c3725472af23757cd6659bb7139c (diff) | |
download | chat-9d32cd42085bbb37460d815c6c1a00ad881c4895.tar.gz chat-9d32cd42085bbb37460d815c6c1a00ad881c4895.tar.bz2 chat-9d32cd42085bbb37460d815c6c1a00ad881c4895.zip |
prevent deactivation of sso users (#7759)
Diffstat (limited to 'app/user_test.go')
-rw-r--r-- | app/user_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/user_test.go b/app/user_test.go index 51db207ef..d9f40a604 100644 --- a/app/user_test.go +++ b/app/user_test.go @@ -13,6 +13,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/mattermost/mattermost-server/einterfaces" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/model/gitlab" @@ -98,6 +100,24 @@ func TestCreateOAuthUser(t *testing.T) { } } +func TestDeactivateSSOUser(t *testing.T) { + th := Setup().InitBasic() + defer th.TearDown() + + r := rand.New(rand.NewSource(time.Now().UnixNano())) + glUser := oauthgitlab.GitLabUser{Id: int64(r.Intn(1000)) + 1, Username: "o" + model.NewId(), Email: model.NewId() + "@simulator.amazonses.com", Name: "Joram Wilander"} + + json := glUser.ToJson() + user, err := th.App.CreateOAuthUser(model.USER_AUTH_SERVICE_GITLAB, strings.NewReader(json), th.BasicTeam.Id) + if err != nil { + t.Fatal(err) + } + defer th.App.PermanentDeleteUser(user) + + _, err = th.App.UpdateNonSSOUserActive(user.Id, false) + assert.Equal(t, "api.user.update_active.no_deactivate_sso.app_error", err.Id) +} + func TestCreateProfileImage(t *testing.T) { b, err := CreateProfileImage("Corey Hulen", "eo1zkdr96pdj98pjmq8zy35wba", "luximbi.ttf") if err != nil { |