This commit is contained in:
2026-08-17 11:30:14 +02:00
parent fe94c2fb9c
commit 321f11e817
5 changed files with 58 additions and 3 deletions
@@ -152,6 +152,28 @@ func TestAllowCompanyAdminOrPlatform(t *testing.T) {
}
})
t.Run("company_owner_member_role", func(t *testing.T) {
t.Parallel()
s := &Server{
testPlatformAdmin: func(context.Context, uuid.UUID) (bool, error) {
return false, nil
},
testCompanyOwner: func(_ context.Context, got uuid.UUID) (bool, error) {
if got != uid {
t.Fatalf("userID = %s, want %s", got, uid)
}
return true, nil
},
}
ctx := context.WithValue(context.Background(), ctxUserID, uid)
ctx = context.WithValue(ctx, ctxRole, "member")
req := httptest.NewRequest(http.MethodGet, "/", nil).WithContext(ctx)
rec := httptest.NewRecorder()
if !s.allowCompanyAdminOrPlatform(rec, req) {
t.Fatal("company owner with membership role=member must be allowed to invite")
}
})
t.Run("impersonated_member_denied", func(t *testing.T) {
t.Parallel()
actor := uuid.MustParse("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb")