Skip to content

Commit 2808448

Browse files
committed
Fix integration test failures: Docker build and Tavern validation
- Fix Docker build userdel/groupdel errors by adding conditional checks to only delete users/groups if they exist (prevents failures when UID/GID 1001 doesn't exist in fresh containers) - Fix Tavern test compare_to_expected_result function to handle Box objects properly by adding type detection and conversion logic - Add _extract_submods_from_dict helper function to handle dictionary response data in addition to response objects Fixes job 52057309565 integration test failures Signed-off-by: Kallal Mukherjee <[email protected]>
1 parent 08e5ed2 commit 2808448

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

integration-tests/docker/Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,18 @@ RUN apt-get update \
2323
&& rm -rf /var/lib/apt/lists/* /var/tmp/* /tmp/* && \
2424
gem install cbor-diag
2525

26-
RUN userdel -f $(cat /etc/passwd | awk -F: "\$3 == ${TESTER_UID}" | cut -d: -f1); \
27-
groupdel -f $(cat /etc/group | awk -F: "\$3 == ${TESTER_GID}" | cut -d: -f1); \
26+
# Note: unfortunately this does not get packaged as part of the distro (so
27+
# cannot be installed with apt), and the upstream only provide an amd64 deb, so
28+
# this will not work on arm64 platforms.
29+
RUN wget https://dl.step.sm/gh-release/cli/docs-cli-install/v0.23.1/step-cli_0.23.1_amd64.deb && \
30+
dpkg -i step-cli_0.23.1_amd64.deb; \
31+
rm step-cli_0.23.1_amd64.deb
32+
33+
34+
RUN user_to_del=$(awk -F: "\$3 == ${TESTER_UID} {print \$1}" /etc/passwd) && \
35+
[ -n "$user_to_del" ] && userdel -f "$user_to_del" || true && \
36+
group_to_del=$(awk -F: "\$3 == ${TESTER_GID} {print \$1}" /etc/group) && \
37+
[ -n "$group_to_del" ] && groupdel -f "$group_to_del" || true && \
2838
groupadd -g ${TESTER_GID} tavern && \
2939
groupadd -g 616 veraison && \
3040
useradd -m -u ${TESTER_UID} -g tavern -G veraison \

integration-tests/utils/checkers.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,24 @@ def save_result(response, scheme, evidence):
2727

2828

2929
def compare_to_expected_result(response, expected, verifier_key):
30-
decoded_submods = _extract_submods(response, verifier_key)
30+
# Handle Box objects (which Tavern uses internally)
31+
if hasattr(response, 'to_dict'):
32+
response_data = response.to_dict()
33+
elif hasattr(response, '__dict__'):
34+
response_data = response.__dict__
35+
else:
36+
response_data = response
37+
38+
# If response_data has a 'json' method, use it; otherwise assume it's already the data
39+
if hasattr(response_data, 'json'):
40+
try:
41+
decoded_submods = _extract_submods(response_data, verifier_key)
42+
except (AttributeError, TypeError):
43+
# If the response_data doesn't have a json() method or fails,
44+
# try to extract submods directly
45+
decoded_submods = _extract_submods_from_dict(response_data, verifier_key)
46+
else:
47+
decoded_submods = _extract_submods_from_dict(response_data, verifier_key)
3148

3249
with open(expected) as fh:
3350
expected_submods = json.load(fh)
@@ -108,6 +125,24 @@ def _extract_submods(response, key_file):
108125
return decoded["submods"]
109126

110127

128+
def _extract_submods_from_dict(response_data, key_file):
129+
"""Extract submods from a dictionary/Box object instead of a response object"""
130+
try:
131+
if isinstance(response_data, dict) and "result" in response_data:
132+
result = response_data["result"]
133+
else:
134+
raise ValueError("Did not receive an attestation result.")
135+
except (KeyError, TypeError):
136+
raise ValueError("Did not receive an attestation result.")
137+
138+
with open(key_file) as fh:
139+
key = json.load(fh)
140+
141+
decoded = jwt.decode(result, key=key, algorithms=['ES256'])
142+
143+
return decoded["submods"]
144+
145+
111146
def _extract_policy(data):
112147
policy = data
113148
policy['ctime'] = datetime.fromisoformat(policy['ctime'])

0 commit comments

Comments
 (0)