17
17
18
18
from warehouse .ip_addresses .models import BanReason
19
19
20
+ from ...common .constants import REMOTE_ADDR
20
21
from ...common .db .ip_addresses import IpAddressFactory as DBIpAddressFactory
21
22
22
23
23
24
class TestIpAddress :
24
25
def test_repr (self , db_request ):
25
26
ip_address = db_request .ip_address
26
27
assert isinstance (repr (ip_address ), str )
27
- assert repr (ip_address ) == "1.2.3.4"
28
+ assert repr (ip_address ) == REMOTE_ADDR
28
29
29
30
def test_invalid_transformed (self , db_request ):
30
31
ip_address = DBIpAddressFactory (ip_address = "wutang" )
@@ -33,21 +34,21 @@ def test_invalid_transformed(self, db_request):
33
34
@pytest .mark .parametrize (
34
35
"kwargs" ,
35
36
[
36
- {"ip_address" : "1.2.3.4" , "is_banned" : True },
37
+ {"ip_address" : REMOTE_ADDR , "is_banned" : True },
37
38
{
38
- "ip_address" : "1.2.3.4" ,
39
+ "ip_address" : REMOTE_ADDR ,
39
40
"is_banned" : True ,
40
41
"ban_reason" : BanReason .AUTHENTICATION_ATTEMPTS ,
41
42
},
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 ()},
43
44
{
44
- "ip_address" : "1.2.3.4" ,
45
+ "ip_address" : REMOTE_ADDR ,
45
46
"is_banned" : False ,
46
47
"ban_reason" : BanReason .AUTHENTICATION_ATTEMPTS ,
47
48
},
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 ()},
49
50
{
50
- "ip_address" : "1.2.3.4" ,
51
+ "ip_address" : REMOTE_ADDR ,
51
52
"is_banned" : False ,
52
53
"ban_reason" : BanReason .AUTHENTICATION_ATTEMPTS ,
53
54
"ban_date" : sql .func .now (),
0 commit comments