10
10
11
11
12
12
@pytest .mark .parametrize (
13
- "policy_cr, issuer_or_secret" ,
13
+ "policy_cr, policy_affected, issuer_or_secret" ,
14
14
[
15
- pytest .param (DNSPolicy , "dns_provider_secret" , id = "DNSPolicy" , marks = [pytest .mark .dnspolicy ]),
16
- pytest .param (TLSPolicy , "cluster_issuer" , id = "TLSPolicy" , marks = [pytest .mark .tlspolicy ]),
15
+ pytest .param (DNSPolicy , "dns_policy" , " dns_provider_secret" , id = "DNSPolicy" , marks = [pytest .mark .dnspolicy ]),
16
+ pytest .param (TLSPolicy , "tls_policy" , " cluster_issuer" , id = "TLSPolicy" , marks = [pytest .mark .tlspolicy ]),
17
17
],
18
18
)
19
- def test_two_policies_one_gw (request , policy_cr , issuer_or_secret , gateway , client , blame , module_label , auth ):
19
+ def test_two_policies_one_gw (
20
+ request , policy_cr , policy_affected , issuer_or_secret , gateway , client , blame , module_label , auth
21
+ ):
20
22
"""Tests that policy is rejected when the Gateway already has a DNSPolicy"""
21
23
22
24
# test that it works before the policy
@@ -25,20 +27,26 @@ def test_two_policies_one_gw(request, policy_cr, issuer_or_secret, gateway, clie
25
27
26
28
# depending on if DNSPolicy or TLSPolicy is tested the right object for the 4th parameter is passed
27
29
issuer_or_secret_obj = request .getfixturevalue (issuer_or_secret )
28
- policy = policy_cr .create_instance (
30
+ policy_new = policy_cr .create_instance (
29
31
gateway .cluster ,
30
32
blame ("dns2" ),
31
33
gateway ,
32
34
issuer_or_secret_obj ,
33
35
labels = {"app" : module_label },
34
36
)
35
- request .addfinalizer (policy .delete )
36
- policy .commit ()
37
-
38
- # Wait for expected status
39
- assert policy .wait_until (
40
- has_condition ("Accepted" , "False" , "Conflicted" , "is already referenced by policy" ), timelimit = 20
41
- ), f"Policy did not reach expected status, instead it was: { policy .refresh ().model .status .conditions } "
37
+ request .addfinalizer (policy_new .delete )
38
+ policy_new .commit ()
39
+
40
+ policy = request .getfixturevalue (policy_affected )
41
+ assert policy_new .wait_until (
42
+ has_condition (
43
+ "Accepted" ,
44
+ "False" ,
45
+ "Conflicted" ,
46
+ f"{ policy_new .model .kind } is conflicted by { policy .namespace ()} /{ policy .name ()} : conflicting policy" ,
47
+ ),
48
+ timelimit = 20 ,
49
+ ), f"Policy did not reach expected status, instead it was: { policy_new .refresh ().model .status .conditions } "
42
50
43
51
# Test that the original policy still works
44
52
response = client .get ("get" , auth = auth )
0 commit comments