From 51da2a1d3f974b1cdc6839c5eb6b77896f0e36c0 Mon Sep 17 00:00:00 2001 From: mohamedasifs123 Date: Sun, 21 Apr 2024 03:37:21 +0000 Subject: [PATCH 1/4] refacoring tests Signed-off-by: mohamedasifs123 --- .../chainsaw-test/cert-bad.yaml | 14 +++++++ .../chainsaw-test/cert-good.yaml | 42 +++++++++++++++++++ .../chainsaw-step-01-assert-1.yaml | 6 +++ .../chainsaw-step-01-assert-2.yaml | 13 ++++++ .../chainsaw-test/chainsaw-test.yaml | 33 +++++++++++++++ 5 files changed, 108 insertions(+) create mode 100644 cert-manager/limit-duration/chainsaw-test/cert-bad.yaml create mode 100644 cert-manager/limit-duration/chainsaw-test/cert-good.yaml create mode 100755 cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-1.yaml create mode 100755 cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-2.yaml create mode 100755 cert-manager/limit-duration/chainsaw-test/chainsaw-test.yaml diff --git a/cert-manager/limit-duration/chainsaw-test/cert-bad.yaml b/cert-manager/limit-duration/chainsaw-test/cert-bad.yaml new file mode 100644 index 000000000..07b78eb8e --- /dev/null +++ b/cert-manager/limit-duration/chainsaw-test/cert-bad.yaml @@ -0,0 +1,14 @@ +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: acme-crt-long +spec: + secretName: acme-crt-secret + dnsNames: + - example.com + issuerRef: + name: acme-prod + kind: Issuer + group: cert-manager.io + duration: 3400h0m0s + renewBefore: 360h0m0s \ No newline at end of file diff --git a/cert-manager/limit-duration/chainsaw-test/cert-good.yaml b/cert-manager/limit-duration/chainsaw-test/cert-good.yaml new file mode 100644 index 000000000..8a04db966 --- /dev/null +++ b/cert-manager/limit-duration/chainsaw-test/cert-good.yaml @@ -0,0 +1,42 @@ +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: acme-crt-short +spec: + secretName: acme-crt-secret + dnsNames: + - example.com + issuerRef: + name: acme-prod + kind: Issuer + group: cert-manager.io + duration: 2160h0m0s + renewBefore: 360h0m0s +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: lets-crt-1 +spec: + secretName: acme-crt-secret + dnsNames: + - example.com + issuerRef: + name: letsencrypt-test + kind: Issuer + group: cert-manager.io + duration: 2164h0m0s +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: lets-crt-2 +spec: + secretName: acme-crt-secret + dnsNames: + - example.com + issuerRef: + name: letsencrypt-test + kind: Issuer + group: cert-manager.io + duration: 3400h0m0s \ No newline at end of file diff --git a/cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-1.yaml b/cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-1.yaml new file mode 100755 index 000000000..96c5357e0 --- /dev/null +++ b/cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-1.yaml @@ -0,0 +1,6 @@ +apiVersion: kyverno.io/v1 +kind: ClusterPolicy +metadata: + name: cert-manager-limit-duration +status: + ready: true diff --git a/cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-2.yaml b/cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-2.yaml new file mode 100755 index 000000000..974d468ae --- /dev/null +++ b/cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-2.yaml @@ -0,0 +1,13 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: certificates.cert-manager.io +spec: {} +status: + acceptedNames: + kind: Certificate + listKind: CertificateList + plural: certificates + singular: certificate + storedVersions: + - v1 diff --git a/cert-manager/limit-duration/chainsaw-test/chainsaw-test.yaml b/cert-manager/limit-duration/chainsaw-test/chainsaw-test.yaml new file mode 100755 index 000000000..3889c4ef1 --- /dev/null +++ b/cert-manager/limit-duration/chainsaw-test/chainsaw-test.yaml @@ -0,0 +1,33 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: limit-duration +spec: + steps: + - name: step-01 + try: + - apply: + file: ../limit-duration.yaml + - patch: + resource: + apiVersion: kyverno.io/v1 + kind: ClusterPolicy + metadata: + name: cert-manager-limit-duration + spec: + validationFailureAction: Enforce + - assert: + file: chainsaw-step-01-assert-1.yaml + - assert: + file: chainsaw-step-01-assert-2.yaml + - name: step-02 + try: + - apply: + file: cert-good.yaml + - apply: + expect: + - check: + ($error != null): true + file: cert-bad.yaml From b7b612d9b654cfc80890fd65bc69cba5e0aeceda Mon Sep 17 00:00:00 2001 From: mohamedasifs123 Date: Sun, 21 Apr 2024 03:41:16 +0000 Subject: [PATCH 2/4] refacoring tests Signed-off-by: mohamedasifs123 --- cert-manager/limit-duration/cert-bad.yaml | 14 ------- cert-manager/limit-duration/cert-good.yaml | 42 ------------------- .../chainsaw-step-01-assert-1.yaml | 6 --- .../chainsaw-step-01-assert-2.yaml | 13 ------ .../limit-duration/chainsaw-test.yaml | 33 --------------- 5 files changed, 108 deletions(-) delete mode 100644 cert-manager/limit-duration/cert-bad.yaml delete mode 100644 cert-manager/limit-duration/cert-good.yaml delete mode 100755 cert-manager/limit-duration/chainsaw-step-01-assert-1.yaml delete mode 100755 cert-manager/limit-duration/chainsaw-step-01-assert-2.yaml delete mode 100755 cert-manager/limit-duration/chainsaw-test.yaml diff --git a/cert-manager/limit-duration/cert-bad.yaml b/cert-manager/limit-duration/cert-bad.yaml deleted file mode 100644 index 07b78eb8e..000000000 --- a/cert-manager/limit-duration/cert-bad.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: cert-manager.io/v1 -kind: Certificate -metadata: - name: acme-crt-long -spec: - secretName: acme-crt-secret - dnsNames: - - example.com - issuerRef: - name: acme-prod - kind: Issuer - group: cert-manager.io - duration: 3400h0m0s - renewBefore: 360h0m0s \ No newline at end of file diff --git a/cert-manager/limit-duration/cert-good.yaml b/cert-manager/limit-duration/cert-good.yaml deleted file mode 100644 index 8a04db966..000000000 --- a/cert-manager/limit-duration/cert-good.yaml +++ /dev/null @@ -1,42 +0,0 @@ -apiVersion: cert-manager.io/v1 -kind: Certificate -metadata: - name: acme-crt-short -spec: - secretName: acme-crt-secret - dnsNames: - - example.com - issuerRef: - name: acme-prod - kind: Issuer - group: cert-manager.io - duration: 2160h0m0s - renewBefore: 360h0m0s ---- -apiVersion: cert-manager.io/v1 -kind: Certificate -metadata: - name: lets-crt-1 -spec: - secretName: acme-crt-secret - dnsNames: - - example.com - issuerRef: - name: letsencrypt-test - kind: Issuer - group: cert-manager.io - duration: 2164h0m0s ---- -apiVersion: cert-manager.io/v1 -kind: Certificate -metadata: - name: lets-crt-2 -spec: - secretName: acme-crt-secret - dnsNames: - - example.com - issuerRef: - name: letsencrypt-test - kind: Issuer - group: cert-manager.io - duration: 3400h0m0s \ No newline at end of file diff --git a/cert-manager/limit-duration/chainsaw-step-01-assert-1.yaml b/cert-manager/limit-duration/chainsaw-step-01-assert-1.yaml deleted file mode 100755 index 96c5357e0..000000000 --- a/cert-manager/limit-duration/chainsaw-step-01-assert-1.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kyverno.io/v1 -kind: ClusterPolicy -metadata: - name: cert-manager-limit-duration -status: - ready: true diff --git a/cert-manager/limit-duration/chainsaw-step-01-assert-2.yaml b/cert-manager/limit-duration/chainsaw-step-01-assert-2.yaml deleted file mode 100755 index 974d468ae..000000000 --- a/cert-manager/limit-duration/chainsaw-step-01-assert-2.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: certificates.cert-manager.io -spec: {} -status: - acceptedNames: - kind: Certificate - listKind: CertificateList - plural: certificates - singular: certificate - storedVersions: - - v1 diff --git a/cert-manager/limit-duration/chainsaw-test.yaml b/cert-manager/limit-duration/chainsaw-test.yaml deleted file mode 100755 index 459a69b73..000000000 --- a/cert-manager/limit-duration/chainsaw-test.yaml +++ /dev/null @@ -1,33 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json -apiVersion: chainsaw.kyverno.io/v1alpha1 -kind: Test -metadata: - creationTimestamp: null - name: limit-duration -spec: - steps: - - name: step-01 - try: - - apply: - file: limit-duration.yaml - - patch: - resource: - apiVersion: kyverno.io/v1 - kind: ClusterPolicy - metadata: - name: cert-manager-limit-duration - spec: - validationFailureAction: Enforce - - assert: - file: chainsaw-step-01-assert-1.yaml - - assert: - file: chainsaw-step-01-assert-2.yaml - - name: step-02 - try: - - apply: - file: cert-good.yaml - - apply: - expect: - - check: - ($error != null): true - file: cert-bad.yaml From 21dadedfc24f9651cca051904f531842b28eb3e9 Mon Sep 17 00:00:00 2001 From: mohamedasifs123 Date: Sun, 21 Apr 2024 04:02:46 +0000 Subject: [PATCH 3/4] refacoring tests Signed-off-by: mohamedasifs123 --- .../{ => .chainsaw-test}/chainsaw-test/cert-bad.yaml | 0 .../{ => .chainsaw-test}/chainsaw-test/cert-good.yaml | 0 .../chainsaw-test/chainsaw-step-01-assert-1.yaml | 0 .../chainsaw-test/chainsaw-step-01-assert-2.yaml | 0 .../{ => .chainsaw-test}/chainsaw-test/chainsaw-test.yaml | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename cert-manager/limit-duration/{ => .chainsaw-test}/chainsaw-test/cert-bad.yaml (100%) rename cert-manager/limit-duration/{ => .chainsaw-test}/chainsaw-test/cert-good.yaml (100%) rename cert-manager/limit-duration/{ => .chainsaw-test}/chainsaw-test/chainsaw-step-01-assert-1.yaml (100%) rename cert-manager/limit-duration/{ => .chainsaw-test}/chainsaw-test/chainsaw-step-01-assert-2.yaml (100%) rename cert-manager/limit-duration/{ => .chainsaw-test}/chainsaw-test/chainsaw-test.yaml (100%) diff --git a/cert-manager/limit-duration/chainsaw-test/cert-bad.yaml b/cert-manager/limit-duration/.chainsaw-test/chainsaw-test/cert-bad.yaml similarity index 100% rename from cert-manager/limit-duration/chainsaw-test/cert-bad.yaml rename to cert-manager/limit-duration/.chainsaw-test/chainsaw-test/cert-bad.yaml diff --git a/cert-manager/limit-duration/chainsaw-test/cert-good.yaml b/cert-manager/limit-duration/.chainsaw-test/chainsaw-test/cert-good.yaml similarity index 100% rename from cert-manager/limit-duration/chainsaw-test/cert-good.yaml rename to cert-manager/limit-duration/.chainsaw-test/chainsaw-test/cert-good.yaml diff --git a/cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-1.yaml b/cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-step-01-assert-1.yaml similarity index 100% rename from cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-1.yaml rename to cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-step-01-assert-1.yaml diff --git a/cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-2.yaml b/cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-step-01-assert-2.yaml similarity index 100% rename from cert-manager/limit-duration/chainsaw-test/chainsaw-step-01-assert-2.yaml rename to cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-step-01-assert-2.yaml diff --git a/cert-manager/limit-duration/chainsaw-test/chainsaw-test.yaml b/cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-test.yaml similarity index 100% rename from cert-manager/limit-duration/chainsaw-test/chainsaw-test.yaml rename to cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-test.yaml From 4eb834bb0279636f336d4d62be0f4de5c3dd2cd3 Mon Sep 17 00:00:00 2001 From: mohamedasifs123 Date: Sun, 21 Apr 2024 05:51:57 +0000 Subject: [PATCH 4/4] refacoring tests Signed-off-by: mohamedasifs123 --- .../.chainsaw-test/{chainsaw-test => }/cert-bad.yaml | 0 .../.chainsaw-test/{chainsaw-test => }/cert-good.yaml | 0 .../{chainsaw-test => }/chainsaw-step-01-assert-1.yaml | 0 .../{chainsaw-test => }/chainsaw-step-01-assert-2.yaml | 0 .../.chainsaw-test/{chainsaw-test => }/chainsaw-test.yaml | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename cert-manager/limit-duration/.chainsaw-test/{chainsaw-test => }/cert-bad.yaml (100%) rename cert-manager/limit-duration/.chainsaw-test/{chainsaw-test => }/cert-good.yaml (100%) rename cert-manager/limit-duration/.chainsaw-test/{chainsaw-test => }/chainsaw-step-01-assert-1.yaml (100%) rename cert-manager/limit-duration/.chainsaw-test/{chainsaw-test => }/chainsaw-step-01-assert-2.yaml (100%) rename cert-manager/limit-duration/.chainsaw-test/{chainsaw-test => }/chainsaw-test.yaml (100%) diff --git a/cert-manager/limit-duration/.chainsaw-test/chainsaw-test/cert-bad.yaml b/cert-manager/limit-duration/.chainsaw-test/cert-bad.yaml similarity index 100% rename from cert-manager/limit-duration/.chainsaw-test/chainsaw-test/cert-bad.yaml rename to cert-manager/limit-duration/.chainsaw-test/cert-bad.yaml diff --git a/cert-manager/limit-duration/.chainsaw-test/chainsaw-test/cert-good.yaml b/cert-manager/limit-duration/.chainsaw-test/cert-good.yaml similarity index 100% rename from cert-manager/limit-duration/.chainsaw-test/chainsaw-test/cert-good.yaml rename to cert-manager/limit-duration/.chainsaw-test/cert-good.yaml diff --git a/cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-step-01-assert-1.yaml b/cert-manager/limit-duration/.chainsaw-test/chainsaw-step-01-assert-1.yaml similarity index 100% rename from cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-step-01-assert-1.yaml rename to cert-manager/limit-duration/.chainsaw-test/chainsaw-step-01-assert-1.yaml diff --git a/cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-step-01-assert-2.yaml b/cert-manager/limit-duration/.chainsaw-test/chainsaw-step-01-assert-2.yaml similarity index 100% rename from cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-step-01-assert-2.yaml rename to cert-manager/limit-duration/.chainsaw-test/chainsaw-step-01-assert-2.yaml diff --git a/cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-test.yaml b/cert-manager/limit-duration/.chainsaw-test/chainsaw-test.yaml similarity index 100% rename from cert-manager/limit-duration/.chainsaw-test/chainsaw-test/chainsaw-test.yaml rename to cert-manager/limit-duration/.chainsaw-test/chainsaw-test.yaml