-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
2,049 additions
and
1,505 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...uthtest/integration_test_data/v1alpha1/validation/invalid-source-traffic-permissions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"id": { | ||
"type": { | ||
"group": "auth", | ||
"group_version": "v1alpha1", | ||
"kind": "TrafficPermissions" | ||
}, | ||
"tenancy": { | ||
"partition": "default", | ||
"namespace": "default", | ||
"peer_name": "local" | ||
}, | ||
"name": "tp-8" | ||
}, | ||
"data": { | ||
"@type": "hashicorp.consul.auth.v1alpha1.TrafficPermissions", | ||
"destination": { | ||
"identity_name": "wi-1" | ||
}, | ||
"action": "ACTION_ALLOW", | ||
"permissions": [ | ||
{ | ||
"sources": [ | ||
{ | ||
"identity_name": "wi-2", | ||
"identity_prefix": "wi-", | ||
"namespace": "ns1", | ||
"partition": "ap1", | ||
"peer": "cp1", | ||
"sameness_group": "sg1" | ||
} | ||
], | ||
"destination_rules": [ | ||
{ | ||
"port_names": [ | ||
"baz" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...uthtest/integration_test_data/v1alpha1/validation/no-destination-traffic-permissions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"id": { | ||
"type": { | ||
"group": "auth", | ||
"group_version": "v1alpha1", | ||
"kind": "TrafficPermissions" | ||
}, | ||
"tenancy": { | ||
"partition": "default", | ||
"namespace": "default", | ||
"peer_name": "local" | ||
}, | ||
"name": "tp-7" | ||
}, | ||
"data": { | ||
"@type": "hashicorp.consul.auth.v1alpha1.TrafficPermissions", | ||
"destination": {}, | ||
"action": "ACTION_ALLOW", | ||
"permissions": [ | ||
{ | ||
"sources": [ | ||
{ | ||
"identity_name": "wi-3" | ||
} | ||
], | ||
"destination_rules": [ | ||
{ | ||
"port_names": [ | ||
"baz" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
.../integration_test_data/v1alpha1/validation/sourceless-permission-traffic-permissions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"id": { | ||
"type": { | ||
"group": "auth", | ||
"group_version": "v1alpha1", | ||
"kind": "TrafficPermissions" | ||
}, | ||
"tenancy": { | ||
"partition": "default", | ||
"namespace": "default", | ||
"peer_name": "local" | ||
}, | ||
"name": "tp-6" | ||
}, | ||
"data": { | ||
"@type": "hashicorp.consul.auth.v1alpha1.TrafficPermissions", | ||
"destination": { | ||
"identity_name": "wi-1" | ||
}, | ||
"action": "ACTION_ALLOW", | ||
"permissions": [ | ||
{ | ||
"sources": [], | ||
"destination_rules": [ | ||
{ | ||
"port_names": [ | ||
"baz" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...t/integration_test_data/v1alpha1/validation/too-many-destination-traffic-permissions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"id": { | ||
"type": { | ||
"group": "auth", | ||
"group_version": "v1alpha1", | ||
"kind": "TrafficPermissions" | ||
}, | ||
"tenancy": { | ||
"partition": "default", | ||
"namespace": "default", | ||
"peer_name": "local" | ||
}, | ||
"name": "tp-5" | ||
}, | ||
"data": { | ||
"@type": "hashicorp.consul.auth.v1alpha1.TrafficPermissions", | ||
"destination": { | ||
"identity_name": "wi-1", | ||
"identity_prefix": "wi" | ||
}, | ||
"action": "ACTION_ALLOW", | ||
"permissions": [ | ||
{ | ||
"sources": [ | ||
{ | ||
"identity_name": "wi-3" | ||
} | ||
], | ||
"destination_rules": [ | ||
{ | ||
"port_names": [ | ||
"baz" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...on_test_data/v1alpha1/validation/too-many-paths-destination-rule-traffic-permissions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"id": { | ||
"type": { | ||
"group": "auth", | ||
"group_version": "v1alpha1", | ||
"kind": "TrafficPermissions" | ||
}, | ||
"tenancy": { | ||
"partition": "default", | ||
"namespace": "default", | ||
"peer_name": "local" | ||
}, | ||
"name": "tp-4" | ||
}, | ||
"data": { | ||
"@type": "hashicorp.consul.auth.v1alpha1.TrafficPermissions", | ||
"destination": { | ||
"identity_name": "wi-1" | ||
}, | ||
"action": "ACTION_ALLOW", | ||
"permissions": [ | ||
{ | ||
"sources": [ | ||
{ | ||
"identity_name": "wi-3" | ||
} | ||
], | ||
"destination_rules": [ | ||
{ | ||
"path_exact": "somepath", | ||
"path_prefix": "some", | ||
"port_names": [ | ||
"baz" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...est/integration_test_data/v1alpha1/validation/unsupported-action-traffic-permissions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"id": { | ||
"type": { | ||
"group": "auth", | ||
"group_version": "v1alpha1", | ||
"kind": "TrafficPermissions" | ||
}, | ||
"tenancy": { | ||
"partition": "default", | ||
"namespace": "default", | ||
"peer_name": "local" | ||
}, | ||
"name": "tp-3" | ||
}, | ||
"data": { | ||
"@type": "hashicorp.consul.auth.v1alpha1.TrafficPermissions", | ||
"destination": { | ||
"identity_name": "wi-1" | ||
}, | ||
"action": 0, | ||
"permissions": [ | ||
{ | ||
"sources": [ | ||
{ | ||
"identity_name": "wi-3" | ||
} | ||
], | ||
"destination_rules": [ | ||
{ | ||
"port_names": [ | ||
"baz" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
.../auth/authtest/integration_test_data/v1alpha1/validation/valid-traffic-permissions-1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"id": { | ||
"type": { | ||
"group": "auth", | ||
"group_version": "v1alpha1", | ||
"kind": "TrafficPermissions" | ||
}, | ||
"tenancy": { | ||
"partition": "default", | ||
"namespace": "default", | ||
"peer_name": "local" | ||
}, | ||
"name": "tp-1" | ||
}, | ||
"data": { | ||
"@type": "hashicorp.consul.auth.v1alpha1.TrafficPermissions", | ||
"destination": { | ||
"identity_name": "wi-1" | ||
}, | ||
"action": "ACTION_ALLOW", | ||
"permissions": [ | ||
{ | ||
"sources": [ | ||
{ | ||
"identity_name": "wi-2" | ||
} | ||
], | ||
"destination_rules": [ | ||
{ | ||
"port_names": [ | ||
"foo" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
.../auth/authtest/integration_test_data/v1alpha1/validation/valid-traffic-permissions-2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"id": { | ||
"type": { | ||
"group": "auth", | ||
"group_version": "v1alpha1", | ||
"kind": "TrafficPermissions" | ||
}, | ||
"tenancy": { | ||
"partition": "default", | ||
"namespace": "default", | ||
"peer_name": "local" | ||
}, | ||
"name": "tp-2" | ||
}, | ||
"data": { | ||
"@type": "hashicorp.consul.auth.v1alpha1.TrafficPermissions", | ||
"destination": { | ||
"identity_prefix": "wi-" | ||
}, | ||
"action": "ACTION_DENY", | ||
"permissions": [ | ||
{ | ||
"sources": [ | ||
{ | ||
"identity_prefix": "wi-", | ||
"namespace": "ns1", | ||
"partition": "ap1" | ||
} | ||
], | ||
"destination_rules": [ | ||
{ | ||
"path_exact": "somepath", | ||
"port_names": [ | ||
"foo" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
package authtest | ||
|
||
import ( | ||
"testing" | ||
|
||
svctest "github.com/hashicorp/consul/agent/grpc-external/services/resource/testing" | ||
"github.com/hashicorp/consul/internal/auth" | ||
"github.com/hashicorp/consul/internal/controller" | ||
"github.com/hashicorp/consul/internal/resource/reaper" | ||
"github.com/hashicorp/consul/proto-public/pbresource" | ||
"github.com/hashicorp/consul/sdk/testutil" | ||
) | ||
|
||
func runInMemResourceService(t *testing.T) pbresource.ResourceServiceClient { | ||
t.Helper() | ||
|
||
ctx := testutil.TestContext(t) | ||
|
||
// Create the in-mem resource service | ||
client := svctest.RunResourceService(t, auth.RegisterTypes) | ||
|
||
// Setup/Run the controller manager | ||
mgr := controller.NewManager(client, testutil.Logger(t)) | ||
|
||
// We also depend on the reaper to take care of cleaning up owned health statuses and | ||
// service endpoints so we must enable that controller as well | ||
reaper.RegisterControllers(mgr) | ||
mgr.SetRaftLeader(true) | ||
go mgr.Run(ctx) | ||
|
||
return client | ||
} | ||
|
||
func TestResource_Validation(t *testing.T) { | ||
client := runInMemResourceService(t) | ||
RunAuthV1Alpha1IntegrationTest(t, client) | ||
} |
Oops, something went wrong.