|
@@ -175,17 +175,21 @@ func TestUserAuth(t *testing.T) {
|
|
|
login := "loginuser0"
|
|
login := "loginuser0"
|
|
|
|
|
|
|
|
// Calling GetUserByAuthInfoQuery on an existing user will populate an entry in the user_auth table
|
|
// Calling GetUserByAuthInfoQuery on an existing user will populate an entry in the user_auth table
|
|
|
|
|
+ // Make the first log-in during the past
|
|
|
|
|
+ getTime = func() time.Time { return time.Now().AddDate(0, 0, -2) }
|
|
|
query := &m.GetUserByAuthInfoQuery{Login: login, AuthModule: "test1", AuthId: "test1"}
|
|
query := &m.GetUserByAuthInfoQuery{Login: login, AuthModule: "test1", AuthId: "test1"}
|
|
|
err = GetUserByAuthInfo(query)
|
|
err = GetUserByAuthInfo(query)
|
|
|
|
|
+ getTime = time.Now
|
|
|
|
|
|
|
|
So(err, ShouldBeNil)
|
|
So(err, ShouldBeNil)
|
|
|
So(query.Result.Login, ShouldEqual, login)
|
|
So(query.Result.Login, ShouldEqual, login)
|
|
|
|
|
|
|
|
// Add a second auth module for this user
|
|
// Add a second auth module for this user
|
|
|
- // resolution of `Created` column is 1sec, so we need a delay
|
|
|
|
|
- time.Sleep(time.Second)
|
|
|
|
|
|
|
+ // Have this module's last log-in be more recent
|
|
|
|
|
+ getTime = func() time.Time { return time.Now().AddDate(0, 0, -1) }
|
|
|
query = &m.GetUserByAuthInfoQuery{Login: login, AuthModule: "test2", AuthId: "test2"}
|
|
query = &m.GetUserByAuthInfoQuery{Login: login, AuthModule: "test2", AuthId: "test2"}
|
|
|
err = GetUserByAuthInfo(query)
|
|
err = GetUserByAuthInfo(query)
|
|
|
|
|
+ getTime = time.Now
|
|
|
|
|
|
|
|
So(err, ShouldBeNil)
|
|
So(err, ShouldBeNil)
|
|
|
So(query.Result.Login, ShouldEqual, login)
|
|
So(query.Result.Login, ShouldEqual, login)
|
|
@@ -201,8 +205,6 @@ func TestUserAuth(t *testing.T) {
|
|
|
So(getAuthQuery.Result.AuthModule, ShouldEqual, "test2")
|
|
So(getAuthQuery.Result.AuthModule, ShouldEqual, "test2")
|
|
|
|
|
|
|
|
// "log in" again with the first auth module
|
|
// "log in" again with the first auth module
|
|
|
- // resolution of `Created` column is 1sec, so we need a delay
|
|
|
|
|
- time.Sleep(time.Second)
|
|
|
|
|
updateAuthCmd := &m.UpdateAuthInfoCommand{UserId: query.Result.Id, AuthModule: "test1", AuthId: "test1"}
|
|
updateAuthCmd := &m.UpdateAuthInfoCommand{UserId: query.Result.Id, AuthModule: "test1", AuthId: "test1"}
|
|
|
err = UpdateAuthInfo(updateAuthCmd)
|
|
err = UpdateAuthInfo(updateAuthCmd)
|
|
|
|
|
|