Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ndhanushkodi committed Nov 8, 2022
1 parent 385ff8a commit 0e9cd80
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion control-plane/subcommand/server-acl-init/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ func TestMeshGatewayRules(t *testing.T) {
cases := []struct {
Name string
EnableNamespaces bool
EnablePeering bool
Expected string
}{
{
Name: "Namespaces are disabled",
Name: "Namespaces and peering are disabled",
Expected: `mesh = "write"
service "mesh-gateway" {
policy = "write"
Expand All @@ -219,6 +220,47 @@ namespace "default" {
policy = "write"
}
}
namespace_prefix "" {
node_prefix "" {
policy = "read"
}
service_prefix "" {
policy = "read"
}
}`,
},
{
Name: "Peering is enabled",
EnablePeering: true,
Expected: `mesh = "write"
peering = "read"
partition_prefix "" {
peering = "read"
}
service "mesh-gateway" {
policy = "write"
}
node_prefix "" {
policy = "read"
}
service_prefix "" {
policy = "read"
}`,
},
{
Name: "Peering and namespaces are enabled",
EnablePeering: true,
EnableNamespaces: true,
Expected: `mesh = "write"
peering = "read"
partition_prefix "" {
peering = "read"
}
namespace "default" {
service "mesh-gateway" {
policy = "write"
}
}
namespace_prefix "" {
node_prefix "" {
policy = "read"
Expand All @@ -234,6 +276,7 @@ namespace_prefix "" {
t.Run(tt.Name, func(t *testing.T) {
cmd := Command{
flagEnableNamespaces: tt.EnableNamespaces,
flagEnablePeering: tt.EnablePeering,
consulFlags: &flags.ConsulFlags{},
}

Expand Down

0 comments on commit 0e9cd80

Please sign in to comment.