-
Notifications
You must be signed in to change notification settings - Fork 21
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
1 parent
0436294
commit 8b13390
Showing
9 changed files
with
187 additions
and
1 deletion.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
e2e/linodefirewall-controller/linodefirewall-addressset/assert-addressset.yaml
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,9 @@ | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 | ||
kind: AddressSet | ||
metadata: | ||
name: ($firewall)-addrset | ||
spec: | ||
ipv4: | ||
- "10.0.0.0/8" | ||
ipv6: | ||
- ::/0 |
15 changes: 15 additions & 0 deletions
15
e2e/linodefirewall-controller/linodefirewall-addressset/assert-capi-resources.yaml
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,15 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: capi-controller-manager | ||
namespace: capi-system | ||
status: | ||
availableReplicas: 1 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: capl-controller-manager | ||
namespace: capl-system | ||
status: | ||
availableReplicas: 1 |
17 changes: 17 additions & 0 deletions
17
e2e/linodefirewall-controller/linodefirewall-addressset/assert-firewall.yaml
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,17 @@ | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 | ||
kind: LinodeFirewall | ||
metadata: | ||
name: ($firewall) | ||
spec: | ||
enabled: true | ||
inboundPolicy: DROP | ||
inboundRules: | ||
- action: ACCEPT | ||
label: test | ||
ports: "1-65535" | ||
protocol: "TCP" | ||
addressSetRefs: | ||
- name: ($firewall)-addrset | ||
kind: AddressSet | ||
status: | ||
ready: true |
96 changes: 96 additions & 0 deletions
96
e2e/linodefirewall-controller/linodefirewall-addressset/chainsaw-test.yaml
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,96 @@ | ||
# 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: | ||
name: minimal-linodefirewall | ||
# Label to trigger the test on every PR | ||
labels: | ||
all: | ||
quick: | ||
linodefirewall: | ||
spec: | ||
bindings: | ||
# A short identifier for the E2E test run | ||
- name: run | ||
value: (join('-', ['e2e', 'addrset-firewall', env('GIT_REF')])) | ||
- name: firewall | ||
# Format the firewall name into a valid Kubernetes object name | ||
value: (trim((truncate(($run), `63`)), '-')) | ||
template: true | ||
steps: | ||
- name: Check if CAPI provider resources exist | ||
try: | ||
- assert: | ||
file: assert-capi-resources.yaml | ||
- name: Create AddressSet | ||
try: | ||
- apply: | ||
file: create-addressset.yaml | ||
- assert: | ||
file: assert-addressset.yaml | ||
catch: | ||
- describe: | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 | ||
kind: AddressSet | ||
- name: Create LinodeFirewall | ||
try: | ||
- apply: | ||
file: create-firewall.yaml | ||
- assert: | ||
file: assert-firewall.yaml | ||
catch: | ||
- describe: | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 | ||
kind: LinodeFirewall | ||
- name: Check if the Firewall was created | ||
try: | ||
- script: | ||
env: | ||
- name: FILTER | ||
value: (to_string({"label":($firewall)})) | ||
content: | | ||
set -e | ||
curl -s \ | ||
-H "Authorization: Bearer $LINODE_TOKEN" \ | ||
-H "X-Filter: $FILTER" \ | ||
-H "Content-Type: application/json" \ | ||
"https://api.linode.com/v4/networking/firewalls" | ||
check: | ||
($error): ~ | ||
(json_parse($stdout)): | ||
results: 1 | ||
- name: Delete Firewall | ||
try: | ||
- delete: | ||
ref: | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 | ||
kind: LinodeFirewall | ||
name: ($firewall) | ||
- error: | ||
file: check-firewall-deletion.yaml | ||
- name: Delete AddressSet | ||
try: | ||
- delete: | ||
ref: | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 | ||
kind: AddressSet | ||
name: ($firewall)-addrset | ||
- error: | ||
file: check-addressset-deletion.yaml | ||
- name: Check if the Firewall was deleted | ||
try: | ||
- script: | ||
env: | ||
- name: FILTER | ||
value: (to_string({"label":($firewall)})) | ||
content: | | ||
set -e | ||
curl -s \ | ||
-H "Authorization: Bearer $LINODE_TOKEN" \ | ||
-H "X-Filter: $FILTER" \ | ||
-H "Content-Type: application/json" \ | ||
"https://api.linode.com/v4/networking/firewalls" | ||
check: | ||
($error): ~ | ||
(json_parse($stdout)): | ||
results: 0 |
9 changes: 9 additions & 0 deletions
9
e2e/linodefirewall-controller/linodefirewall-addressset/check-addressset-deletion.yaml
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,9 @@ | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 | ||
kind: AddressSet | ||
metadata: | ||
name: ($firewall)-addrset | ||
spec: | ||
ipv4: | ||
- "10.0.0.0/8" | ||
ipv6: | ||
- ::/0 |
16 changes: 16 additions & 0 deletions
16
e2e/linodefirewall-controller/linodefirewall-addressset/check-firewall-deletion.yaml
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,16 @@ | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 | ||
kind: LinodeFirewall | ||
metadata: | ||
name: ($firewall) | ||
spec: | ||
enabled: true | ||
inboundPolicy: DROP | ||
inboundRules: | ||
- action: ACCEPT | ||
label: test | ||
ports: "1-65535" | ||
protocol: "TCP" | ||
addressSetRefs: | ||
- name: ($firewall)-addrset | ||
kind: AddressSet | ||
|
9 changes: 9 additions & 0 deletions
9
e2e/linodefirewall-controller/linodefirewall-addressset/create-addressset.yaml
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,9 @@ | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 | ||
kind: AddressSet | ||
metadata: | ||
name: ($firewall)-addrset | ||
spec: | ||
ipv4: | ||
- "10.0.0.0/8" | ||
ipv6: | ||
- ::/0 |
15 changes: 15 additions & 0 deletions
15
e2e/linodefirewall-controller/linodefirewall-addressset/create-firewall.yaml
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,15 @@ | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2 | ||
kind: LinodeFirewall | ||
metadata: | ||
name: ($firewall) | ||
spec: | ||
enabled: true | ||
inboundPolicy: DROP | ||
inboundRules: | ||
- action: ACCEPT | ||
label: test | ||
ports: "1-65535" | ||
protocol: "TCP" | ||
addressSetRefs: | ||
- name: ($firewall)-addrset | ||
kind: AddressSet |
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