Batch disable users (#17254)

* batch disable users

* batch revoke users tokens

* split batch disable user and revoke token

* fix tests for batch disable users

* Chore: add BatchDisableUsers() to the bus
This commit is contained in:
Alexander Zobnin
2019-05-31 13:22:22 +03:00
committed by GitHub
parent 1497f3d79a
commit 60ddad8fdb
5 changed files with 116 additions and 0 deletions
+20
View File
@@ -117,6 +117,26 @@ func TestUserAuthToken(t *testing.T) {
So(model2, ShouldBeNil)
})
})
Convey("When revoking users tokens in a batch", func() {
Convey("Can revoke all users tokens", func() {
userIds := []int64{}
for i := 0; i < 3; i++ {
userId := userID + int64(i+1)
userIds = append(userIds, userId)
userAuthTokenService.CreateToken(context.Background(), userId, "192.168.10.11:1234", "some user agent")
}
err := userAuthTokenService.BatchRevokeAllUserTokens(context.Background(), userIds)
So(err, ShouldBeNil)
for _, v := range userIds {
tokens, err := userAuthTokenService.GetUserTokens(context.Background(), v)
So(err, ShouldBeNil)
So(len(tokens), ShouldEqual, 0)
}
})
})
})
Convey("expires correctly", func() {