diff --git a/acceptance/tests/fixtures/bases/partitions/exportedservices-default/exportedservices-default.yaml b/acceptance/tests/fixtures/bases/exportedservices-default/exportedservices-default.yaml similarity index 100% rename from acceptance/tests/fixtures/bases/partitions/exportedservices-default/exportedservices-default.yaml rename to acceptance/tests/fixtures/bases/exportedservices-default/exportedservices-default.yaml diff --git a/acceptance/tests/fixtures/bases/partitions/exportedservices-default/kustomization.yaml b/acceptance/tests/fixtures/bases/exportedservices-default/kustomization.yaml similarity index 100% rename from acceptance/tests/fixtures/bases/partitions/exportedservices-default/kustomization.yaml rename to acceptance/tests/fixtures/bases/exportedservices-default/kustomization.yaml diff --git a/acceptance/tests/fixtures/bases/partitions/exportedservices-secondary/exportedservices-secondary.yaml b/acceptance/tests/fixtures/bases/exportedservices-secondary/exportedservices-secondary.yaml similarity index 100% rename from acceptance/tests/fixtures/bases/partitions/exportedservices-secondary/exportedservices-secondary.yaml rename to acceptance/tests/fixtures/bases/exportedservices-secondary/exportedservices-secondary.yaml diff --git a/acceptance/tests/fixtures/bases/partitions/exportedservices-secondary/kustomization.yaml b/acceptance/tests/fixtures/bases/exportedservices-secondary/kustomization.yaml similarity index 100% rename from acceptance/tests/fixtures/bases/partitions/exportedservices-secondary/kustomization.yaml rename to acceptance/tests/fixtures/bases/exportedservices-secondary/kustomization.yaml diff --git a/acceptance/tests/fixtures/bases/partitions/intentions/kustomization.yaml b/acceptance/tests/fixtures/bases/partitions/intentions/kustomization.yaml deleted file mode 100644 index aff115793a..0000000000 --- a/acceptance/tests/fixtures/bases/partitions/intentions/kustomization.yaml +++ /dev/null @@ -1,2 +0,0 @@ -resources: - - serviceintentions.yaml diff --git a/acceptance/tests/fixtures/bases/partitions/intentions/serviceintentions.yaml b/acceptance/tests/fixtures/bases/partitions/intentions/serviceintentions.yaml deleted file mode 100644 index 48a642dfa4..0000000000 --- a/acceptance/tests/fixtures/bases/partitions/intentions/serviceintentions.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: consul.hashicorp.com/v1alpha1 -kind: ServiceIntentions -metadata: - name: intentions -spec: {} diff --git a/acceptance/tests/fixtures/cases/crd-partitions/default-partition-default/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/default-partition-default/kustomization.yaml index 6055280660..499fdc5bc1 100644 --- a/acceptance/tests/fixtures/cases/crd-partitions/default-partition-default/kustomization.yaml +++ b/acceptance/tests/fixtures/cases/crd-partitions/default-partition-default/kustomization.yaml @@ -1,5 +1,5 @@ resources: - - ../../../bases/partitions/exportedservices-default + - ../../../bases/exportedservices-default patchesStrategicMerge: - patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/default-partition-ns1/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/default-partition-ns1/kustomization.yaml index 6055280660..499fdc5bc1 100644 --- a/acceptance/tests/fixtures/cases/crd-partitions/default-partition-ns1/kustomization.yaml +++ b/acceptance/tests/fixtures/cases/crd-partitions/default-partition-ns1/kustomization.yaml @@ -1,5 +1,5 @@ resources: - - ../../../bases/partitions/exportedservices-default + - ../../../bases/exportedservices-default patchesStrategicMerge: - patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/kustomization.yaml deleted file mode 100644 index b3784897f8..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resources: - - ../../../bases/partitions/intentions - -patchesStrategicMerge: -- patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/patch.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/patch.yaml deleted file mode 100644 index df1976c7b2..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-default/patch.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: consul.hashicorp.com/v1alpha1 -kind: ServiceIntentions -metadata: - name: intentions -spec: - destination: - name: static-server - namespace: default - sources: - - name: static-client - namespace: default - partition: secondary - action: allow diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/kustomization.yaml deleted file mode 100644 index b3784897f8..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resources: - - ../../../bases/partitions/intentions - -patchesStrategicMerge: -- patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/patch.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/patch.yaml deleted file mode 100644 index e87ab17ba3..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-default-namespaces/patch.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: consul.hashicorp.com/v1alpha1 -kind: ServiceIntentions -metadata: - name: intentions -spec: - destination: - name: static-server - namespace: ns1 - sources: - - name: static-client - namespace: ns2 - partition: secondary - action: allow diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/kustomization.yaml deleted file mode 100644 index b3784897f8..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resources: - - ../../../bases/partitions/intentions - -patchesStrategicMerge: -- patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/patch.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/patch.yaml deleted file mode 100644 index b37311357d..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-default/patch.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: consul.hashicorp.com/v1alpha1 -kind: ServiceIntentions -metadata: - name: intentions -spec: - destination: - name: static-server - namespace: default - sources: - - name: static-client - namespace: default - partition: default - action: allow diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/kustomization.yaml deleted file mode 100644 index b3784897f8..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resources: - - ../../../bases/partitions/intentions - -patchesStrategicMerge: -- patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/patch.yaml b/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/patch.yaml deleted file mode 100644 index b908e66970..0000000000 --- a/acceptance/tests/fixtures/cases/crd-partitions/intentions-secondary-namespaces/patch.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: consul.hashicorp.com/v1alpha1 -kind: ServiceIntentions -metadata: - name: intentions -spec: - destination: - name: static-server - namespace: ns1 - sources: - - name: static-client - namespace: ns2 - partition: default - action: allow diff --git a/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-default/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-default/kustomization.yaml index a75dcf8e40..5a9c8412aa 100644 --- a/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-default/kustomization.yaml +++ b/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-default/kustomization.yaml @@ -1,5 +1,5 @@ resources: - - ../../../bases/partitions/exportedservices-secondary + - ../../../bases/exportedservices-secondary patchesStrategicMerge: - patch.yaml diff --git a/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-ns1/kustomization.yaml b/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-ns1/kustomization.yaml index a75dcf8e40..5a9c8412aa 100644 --- a/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-ns1/kustomization.yaml +++ b/acceptance/tests/fixtures/cases/crd-partitions/secondary-partition-ns1/kustomization.yaml @@ -1,5 +1,5 @@ resources: - - ../../../bases/partitions/exportedservices-secondary + - ../../../bases/exportedservices-secondary patchesStrategicMerge: - patch.yaml diff --git a/acceptance/tests/partitions/partitions_test.go b/acceptance/tests/partitions/partitions_test.go index 1adad75aff..691a4d52e4 100644 --- a/acceptance/tests/partitions/partitions_test.go +++ b/acceptance/tests/partitions/partitions_test.go @@ -604,22 +604,33 @@ func TestPartitions(t *testing.T) { k8s.CheckStaticServerConnectionFailing(t, clientClusterStaticClientOpts, "http://localhost:1234") } - logger.Log(t, "creating intention") - if c.destinationNamespace == defaultNamespace { - k8s.KubectlApplyK(t, serverClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-default-default") - k8s.KubectlApplyK(t, clientClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-secondary-default") - helpers.Cleanup(t, cfg.NoCleanupOnFailure, func() { - k8s.KubectlDeleteK(t, serverClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-default-default") - k8s.KubectlDeleteK(t, clientClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-secondary-default") - }) - } else { - k8s.KubectlApplyK(t, serverClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-default-namespaces") - k8s.KubectlApplyK(t, clientClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-secondary-namespaces") - helpers.Cleanup(t, cfg.NoCleanupOnFailure, func() { - k8s.KubectlDeleteK(t, serverClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-default-namespaces") - k8s.KubectlDeleteK(t, clientClusterContext.KubectlOptions(t), "../fixtures/cases/crd-partitions/intentions-secondary-namespaces") - }) + intention := &api.ServiceIntentionsConfigEntry{ + Name: staticServerName, + Kind: api.ServiceIntentions, + Namespace: staticServerNamespace, + Sources: []*api.SourceIntention{ + { + Name: staticClientName, + Namespace: staticClientNamespace, + Action: api.IntentionActionAllow, + }, + }, + } + + // Set the destination namespace to be the same + // unless mirrorK8S is true. + if !c.mirrorK8S { + intention.Namespace = c.destinationNamespace + intention.Sources[0].Namespace = c.destinationNamespace } + + logger.Log(t, "creating intention") + intention.Sources[0].Partition = secondaryPartition + _, _, err := consulClient.ConfigEntries().Set(intention, &api.WriteOptions{Partition: defaultPartition}) + require.NoError(t, err) + intention.Sources[0].Partition = defaultPartition + _, _, err = consulClient.ConfigEntries().Set(intention, &api.WriteOptions{Partition: secondaryPartition}) + require.NoError(t, err) } logger.Log(t, "checking that connection is successful")