审查检查点:补齐安全版本并更新Telegram回归
补齐控制器测试中的会话与安全版本上下文,更新Telegram用户配置协议及前端回归断言。
This commit is contained in:
1 parent
ab083ef382
commit
d0abe66700
4 files changed
+84
-44
No files matched your search
@@ -54,15 +54,21 @@ func TestEditUserPasswordResetRoleMatrix(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
superContext := &appcontext.Context{UserID: superAdmin.ID, UserAccount: superAdmin.Account, Role: access.RoleSuperAdmin, RecentAuth: true, RecoveryCodeConfigured: true, Lang: "zhCn"}
|
||||
adminContext := &appcontext.Context{UserID: admin.ID, UserAccount: admin.Account, Role: access.RoleAdmin, RecentAuth: true, RecoveryCodeConfigured: true, Lang: "zhCn"}
|
||||
userContext := &appcontext.Context{UserID: user.ID, UserAccount: user.Account, Role: access.RoleUser, RecentAuth: true, RecoveryCodeConfigured: true, Lang: "zhCn"}
|
||||
superContext := &appcontext.Context{UserID: superAdmin.ID, SessionVersion: superAdmin.SessionVersion, SecurityVersion: superAdmin.SecurityVersion, UserAccount: superAdmin.Account, Role: access.RoleSuperAdmin, RecentAuth: true, RecoveryCodeConfigured: true, Lang: "zhCn"}
|
||||
adminContext := &appcontext.Context{UserID: admin.ID, SessionVersion: admin.SessionVersion, SecurityVersion: admin.SecurityVersion, UserAccount: admin.Account, Role: access.RoleAdmin, RecentAuth: true, RecoveryCodeConfigured: true, Lang: "zhCn"}
|
||||
userContext := &appcontext.Context{UserID: user.ID, SessionVersion: user.SessionVersion, SecurityVersion: user.SecurityVersion, UserAccount: user.Account, Role: access.RoleUser, RecentAuth: true, RecoveryCodeConfigured: true, Lang: "zhCn"}
|
||||
|
||||
if result := editUserRequest(t, superContext, `{"id":`+itoa(admin.ID)+`,"password":"ResetAdm12","disabled":0}`); result != 0 {
|
||||
t.Fatalf("super administrator could not reset administrator: %d", result)
|
||||
}
|
||||
assertUserPassword(t, admin.ID, "ResetAdm12")
|
||||
|
||||
if _, err := db.Instance.ID(admin.ID).Get(&admin); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
adminContext.SessionVersion = admin.SessionVersion
|
||||
adminContext.SecurityVersion = admin.SecurityVersion
|
||||
|
||||
if result := editUserRequest(t, adminContext, `{"id":`+itoa(user.ID)+`,"password":"ResetUser123","disabled":0}`); result != 0 {
|
||||
t.Fatalf("administrator could not reset regular user: %d", result)
|
||||
}
|
||||
@@ -159,7 +165,7 @@ func TestPasswordChangeRevokesOfflineCredentialsAtomically(t *testing.T) {
|
||||
|
||||
func newControllerTestUser(t *testing.T, account, name string, role access.Role, plainPassword string) models.User {
|
||||
t.Helper()
|
||||
user := models.User{Account: account, Name: name, Role: string(role), SessionVersion: 1}
|
||||
user := models.User{Account: account, Name: name, Role: string(role), SessionVersion: 1, SecurityVersion: 1}
|
||||
user.ApplyRole(role)
|
||||
if err := auth.SetPassword(&user, plainPassword); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -37,7 +37,7 @@ func TestEditUserProtectsAdministrativeCredentialsAndRevokesUserSessions(t *test
|
||||
if err := db.Init(""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
admin := models.User{Account: "admin-user", Name: "Admin", IsAdmin: 1, SessionVersion: 1}
|
||||
admin := models.User{Account: "admin-user", Name: "Admin", IsAdmin: 1, SessionVersion: 1, SecurityVersion: 1}
|
||||
if err := auth.SetPassword(&admin, "AdminPass123"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -49,7 +49,8 @@ func TestEditUserProtectsAdministrativeCredentialsAndRevokesUserSessions(t *test
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx := &appcontext.Context{
|
||||
UserID: admin.ID, UserAccount: admin.Account, IsAdmin: true, Lang: "zhCn",
|
||||
UserID: admin.ID, SessionVersion: admin.SessionVersion, SecurityVersion: admin.SecurityVersion,
|
||||
UserAccount: admin.Account, IsAdmin: true, Lang: "zhCn",
|
||||
RecentAuth: true, RecoveryCodeConfigured: true,
|
||||
}
|
||||
|
||||
@@ -268,7 +269,8 @@ func TestManagedRecoveryCodesAreScopedAndShownOnce(t *testing.T) {
|
||||
}
|
||||
ConfigureSecurityRuntime(nil, nil, nil, credentialService)
|
||||
ctx := &appcontext.Context{
|
||||
UserID: actor.ID, UserAccount: actor.Account, Role: access.RoleSuperAdmin, RecentAuth: true,
|
||||
UserID: actor.ID, SessionVersion: actor.SessionVersion, SecurityVersion: actor.SecurityVersion,
|
||||
UserAccount: actor.Account, Role: access.RoleSuperAdmin, RecentAuth: true,
|
||||
}
|
||||
|
||||
generateRecorder := httptest.NewRecorder()
|
||||
@@ -405,10 +407,12 @@ func TestManagedExternalEmailChangeInvalidatesPreviousChallenge(t *testing.T) {
|
||||
}
|
||||
|
||||
ctx := &appcontext.Context{
|
||||
UserID: actor.ID,
|
||||
UserAccount: actor.Account,
|
||||
Role: access.RoleSuperAdmin,
|
||||
RecentAuth: true,
|
||||
UserID: actor.ID,
|
||||
SessionVersion: actor.SessionVersion,
|
||||
SecurityVersion: actor.SecurityVersion,
|
||||
UserAccount: actor.Account,
|
||||
Role: access.RoleSuperAdmin,
|
||||
RecentAuth: true,
|
||||
}
|
||||
recorder := httptest.NewRecorder()
|
||||
request := httptest.NewRequest(
|
||||
|
||||
Reference in new issue
Block a user