Skip to content

Commit 845224b

Browse files
committed
create securityPolicy for collection test
1 parent 7a5f9b9 commit 845224b

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

test/e2e/tests/test_collection.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,22 @@
2424
from e2e import service_marker, CRD_GROUP, CRD_VERSION, load_resource
2525
from e2e.replacement_values import REPLACEMENT_VALUES
2626
from e2e import collection
27+
from e2e.tests.test_security_policy import simple_security_policy
2728

2829
COLLECTION_RESOURCE_PLURAL = "collections"
2930
DELETE_WAIT_AFTER_SECONDS = 10
3031
CHECK_STATUS_WAIT_SECONDS = 30
3132
MODIFY_WAIT_AFTER_SECONDS = 30
3233
INITIAL_DESCRIPTION = "Initial Description"
33-
UPDATED_DESCRIPTION = "UPDATEd Description"
34+
UPDATED_DESCRIPTION = "Updated Description"
3435

3536

36-
@pytest.fixture(scope="module")
37-
def simple_collection():
37+
@pytest.fixture
38+
def simple_collection(simple_security_policy):
39+
# EncryptionType securityPolicy is required to create Collection resource
40+
_, _ = simple_security_policy
41+
3842
collection_name = random_suffix_name("my-collection", 24)
39-
4043
replacements = REPLACEMENT_VALUES.copy()
4144
replacements['COLLECTION_NAME'] = collection_name
4245
replacements['DESCRIPTION'] = "Initial Description"
@@ -92,10 +95,14 @@ def test_crud(self, simple_collection):
9295
desired_tags = cr['spec']['tags']
9396
tags.assert_ack_system_tags(
9497
tags=latest_tags,
98+
key_member_name='key',
99+
value_member_name='value'
95100
)
96101
tags.assert_equal_without_ack_tags(
97102
expected=desired_tags,
98103
actual=latest_tags,
104+
key_member_name='key',
105+
value_member_name='value'
99106
)
100107

101108
# Update the collection
@@ -131,8 +138,12 @@ def test_crud(self, simple_collection):
131138
desired_tags = cr['spec']['tags']
132139
tags.assert_ack_system_tags(
133140
tags=latest_tags,
141+
key_member_name='key',
142+
value_member_name='value'
134143
)
135144
tags.assert_equal_without_ack_tags(
136145
expected=desired_tags,
137146
actual=latest_tags,
147+
key_member_name='key',
148+
value_member_name='value'
138149
)

test/e2e/tests/test_security_policy.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,28 @@
4141
UPDATED_NETWORK_POLICY = '[{"Rules": [{"ResourceType": "collection","Resource": ["collection/*"]},{"ResourceType": "dashboard","Resource": ["collection/logs*"]}],"AllowFromPublic": true}]'
4242

4343

44-
4544
@pytest.fixture
4645
def simple_security_policy(request):
4746
sp_name = random_suffix_name("my-security-policy", 24)
4847
marker = request.node.get_closest_marker("resource_data")
49-
assert marker is not None
50-
data = marker.args[0]
51-
# either encryption or network
52-
assert 'type' in data
53-
assert 'policy' in data
48+
# We want to default to an encryptionPolicy that applies to all collections
49+
# when no marker is provided. This will allow us to create SecurityPolicy
50+
# seamlessly when testing Collections
51+
sp_type = "encryption"
52+
sp_policy = UPDATED_ENCRYPTION_POLICY
53+
if marker is not None:
54+
data = marker.args[0]
55+
# either encryption or network
56+
assert 'type' in data
57+
sp_type = data['type']
58+
assert 'policy' in data
59+
sp_policy = data['policy']
5460

5561
replacements = REPLACEMENT_VALUES.copy()
5662
replacements['SECURITY_POLICY_NAME'] = sp_name
5763
replacements['SECURITY_POLICY_DESCRIPTION'] = INITIAL_DESCRIPTION
58-
replacements['SECURITY_POLICY_TYPE'] = data['type']
59-
replacements['SECURITY_POLICY'] = data['policy']
64+
replacements['SECURITY_POLICY_TYPE'] = sp_type
65+
replacements['SECURITY_POLICY'] = sp_policy
6066

6167
resource_data = load_resource(
6268
"security_policy",

0 commit comments

Comments
 (0)