Skip to content

Commit 6cfdee7

Browse files
Remaining Test Case Fix
1 parent 6880f29 commit 6cfdee7

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

tests/common/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
REMOTE_ADDR = "1.2.3.4"
1616

1717
"""
18-
Static output of `hashlib.sha256(remote_addr.encode("utf8")).hexdigest()`
18+
Static output of `hashlib.sha256(REMOTE_ADDR.encode("utf8")).hexdigest()`
1919
Created statically to prevent needing to calculate it every run.
2020
"""
2121
REMOTE_ADDR_HASHED = "6694f83c9f476da31f5df6bcc520034e7e57d421d247b9d34f49edbfc84a764c"
2222

2323
"""
24-
Output of `hashlib.sha256((remote_addr + "pepa").encode("utf8")).hexdigest()`
24+
Output of `hashlib.sha256((REMOTE_ADDR + "pepa").encode("utf8")).hexdigest()`
2525
"""
2626
REMOTE_ADDR_SALTED = "a69a49383d81404e4b1df297c7baa28e1cd6c4ee1495ed5d0ab165a63a147763"
2727

tests/unit/ip_addresses/test_models.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717

1818
from warehouse.ip_addresses.models import BanReason
1919

20+
from ...common.constants import REMOTE_ADDR
2021
from ...common.db.ip_addresses import IpAddressFactory as DBIpAddressFactory
2122

2223

2324
class TestIpAddress:
2425
def test_repr(self, db_request):
2526
ip_address = db_request.ip_address
2627
assert isinstance(repr(ip_address), str)
27-
assert repr(ip_address) == "1.2.3.4"
28+
assert repr(ip_address) == REMOTE_ADDR
2829

2930
def test_invalid_transformed(self, db_request):
3031
ip_address = DBIpAddressFactory(ip_address="wutang")
@@ -33,21 +34,21 @@ def test_invalid_transformed(self, db_request):
3334
@pytest.mark.parametrize(
3435
"kwargs",
3536
[
36-
{"ip_address": "1.2.3.4", "is_banned": True},
37+
{"ip_address": REMOTE_ADDR, "is_banned": True},
3738
{
38-
"ip_address": "1.2.3.4",
39+
"ip_address": REMOTE_ADDR,
3940
"is_banned": True,
4041
"ban_reason": BanReason.AUTHENTICATION_ATTEMPTS,
4142
},
42-
{"ip_address": "1.2.3.4", "is_banned": True, "ban_date": sql.func.now()},
43+
{"ip_address": REMOTE_ADDR, "is_banned": True, "ban_date": sql.func.now()},
4344
{
44-
"ip_address": "1.2.3.4",
45+
"ip_address": REMOTE_ADDR,
4546
"is_banned": False,
4647
"ban_reason": BanReason.AUTHENTICATION_ATTEMPTS,
4748
},
48-
{"ip_address": "1.2.3.4", "is_banned": False, "ban_date": sql.func.now()},
49+
{"ip_address": REMOTE_ADDR, "is_banned": False, "ban_date": sql.func.now()},
4950
{
50-
"ip_address": "1.2.3.4",
51+
"ip_address": REMOTE_ADDR,
5152
"is_banned": False,
5253
"ban_reason": BanReason.AUTHENTICATION_ATTEMPTS,
5354
"ban_date": sql.func.now(),

0 commit comments

Comments
 (0)