Skip to content

Commit 53f28a7

Browse files
fix(spp_dci_client): use _SECRET_MASK constant in tests instead of hardcoded value
The secret display tests hardcoded "********" in three places. If the mask value changes in the model, the tests would silently break. Now references cls.SECRET_MASK set from DCIDataSource._SECRET_MASK.
1 parent 44904bb commit 53f28a7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

spp_dci_client/tests/test_data_source.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class TestDataSource(TransactionCase):
1414
def setUpClass(cls):
1515
super().setUpClass()
1616
cls.DataSource = cls.env["spp.dci.data.source"]
17+
cls.SECRET_MASK = cls.DataSource._SECRET_MASK
1718

1819
def test_create_data_source(self):
1920
"""Test creating a data source with required fields"""
@@ -645,7 +646,7 @@ def test_secret_display_field_masks_value(self):
645646
}
646647
)
647648
# Display field should show mask, stored field should have real value
648-
self.assertEqual(ds.oauth2_client_secret_display, "********")
649+
self.assertEqual(ds.oauth2_client_secret_display, self.SECRET_MASK)
649650
self.assertEqual(ds.oauth2_client_secret, "secret456")
650651

651652
def test_secret_display_field_empty_when_no_secret(self):
@@ -680,7 +681,7 @@ def test_secret_display_write_updates_stored_field(self):
680681
self.assertEqual(ds.oauth2_client_secret, "brand_new_secret")
681682
# Invalidate cache to force recomputation of the display field
682683
ds.invalidate_recordset(["oauth2_client_secret_display"])
683-
self.assertEqual(ds.oauth2_client_secret_display, "********")
684+
self.assertEqual(ds.oauth2_client_secret_display, self.SECRET_MASK)
684685

685686
def test_secret_display_mask_value_does_not_overwrite(self):
686687
"""Test that writing the mask value does not overwrite the real secret"""
@@ -697,7 +698,7 @@ def test_secret_display_mask_value_does_not_overwrite(self):
697698
}
698699
)
699700
# Writing the mask value should not change the stored secret
700-
ds.write({"oauth2_client_secret_display": "********"})
701+
ds.write({"oauth2_client_secret_display": self.SECRET_MASK})
701702
self.assertEqual(ds.oauth2_client_secret, "real_secret_value")
702703

703704
def test_secret_display_clear_removes_secret(self):

0 commit comments

Comments
 (0)