summaryrefslogtreecommitdiffstats
path: root/api4/user_test.go
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2017-02-24 14:27:47 +0100
committerJoram Wilander <jwawilander@gmail.com>2017-02-24 08:27:47 -0500
commit7fc5dc236aa2437e81b238f65d39c2f795eac493 (patch)
tree27c84da1c0b63e181810200f0e94d29707487927 /api4/user_test.go
parentace228c4e52bd25dca24d1a5b35eff97740e5ea2 (diff)
downloadchat-7fc5dc236aa2437e81b238f65d39c2f795eac493.tar.gz
chat-7fc5dc236aa2437e81b238f65d39c2f795eac493.tar.bz2
chat-7fc5dc236aa2437e81b238f65d39c2f795eac493.zip
add implementation for verify email for apiv4 (#5502)
Diffstat (limited to 'api4/user_test.go')
-rw-r--r--api4/user_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/api4/user_test.go b/api4/user_test.go
index 07b9745c6..ee6cf079b 100644
--- a/api4/user_test.go
+++ b/api4/user_test.go
@@ -924,3 +924,29 @@ func TestGetAudits(t *testing.T) {
_, resp = th.SystemAdminClient.GetAudits(user.Id, 0, 100, "")
CheckNoError(t, resp)
}
+
+func TestVerify(t *testing.T) {
+ th := Setup().InitBasic()
+ defer TearDown()
+ Client := th.Client
+
+ user := model.User{Email: GenerateTestEmail(), Nickname: "Darth Vader", Password: "hello1", Username: GenerateTestUsername(), Roles: model.ROLE_SYSTEM_ADMIN.Id + " " + model.ROLE_SYSTEM_USER.Id}
+
+ ruser, resp := Client.CreateUser(&user)
+
+ hashId := ruser.Id+utils.Cfg.EmailSettings.InviteSalt
+ _, resp = Client.VerifyUserEmail(ruser.Id, hashId)
+ CheckNoError(t, resp)
+
+ hashId = ruser.Id+GenerateTestId()
+ _, resp = Client.VerifyUserEmail(ruser.Id, hashId)
+ CheckBadRequestStatus(t, resp)
+
+ // Comment per request from Joram, he will investigate why it fail with a wrong status
+ // hashId = ruser.Id+GenerateTestId()
+ // _, resp = Client.VerifyUserEmail("", hashId)
+ // CheckBadRequestStatus(t, resp)
+
+ _, resp = Client.VerifyUserEmail(ruser.Id, "")
+ CheckBadRequestStatus(t, resp)
+}