Skip to content

Commit 15d2d8d

Browse files
committed
cleanup-tang-keys-and-ensure
1 parent a514a73 commit 15d2d8d

File tree

1 file changed

+45
-15
lines changed

1 file changed

+45
-15
lines changed

tests/tests_failed_bind.yml

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
- name: Set up test environment
77
include_tasks: tasks/setup_test.yml
88

9+
- name: Get the contents of the tang directory before adding keys
10+
find:
11+
path: /var/db/tang/
12+
patterns: "*.jwk"
13+
register: tang_dir_contents_before
14+
915
# For this test we will create many tang keys, so that the metadata
1016
# generated will be too large that it will not fit the LUKS header
1117
# after a few binding attempts.
@@ -14,20 +20,44 @@
1420
changed_when: false
1521
with_sequence: count=32
1622

17-
# Now we will attempt to perform multiple binding operations, and at some
18-
# point it will fail, due to the metadata being too large. We will also
19-
# calculate the checksum of the device before each attempt, and, in case
20-
# the binding fails, we will compare the after checksum to check whether
21-
# any changes were performed, in these failed scenarios.
22-
- name: Run the test for each device type
23-
include_tasks: tasks/bind_repeatedly_single_device.yml
24-
loop:
25-
- "{{ nbde_client_test_device }}" # LUKS2 (with modern cryptsetup).
26-
- "{{ nbde_client_test_device_luks1 }}" # LUKS1.
27-
loop_control:
28-
loop_var: nbde_client_selected_device
29-
30-
- name: Clean up test environment
31-
include_tasks: tasks/cleanup_test.yml
23+
- name: Run the test
24+
block:
25+
# Now we will attempt to perform multiple binding operations, and at some
26+
# point it will fail, due to the metadata being too large. We will also
27+
# calculate the checksum of the device before each attempt, and, in case
28+
# the binding fails, we will compare the after checksum to check whether
29+
# any changes were performed, in these failed scenarios.
30+
- name: Run the test for each device type
31+
include_tasks: tasks/bind_repeatedly_single_device.yml
32+
loop:
33+
- "{{ nbde_client_test_device }}" # LUKS2 (with modern cryptsetup).
34+
- "{{ nbde_client_test_device_luks1 }}" # LUKS1.
35+
loop_control:
36+
loop_var: nbde_client_selected_device
37+
38+
always:
39+
- name: Get the contents of the tang directory after adding keys
40+
find:
41+
path: /var/db/tang/
42+
patterns: "*.jwk"
43+
register: tang_dir_contents_after
44+
45+
- name: Remove any keys added during the test
46+
file:
47+
path: "{{ item }}"
48+
state: absent
49+
loop: "{{ tang_dir_contents_after.files | map(attribute='path') | list |
50+
difference(tang_dir_contents_before.files | map(attribute='path') | list) }}"
51+
52+
- name: Ensure directory is same as before
53+
find:
54+
path: /var/db/tang/
55+
patterns: "*.jwk"
56+
register: tang_dir_contents_final
57+
failed_when: tang_dir_contents_before.files | map(attribute='path') | list |
58+
difference(tang_dir_contents_final.files | map(attribute='path') | list) | list | length > 0
59+
60+
- name: Clean up test environment
61+
include_tasks: tasks/cleanup_test.yml
3262

3363
# vim:set ts=2 sw=2 et:

0 commit comments

Comments
 (0)