Merge ~adam-collard/maas:security-test-cleanup into maas:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: acfd78d5c90bb6b98be3e71922c662b0a597252c
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas:security-test-cleanup
Merge into: maas:master
Diff against target: 44 lines (+3/-16)
1 file modified
src/provisioningserver/tests/test_security.py (+3/-16)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Alberto Donato (community) Approve
Review via email: mp+407891@code.launchpad.net

Commit message

Clean up test_security

Better test isolation, avoid flakiness by manipulating less global state

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b security-test-cleanup lp:~adam-collard/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/10824/console
COMMIT: d5d482dbad2fe5202d07db3b4bcc569f33883fc9

review: Needs Fixing
Revision history for this message
Alberto Donato (ack) wrote :

+1

needs lint fix though

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b security-test-cleanup lp:~adam-collard/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/10826/console
COMMIT: 09b5b2595ce3fd1ab14a6e0e08f8eb8c7ccb1aeb

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b security-test-cleanup lp:~adam-collard/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: acfd78d5c90bb6b98be3e71922c662b0a597252c

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/provisioningserver/tests/test_security.py b/src/provisioningserver/tests/test_security.py
2index 7acdc70..b008ea5 100644
3--- a/src/provisioningserver/tests/test_security.py
4+++ b/src/provisioningserver/tests/test_security.py
5@@ -19,7 +19,6 @@ from maastesting.factory import factory
6 from maastesting.matchers import MockCalledOnceWith
7 from maastesting.testcase import MAASTestCase
8 from provisioningserver import security
9-from provisioningserver.path import get_maas_data_path
10 from provisioningserver.security import (
11 fernet_decrypt_psk,
12 fernet_encrypt_psk,
13@@ -33,11 +32,9 @@ class SharedSecretTestCase(MAASTestCase):
14 get_secret = self.patch(security, "get_shared_secret_filesystem_path")
15 # Ensure each test uses a different filename for the shared secret,
16 # so that tests cannot interfere with each other.
17- get_secret.return_value = Path(
18- get_maas_data_path("secret-%s" % factory.make_string(16))
19- )
20- # Extremely unlikely, but just in case.
21- self.delete_secret()
22+ secret_dir = Path(self.make_dir())
23+ get_secret.return_value = secret_dir / "secret"
24+ self.patch(security, "_fernet_psk", value=None)
25 self.addCleanup(
26 setattr,
27 security,
28@@ -48,16 +45,6 @@ class SharedSecretTestCase(MAASTestCase):
29 security.DEFAULT_ITERATION_COUNT = 2
30 super().setUp()
31
32- def tearDown(self):
33- self.delete_secret()
34- super().tearDown()
35-
36- def delete_secret(self):
37- security._fernet_psk = None
38- secret_file = security.get_shared_secret_filesystem_path()
39- if secret_file.exists():
40- secret_file.unlink()
41-
42 def write_secret(self):
43 secret = factory.make_bytes()
44 secret_path = security.get_shared_secret_filesystem_path()

Subscribers

People subscribed via source and target branches