diff options
Diffstat (limited to 'store/storetest/user_access_token_store.go')
-rw-r--r-- | store/storetest/user_access_token_store.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/store/storetest/user_access_token_store.go b/store/storetest/user_access_token_store.go index 292929419..661c969da 100644 --- a/store/storetest/user_access_token_store.go +++ b/store/storetest/user_access_token_store.go @@ -12,6 +12,7 @@ import ( func TestUserAccessTokenStore(t *testing.T, ss store.Store) { t.Run("UserAccessTokenSaveGetDelete", func(t *testing.T) { testUserAccessTokenSaveGetDelete(t, ss) }) + t.Run("UserAccessTokenDisableEnable", func(t *testing.T) { testUserAccessTokenDisableEnable(t, ss) }) } func testUserAccessTokenSaveGetDelete(t *testing.T, ss store.Store) { @@ -87,3 +88,39 @@ func testUserAccessTokenSaveGetDelete(t *testing.T, ss store.Store) { t.Fatal("should error - access token should be deleted") } } + +func testUserAccessTokenDisableEnable(t *testing.T, ss store.Store) { + uat := &model.UserAccessToken{ + Token: model.NewId(), + UserId: model.NewId(), + Description: "testtoken", + } + + s1 := model.Session{} + s1.UserId = uat.UserId + s1.Token = uat.Token + + store.Must(ss.Session().Save(&s1)) + + if result := <-ss.UserAccessToken().Save(uat); result.Err != nil { + t.Fatal(result.Err) + } + + if err := (<-ss.UserAccessToken().UpdateTokenDisable(uat.Id)).Err; err != nil { + t.Fatal(err) + } + + if err := (<-ss.Session().Get(s1.Token)).Err; err == nil { + t.Fatal("should error - session should be deleted") + } + + s2 := model.Session{} + s2.UserId = uat.UserId + s2.Token = uat.Token + + store.Must(ss.Session().Save(&s2)) + + if err := (<-ss.UserAccessToken().UpdateTokenEnable(uat.Id)).Err; err != nil { + t.Fatal(err) + } +} |