diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-03-24 16:42:05 -0400 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2017-03-24 13:42:05 -0700 |
commit | 11b7aa859c4b5108207b1395a91ddbc988ccf00b (patch) | |
tree | 30d93a5ad563dbf6bea17bdcfb9a9a24abbeb4bf /api4/user_test.go | |
parent | a2f78d01bd4d105da374c46bd40c2a585bddd536 (diff) | |
download | chat-11b7aa859c4b5108207b1395a91ddbc988ccf00b.tar.gz chat-11b7aa859c4b5108207b1395a91ddbc988ccf00b.tar.bz2 chat-11b7aa859c4b5108207b1395a91ddbc988ccf00b.zip |
Implement POST /users/email/verify/send endpoint for APIv4 (#5825)
Diffstat (limited to 'api4/user_test.go')
-rw-r--r-- | api4/user_test.go | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/api4/user_test.go b/api4/user_test.go index 6a42d19d2..16ae8bdad 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -1303,7 +1303,7 @@ func TestGetUserAudits(t *testing.T) { CheckNoError(t, resp) } -func TestVerify(t *testing.T) { +func TestVerifyUserEmail(t *testing.T) { th := Setup().InitBasic() defer TearDown() Client := th.Client @@ -1320,15 +1320,34 @@ func TestVerify(t *testing.T) { _, 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) } +func TestSendVerificationEmail(t *testing.T) { + th := Setup().InitBasic() + defer TearDown() + Client := th.Client + + pass, resp := Client.SendVerificationEmail(th.BasicUser.Email) + CheckNoError(t, resp) + + if !pass { + t.Fatal("should have passed") + } + + _, resp = Client.SendVerificationEmail("") + CheckBadRequestStatus(t, resp) + + // Even non-existent emails should return 200 OK + _, resp = Client.SendVerificationEmail(GenerateTestEmail()) + CheckNoError(t, resp) + + Client.Logout() + _, resp = Client.SendVerificationEmail(th.BasicUser.Email) + CheckNoError(t, resp) +} + func TestSetProfileImage(t *testing.T) { th := Setup().InitBasic().InitSystemAdmin() defer TearDown() |