This repository was archived by the owner on Oct 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -143,12 +143,15 @@ def get_user_info(self, request):
143143 Requires Flask-Login (https://pypi.python.org/pypi/Flask-Login/)
144144 to be installed and setup.
145145 """
146+ user_info = {}
147+
146148 try :
147- user_info = {
148- 'ip_address' : request .access_route [0 ],
149- }
149+ ip_address = request .access_route [0 ]
150150 except IndexError :
151- user_info = {}
151+ ip_address = request .remote_addr
152+
153+ if ip_address :
154+ user_info ['ip_address' ] = ip_address
152155
153156 if not has_flask_login :
154157 return user_info
Original file line number Diff line number Diff line change @@ -234,9 +234,7 @@ def test_user_info(self):
234234 assert 'user' in event
235235
236236 user_info = event ['user' ]
237- assert user_info == {
238- {'ip_address' : '127.0.0.1' }
239- }
237+ assert user_info == {'ip_address' : '127.0.0.1' }
240238
241239 assert self .client .login (username = 'admin' , password = 'password' )
242240
@@ -247,6 +245,7 @@ def test_user_info(self):
247245 assert 'user' in event
248246 user_info = event ['user' ]
249247 assert user_info == {
248+ 'ip_address' : '127.0.0.1' ,
250249 'username' : self .user .username ,
251250 'id' : self .user .id ,
252251 'email' : self .user .email ,
Original file line number Diff line number Diff line change @@ -313,7 +313,7 @@ def setup_login(self):
313313
314314 def test_user (self ):
315315 self .client .get ('/login/' )
316- self .client .get ('/an-error/' )
316+ self .client .get ('/an-error/' , environ_overrides = { 'REMOTE_ADDR' : '127.0.0.1' } )
317317 event = self .raven .events .pop (0 )
318318 assert event ['message' ] == 'ValueError: hello world'
319319 assert 'request' in event
You can’t perform that action at this time.
0 commit comments