[v11.0.x] User: Fix GetByID (#88894)

User: Fix GetByID (#86282)

* Auth: Remove unused lookup param

* Remove case sensitive lookup for GetByID

(cherry picked from commit 8520892923)
This commit is contained in:
Karl Persson
2024-06-07 13:55:45 +02:00
committed by GitHub
parent ca5e8271fa
commit 718994af44
10 changed files with 37 additions and 125 deletions
@@ -25,10 +25,6 @@ func ptrBool(b bool) *bool {
return &b
}
func ptrInt64(i int64) *int64 {
return &i
}
func TestUserSync_SyncUserHook(t *testing.T) {
userProtection := &authinfoimpl.OSSUserProtectionImpl{}
@@ -110,9 +106,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
Email: "test",
ClientParams: authn.ClientParams{
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: ptrString("test"),
Login: nil,
Email: ptrString("test"),
Login: nil,
},
},
},
@@ -125,9 +120,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
Email: "test",
ClientParams: authn.ClientParams{
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: ptrString("test"),
Login: nil,
Email: ptrString("test"),
Login: nil,
},
},
},
@@ -149,9 +143,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
ClientParams: authn.ClientParams{
SyncUser: true,
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: ptrString("test"),
Login: nil,
Email: ptrString("test"),
Login: nil,
},
},
},
@@ -166,9 +159,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
ClientParams: authn.ClientParams{
SyncUser: true,
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: ptrString("test"),
Login: nil,
Email: ptrString("test"),
Login: nil,
},
},
},
@@ -190,9 +182,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
ClientParams: authn.ClientParams{
SyncUser: true,
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: nil,
Login: ptrString("test"),
Email: nil,
Login: ptrString("test"),
},
},
},
@@ -206,55 +197,13 @@ func TestUserSync_SyncUserHook(t *testing.T) {
IsGrafanaAdmin: ptrBool(false),
ClientParams: authn.ClientParams{
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: nil,
Login: ptrString("test"),
Email: nil,
Login: ptrString("test"),
},
SyncUser: true,
},
},
},
{
name: "sync - user found in DB - by ID",
fields: fields{
userService: userService,
authInfoService: authFakeNil,
quotaService: &quotatest.FakeQuotaService{},
},
args: args{
ctx: context.Background(),
id: &authn.Identity{
ID: "",
Login: "test",
Name: "test",
Email: "test",
ClientParams: authn.ClientParams{
SyncUser: true,
LookUpParams: login.UserLookupParams{
UserID: ptrInt64(1),
Email: nil,
Login: nil,
},
},
},
},
wantErr: false,
wantID: &authn.Identity{
ID: "user:1",
Login: "test",
Name: "test",
Email: "test",
IsGrafanaAdmin: ptrBool(false),
ClientParams: authn.ClientParams{
SyncUser: true,
LookUpParams: login.UserLookupParams{
UserID: ptrInt64(1),
Email: nil,
Login: nil,
},
},
},
},
{
name: "sync - user found in authInfo",
fields: fields{
@@ -274,9 +223,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
ClientParams: authn.ClientParams{
SyncUser: true,
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: nil,
Login: nil,
Email: nil,
Login: nil,
},
},
},
@@ -293,9 +241,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
ClientParams: authn.ClientParams{
SyncUser: true,
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: nil,
Login: nil,
Email: nil,
Login: nil,
},
},
},
@@ -319,9 +266,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
ClientParams: authn.ClientParams{
SyncUser: true,
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: nil,
Login: nil,
Email: nil,
Login: nil,
},
},
},
@@ -350,9 +296,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
AllowSignUp: true,
EnableUser: true,
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: ptrString("test_create"),
Login: nil,
Email: ptrString("test_create"),
Login: nil,
},
},
},
@@ -371,9 +316,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
AllowSignUp: true,
EnableUser: true,
LookUpParams: login.UserLookupParams{
UserID: nil,
Email: ptrString("test_create"),
Login: nil,
Email: ptrString("test_create"),
Login: nil,
},
},
},
@@ -398,9 +342,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
SyncUser: true,
EnableUser: true,
LookUpParams: login.UserLookupParams{
UserID: ptrInt64(3),
Email: nil,
Login: nil,
Email: nil,
Login: ptrString("test"),
},
},
},
@@ -417,9 +360,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
SyncUser: true,
EnableUser: true,
LookUpParams: login.UserLookupParams{
UserID: ptrInt64(3),
Email: nil,
Login: nil,
Email: nil,
Login: ptrString("test"),
},
},
},