summaryrefslogtreecommitdiffstats
path: root/api4/user_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-27 09:17:34 -0400
committerChristopher Speller <crspeller@gmail.com>2017-03-27 09:17:34 -0400
commitd145c3583835766c1f200a413131e7d6bad82229 (patch)
tree1671fd532293482f035f40accd068e19da1d86df /api4/user_test.go
parent84dc60a640bbfb3b670a65f1c9ea6ce35ad1b5cc (diff)
downloadchat-d145c3583835766c1f200a413131e7d6bad82229.tar.gz
chat-d145c3583835766c1f200a413131e7d6bad82229.tar.bz2
chat-d145c3583835766c1f200a413131e7d6bad82229.zip
Implement PUT /users/sessions/device endpoint for APIv4 (#5866)
Diffstat (limited to 'api4/user_test.go')
-rw-r--r--api4/user_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/api4/user_test.go b/api4/user_test.go
index 16ae8bdad..3bdc73045 100644
--- a/api4/user_test.go
+++ b/api4/user_test.go
@@ -1275,7 +1275,36 @@ func TestRevokeSessions(t *testing.T) {
_, resp = th.SystemAdminClient.RevokeSession(th.SystemAdminUser.Id, session.Id)
CheckNoError(t, resp)
+}
+
+func TestAttachDeviceId(t *testing.T) {
+ th := Setup().InitBasic()
+ defer TearDown()
+ Client := th.Client
+
+ deviceId := model.PUSH_NOTIFY_APPLE + ":1234567890"
+ pass, resp := Client.AttachDeviceId(deviceId)
+ CheckNoError(t, resp)
+
+ if !pass {
+ t.Fatal("should have passed")
+ }
+ if sessions, err := app.GetSessions(th.BasicUser.Id); err != nil {
+ t.Fatal(err)
+ } else {
+ if sessions[0].DeviceId != deviceId {
+ t.Fatal("Missing device Id")
+ }
+ }
+
+ _, resp = Client.AttachDeviceId("")
+ CheckBadRequestStatus(t, resp)
+
+ Client.Logout()
+
+ _, resp = Client.AttachDeviceId("")
+ CheckUnauthorizedStatus(t, resp)
}
func TestGetUserAudits(t *testing.T) {