feat: scope API MCP OAuth by principal
This commit is contained in:
@@ -9,7 +9,8 @@ import (
|
||||
|
||||
func TestWithIMIdentity(t *testing.T) {
|
||||
const tenantID uint64 = 42
|
||||
ctx := withIMIdentity(context.Background(), tenantID)
|
||||
msg := &IncomingMessage{Platform: PlatformFeishu, UserID: "open-id-1"}
|
||||
ctx := withIMIdentity(context.Background(), tenantID, "channel-1", msg)
|
||||
|
||||
gotTenant, ok := types.TenantIDFromContext(ctx)
|
||||
if !ok || gotTenant != tenantID {
|
||||
@@ -35,4 +36,12 @@ func TestWithIMIdentity(t *testing.T) {
|
||||
if role := types.TenantRoleFromContext(ctx); role != types.TenantRoleViewer {
|
||||
t.Fatalf("TenantRole = %v, want %v", role, types.TenantRoleViewer)
|
||||
}
|
||||
|
||||
principal, ok := types.PrincipalFromContext(ctx)
|
||||
if !ok {
|
||||
t.Fatalf("Principal missing")
|
||||
}
|
||||
if principal.Type != types.PrincipalIMUser || principal.ID != "42:channel-1:feishu:open-id-1" {
|
||||
t.Fatalf("Principal = %#v, want im_user for the external IM user", principal)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user