|
1 | 1 | from django.test import TestCase |
2 | 2 |
|
3 | | -from cohiva.utils.strings import remove_secrets_from_uri |
| 3 | +from cohiva.utils.strings import sanitize_log_message |
4 | 4 |
|
5 | 5 |
|
6 | 6 | class UtilsStringsTestCase(TestCase): |
7 | | - def test_remove_secrets_from_uri_no_uri(self): |
| 7 | + def test_sanitize_log_message_no_uri(self): |
8 | 8 | text = "Normal text without URI" |
9 | | - safe_text = remove_secrets_from_uri(text) |
| 9 | + safe_text = sanitize_log_message(text) |
10 | 10 | self.assertEqual(safe_text, text) |
11 | 11 |
|
12 | | - def test_remove_secrets_from_uri_no_password(self): |
| 12 | + def test_sanitize_log_message_uri_without_password(self): |
13 | 13 | text = "Normal text without URI but no password https://user@host/path?bla=1 more text" |
14 | | - safe_text = remove_secrets_from_uri(text) |
| 14 | + safe_text = sanitize_log_message(text) |
15 | 15 | self.assertEqual(safe_text, text) |
16 | 16 |
|
17 | | - def test_remove_secrets_from_uri_https(self): |
18 | | - safe_text = remove_secrets_from_uri("https://user:_SECRET_@host") |
| 17 | + def test_sanitize_log_message_uri_https(self): |
| 18 | + safe_text = sanitize_log_message("https://user:_SECRET_@host") |
19 | 19 | self.assertEqual(safe_text, "https://user:******@host") |
20 | 20 |
|
21 | | - def test_remove_secrets_from_uri_https_with_text(self): |
22 | | - safe_text = remove_secrets_from_uri("Text https://user:_SECRET_@host more text") |
| 21 | + def test_sanitize_log_message_uri_https_with_text(self): |
| 22 | + safe_text = sanitize_log_message("Text https://user:_SECRET_@host more text") |
23 | 23 | self.assertEqual(safe_text, "Text https://user:******@host more text") |
24 | 24 |
|
25 | | - def test_remove_secrets_from_uri_mysql(self): |
26 | | - safe_text = remove_secrets_from_uri("Text mysql://user:_SECRET_@host more text") |
| 25 | + def test_sanitize_log_message_uri_mysql(self): |
| 26 | + safe_text = sanitize_log_message("Text mysql://user:_SECRET_@host more text") |
27 | 27 | self.assertEqual(safe_text, "Text mysql://user:******@host more text") |
28 | 28 |
|
29 | | - def test_remove_secrets_from_uri_multiple(self): |
| 29 | + def test_sanitize_log_message_multiple_uris(self): |
30 | 30 | text = ( |
31 | 31 | "Text https://user:_SECRET_@host more text " |
32 | 32 | "mysql://user:_SECRET_@host/path/to/?query=1 more text" |
33 | 33 | ) |
34 | | - safe_text = remove_secrets_from_uri(text) |
| 34 | + safe_text = sanitize_log_message(text) |
35 | 35 | self.assertEqual( |
36 | 36 | safe_text, |
37 | 37 | ( |
|
0 commit comments