|
19 | 19 | package integrationv1
|
20 | 20 |
|
21 | 21 | import (
|
| 22 | + "cmp" |
22 | 23 | "context"
|
23 | 24 | "testing"
|
24 | 25 |
|
@@ -68,13 +69,14 @@ func TestIntegrationCRUD(t *testing.T) {
|
68 | 69 | }
|
69 | 70 |
|
70 | 71 | tt := []struct {
|
71 |
| - Name string |
72 |
| - Role types.RoleSpecV6 |
73 |
| - Setup func(t *testing.T, igName string) |
74 |
| - Test func(ctx context.Context, resourceSvc *Service, igName string) error |
75 |
| - Validate func(t *testing.T, igName string) |
76 |
| - Cleanup func(t *testing.T, igName string) |
77 |
| - ErrAssertion func(error) bool |
| 72 | + Name string |
| 73 | + Role types.RoleSpecV6 |
| 74 | + IntegrationName string |
| 75 | + Setup func(t *testing.T, igName string) |
| 76 | + Test func(ctx context.Context, resourceSvc *Service, igName string) error |
| 77 | + Validate func(t *testing.T, igName string) |
| 78 | + Cleanup func(t *testing.T, igName string) |
| 79 | + ErrAssertion func(error) bool |
78 | 80 | }{
|
79 | 81 | // Read
|
80 | 82 | {
|
@@ -186,13 +188,30 @@ func TestIntegrationCRUD(t *testing.T) {
|
186 | 188 | Verbs: []string{types.VerbCreate},
|
187 | 189 | }}},
|
188 | 190 | },
|
| 191 | + IntegrationName: "integration-allow-create-access", |
189 | 192 | Test: func(ctx context.Context, resourceSvc *Service, igName string) error {
|
190 | 193 | ig := sampleIntegrationFn(t, igName)
|
191 | 194 | _, err := resourceSvc.CreateIntegration(ctx, &integrationpb.CreateIntegrationRequest{Integration: ig.(*types.IntegrationV1)})
|
192 | 195 | return err
|
193 | 196 | },
|
194 | 197 | ErrAssertion: noError,
|
195 | 198 | },
|
| 199 | + { |
| 200 | + Name: "access to create integrations but name is invalid", |
| 201 | + Role: types.RoleSpecV6{ |
| 202 | + Allow: types.RoleConditions{Rules: []types.Rule{{ |
| 203 | + Resources: []string{types.KindIntegration}, |
| 204 | + Verbs: []string{types.VerbCreate}, |
| 205 | + }}}, |
| 206 | + }, |
| 207 | + IntegrationName: "integration-awsoidc-invalid.name", |
| 208 | + Test: func(ctx context.Context, resourceSvc *Service, igName string) error { |
| 209 | + ig := sampleIntegrationFn(t, igName) |
| 210 | + _, err := resourceSvc.CreateIntegration(ctx, &integrationpb.CreateIntegrationRequest{Integration: ig.(*types.IntegrationV1)}) |
| 211 | + return err |
| 212 | + }, |
| 213 | + ErrAssertion: trace.IsBadParameter, |
| 214 | + }, |
196 | 215 | {
|
197 | 216 | Name: "create github integrations",
|
198 | 217 | Role: types.RoleSpecV6{
|
@@ -496,7 +515,7 @@ func TestIntegrationCRUD(t *testing.T) {
|
496 | 515 | tc := tc
|
497 | 516 | t.Run(tc.Name, func(t *testing.T) {
|
498 | 517 | localCtx := authorizerForDummyUser(t, ctx, tc.Role, localClient)
|
499 |
| - igName := uuid.NewString() |
| 518 | + igName := cmp.Or(tc.IntegrationName, uuid.NewString()) |
500 | 519 | if tc.Setup != nil {
|
501 | 520 | tc.Setup(t, igName)
|
502 | 521 | }
|
|
0 commit comments