MCPcopy
hub / github.com/django/django / assertMaskedSecretCorrect

Method assertMaskedSecretCorrect

tests/csrf_tests/tests.py:48–57  ·  view source on GitHub ↗

Test that a string is a valid masked version of a secret.

(self, masked_secret, secret)

Source from the content-addressed store, hash-verified

46class CsrfFunctionTestMixin:
47 # This method depends on _unmask_cipher_token() being correct.
48 def assertMaskedSecretCorrect(self, masked_secret, secret):
49 """Test that a string is a valid masked version of a secret."""
50 self.assertEqual(len(masked_secret), CSRF_TOKEN_LENGTH)
51 self.assertEqual(len(secret), CSRF_SECRET_LENGTH)
52 self.assertTrue(
53 set(masked_secret).issubset(set(CSRF_ALLOWED_CHARS)),
54 msg=f"invalid characters in {masked_secret!r}",
55 )
56 actual = _unmask_cipher_token(masked_secret)
57 self.assertEqual(actual, secret)
58
59 def assertForbiddenReason(
60 self, response, logger_cm, reason, levelno=logging.WARNING

Calls 1

_unmask_cipher_tokenFunction · 0.90

Tested by

no test coverage detected