Skip to content

Commit c8d02c1

Browse files
committed
feat(health): implement unit test cases with actual resource kinds of microgateway.airlock.com API group
1 parent 551f2ca commit c8d02c1

8 files changed

Lines changed: 33 additions & 31 deletions

File tree

resource_customizations/microgateway.airlock.com/_/health.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local function is_policy_kind(kind)
55
end
66

77
if not is_policy_kind(obj.kind) then
8-
return nil
8+
return { status = "Healthy", message = obj.kind .. " is healthy" }
99
end
1010

1111
if obj.status ~= nil and obj.status.ancestors ~= nil then
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
tests:
22
- healthStatus:
33
status: Healthy
4-
message: "XPolicy is healthy"
5-
inputPath: testdata/xpolicy_healthy.yaml
4+
message: "AccessControlPolicy is healthy"
5+
inputPath: testdata/healthy.yaml
66
- healthStatus:
77
status: Degraded
8-
message: "Ancestor example-gateway: XPolicy is conflicting with other policies for this ancestor: [example-xpolicy]"
9-
inputPath: testdata/xpolicy_degraded_conflicting.yaml
8+
message: "Ancestor example-gateway: ContentSecurityPolicy is conflicting with other policies for this ancestor: [example-contentsecuritypolicy]"
9+
inputPath: testdata/degraded_conflicting.yaml
1010
- healthStatus:
1111
status: Degraded
1212
message: >-
13-
Ancestor example-gateway: Resolving XPolicy failed:
14-
Missing referenced XResource.Secret 'ca'
13+
Ancestor example-gateway: Resolving CustomResponsePolicy failed:
14+
Missing referenced CustomResponse 'example'
1515
WARNING: traffic to referenced target(s) will be rejected.
16-
inputPath: testdata/xpolicy_degraded_resolved_refs.yaml
16+
inputPath: testdata/degraded_resolved_refs.yaml
1717
- healthStatus:
1818
status: Progressing
19-
message: "Waiting for XPolicy status"
20-
inputPath: testdata/xpolicy_progressing.yaml
19+
message: "Waiting for EnvoyExtensionPolicy status"
20+
inputPath: testdata/progressing.yaml
2121
- healthStatus:
2222
status: Progressing
23-
message: "Waiting for Ancestor example-gateway to update XPolicy status"
24-
inputPath: testdata/xpolicy_progressing_observed_generation.yaml
25-
- healthStatus: {}
26-
inputPath: testdata/xcustomresource_unknown.yaml
23+
message: "Waiting for Ancestor example-gateway to update ICAPPolicy status"
24+
inputPath: testdata/progressing_observed_generation.yaml
25+
- healthStatus:
26+
status: Healthy
27+
message: "DenyRules is healthy"
28+
inputPath: testdata/unknown.yaml

resource_customizations/microgateway.airlock.com/_/testdata/xpolicy_degraded_conflicting.yaml renamed to resource_customizations/microgateway.airlock.com/_/testdata/degraded_conflicting.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: microgateway.airlock.com/v1alpha1
2-
kind: XPolicy
2+
kind: ContentSecurityPolicy
33
metadata:
4-
name: example-xpolicy-2
4+
name: example-contentsecuritypolicy-2
55
namespace: default
66
spec:
77
targetRefs:
@@ -17,7 +17,7 @@ status:
1717
conditions:
1818
- lastTransitionTime: '2026-04-16T14:21:38Z'
1919
message: >-
20-
XPolicy is conflicting with other policies for this ancestor: [example-xpolicy]
20+
ContentSecurityPolicy is conflicting with other policies for this ancestor: [example-contentsecuritypolicy]
2121
observedGeneration: 3
2222
reason: Conflicted
2323
status: 'False'

resource_customizations/microgateway.airlock.com/_/testdata/xpolicy_degraded_resolved_refs.yaml renamed to resource_customizations/microgateway.airlock.com/_/testdata/degraded_resolved_refs.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: microgateway.airlock.com/v1alpha1
2-
kind: XPolicy
2+
kind: CustomResponsePolicy
33
metadata:
4-
name: example-xpolicy
4+
name: example-customresponsepolicy
55
namespace: default
66
spec:
77
targetRefs:
@@ -17,8 +17,8 @@ status:
1717
conditions:
1818
- lastTransitionTime: '2026-04-16T12:20:11Z'
1919
message: >-
20-
Resolving XPolicy failed:
21-
Missing referenced XResource.Secret 'ca'
20+
Resolving CustomResponsePolicy failed:
21+
Missing referenced CustomResponse 'example'
2222
WARNING: traffic to referenced target(s) will be rejected.
2323
observedGeneration: 3
2424
reason: Invalid

resource_customizations/microgateway.airlock.com/_/testdata/xpolicy_healthy.yaml renamed to resource_customizations/microgateway.airlock.com/_/testdata/healthy.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: microgateway.airlock.com/v1alpha1
2-
kind: XPolicy
2+
kind: AccessControlPolicy
33
metadata:
4-
name: example-xpolicy
4+
name: example-accesscontrolpolicy
55
namespace: default
66
generation: 3
77
spec:
@@ -17,7 +17,7 @@ status:
1717
name: example-gateway
1818
conditions:
1919
- lastTransitionTime: '2026-04-16T12:20:11Z'
20-
message: XPolicy is accepted
20+
message: AccessControlPolicy is accepted
2121
observedGeneration: 3
2222
reason: Accepted
2323
status: 'True'

resource_customizations/microgateway.airlock.com/_/testdata/xcustomresource_unknown.yaml renamed to resource_customizations/microgateway.airlock.com/_/testdata/progressing.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: microgateway.airlock.com/v1alpha1
2-
kind: XCustomResource
2+
kind: EnvoyExtensionPolicy
33
metadata:
4-
name: example-xcustomresource
4+
name: example-envoyextensionpolicy
55
namespace: default
66
spec:
77
targetRefs:

resource_customizations/microgateway.airlock.com/_/testdata/xpolicy_progressing_observed_generation.yaml renamed to resource_customizations/microgateway.airlock.com/_/testdata/progressing_observed_generation.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: microgateway.airlock.com/v1alpha1
2-
kind: XPolicy
2+
kind: ICAPPolicy
33
metadata:
4-
name: example-xpolicy
4+
name: example-icappolicy
55
namespace: default
66
generation: 3
77
spec:
@@ -17,7 +17,7 @@ status:
1717
name: example-gateway
1818
conditions:
1919
- lastTransitionTime: '2026-04-16T12:20:11Z'
20-
message: XPolicy is accepted
20+
message: ICAPPolicy is accepted
2121
observedGeneration: 1
2222
reason: Accepted
2323
status: 'True'

resource_customizations/microgateway.airlock.com/_/testdata/xpolicy_progressing.yaml renamed to resource_customizations/microgateway.airlock.com/_/testdata/unknown.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: microgateway.airlock.com/v1alpha1
2-
kind: XPolicy
2+
kind: DenyRules
33
metadata:
4-
name: example-xpolicy
4+
name: example-denyrules
55
namespace: default
66
spec:
77
targetRefs:

0 commit comments

Comments
 (0)