Identity: Rename "namespace" to "type" in the requester interface (#90567)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/services/authn"
|
||||
"github.com/grafana/grafana/pkg/services/login"
|
||||
@@ -163,8 +164,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
||||
},
|
||||
wantErr: false,
|
||||
wantID: &authn.Identity{
|
||||
ID: authn.MustParseNamespaceID("user:1"),
|
||||
UID: authn.MustParseNamespaceID("user:1"),
|
||||
ID: identity.MustParseTypedID("user:1"),
|
||||
UID: identity.MustParseTypedID("user:1"),
|
||||
Login: "test",
|
||||
Name: "test",
|
||||
Email: "test",
|
||||
@@ -202,8 +203,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
||||
},
|
||||
wantErr: false,
|
||||
wantID: &authn.Identity{
|
||||
ID: authn.MustParseNamespaceID("user:1"),
|
||||
UID: authn.MustParseNamespaceID("user:1"),
|
||||
ID: identity.MustParseTypedID("user:1"),
|
||||
UID: identity.MustParseTypedID("user:1"),
|
||||
Login: "test",
|
||||
Name: "test",
|
||||
Email: "test",
|
||||
@@ -243,8 +244,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
||||
},
|
||||
wantErr: false,
|
||||
wantID: &authn.Identity{
|
||||
ID: authn.MustParseNamespaceID("user:1"),
|
||||
UID: authn.MustParseNamespaceID("user:1"),
|
||||
ID: identity.MustParseTypedID("user:1"),
|
||||
UID: identity.MustParseTypedID("user:1"),
|
||||
AuthID: "2032",
|
||||
AuthenticatedBy: "oauth",
|
||||
Login: "test",
|
||||
@@ -315,8 +316,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
||||
},
|
||||
wantErr: false,
|
||||
wantID: &authn.Identity{
|
||||
ID: authn.MustParseNamespaceID("user:2"),
|
||||
UID: authn.MustParseNamespaceID("user:2"),
|
||||
ID: identity.MustParseTypedID("user:2"),
|
||||
UID: identity.MustParseTypedID("user:2"),
|
||||
Login: "test_create",
|
||||
Name: "test_create",
|
||||
Email: "test_create",
|
||||
@@ -361,8 +362,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
||||
},
|
||||
wantErr: false,
|
||||
wantID: &authn.Identity{
|
||||
ID: authn.MustParseNamespaceID("user:3"),
|
||||
UID: authn.MustParseNamespaceID("user:3"),
|
||||
ID: identity.MustParseTypedID("user:3"),
|
||||
UID: identity.MustParseTypedID("user:3"),
|
||||
Login: "test_mod",
|
||||
Name: "test_mod",
|
||||
Email: "test_mod",
|
||||
@@ -406,8 +407,8 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
||||
},
|
||||
wantErr: false,
|
||||
wantID: &authn.Identity{
|
||||
ID: authn.MustParseNamespaceID("user:3"),
|
||||
UID: authn.MustParseNamespaceID("user:3"),
|
||||
ID: identity.MustParseTypedID("user:3"),
|
||||
UID: identity.MustParseTypedID("user:3"),
|
||||
Name: "test",
|
||||
Login: "test",
|
||||
Email: "test_mod@test.com",
|
||||
@@ -457,7 +458,7 @@ func TestUserSync_FetchSyncedUserHook(t *testing.T) {
|
||||
{
|
||||
desc: "should skip hook when identity is not a user",
|
||||
req: &authn.Request{},
|
||||
identity: &authn.Identity{ID: authn.MustParseNamespaceID("api-key:1"), ClientParams: authn.ClientParams{FetchSyncedUser: true}},
|
||||
identity: &authn.Identity{ID: identity.MustParseTypedID("api-key:1"), ClientParams: authn.ClientParams{FetchSyncedUser: true}},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -483,7 +484,7 @@ func TestUserSync_EnableDisabledUserHook(t *testing.T) {
|
||||
{
|
||||
desc: "should skip if correct flag is not set",
|
||||
identity: &authn.Identity{
|
||||
ID: authn.NewNamespaceID(authn.NamespaceUser, 1),
|
||||
ID: identity.NewTypedID(identity.TypeUser, 1),
|
||||
IsDisabled: true,
|
||||
ClientParams: authn.ClientParams{EnableUser: false},
|
||||
},
|
||||
@@ -492,7 +493,7 @@ func TestUserSync_EnableDisabledUserHook(t *testing.T) {
|
||||
{
|
||||
desc: "should skip if identity is not a user",
|
||||
identity: &authn.Identity{
|
||||
ID: authn.NewNamespaceID(authn.NamespaceAPIKey, 1),
|
||||
ID: identity.NewTypedID(identity.TypeAPIKey, 1),
|
||||
IsDisabled: true,
|
||||
ClientParams: authn.ClientParams{EnableUser: true},
|
||||
},
|
||||
@@ -501,7 +502,7 @@ func TestUserSync_EnableDisabledUserHook(t *testing.T) {
|
||||
{
|
||||
desc: "should enabled disabled user",
|
||||
identity: &authn.Identity{
|
||||
ID: authn.NewNamespaceID(authn.NamespaceUser, 1),
|
||||
ID: identity.NewTypedID(identity.TypeUser, 1),
|
||||
IsDisabled: true,
|
||||
ClientParams: authn.ClientParams{EnableUser: true},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user