diff --git a/tests/test_pagure_flask_internal.py b/tests/test_pagure_flask_internal.py
index 4959faa..709a78e 100644
--- a/tests/test_pagure_flask_internal.py
+++ b/tests/test_pagure_flask_internal.py
@@ -123,10 +123,14 @@ class PagureFlaskInternaltests(tests.Modeltests):
self.assertEqual(len(request.discussion), 1)
# Check the @localonly
- pagure.APP.config['IP_ALLOWED_INTERNAL'].remove(None)
+ before = pagure.APP.config['IP_ALLOWED_INTERNAL'][:]
+ pagure.APP.config['IP_ALLOWED_INTERNAL'] = []
+
output = self.app.put('/pv/pull-request/comment/', data=data)
self.assertEqual(output.status_code, 403)
+ pagure.APP.config['IP_ALLOWED_INTERNAL'] = before[:]
+
@patch('pagure.lib.notify.send_email')
def test_ticket_add_comment(self, send_email):
""" Test the ticket_add_comment function. """
@@ -198,9 +202,14 @@ class PagureFlaskInternaltests(tests.Modeltests):
# Check the @localonly
pagure.APP.config['IP_ALLOWED_INTERNAL'].remove(None)
+ before = pagure.APP.config['IP_ALLOWED_INTERNAL'][:]
+ pagure.APP.config['IP_ALLOWED_INTERNAL'] = []
+
output = self.app.put('/pv/ticket/comment/', data=data)
self.assertEqual(output.status_code, 403)
+ pagure.APP.config['IP_ALLOWED_INTERNAL'] = before[:]
+
@patch('pagure.lib.notify.send_email')
def test_private_ticket_add_comment(self, send_email):
""" Test the ticket_add_comment function on a private ticket. """
@@ -281,10 +290,14 @@ class PagureFlaskInternaltests(tests.Modeltests):
self.assertEqual(len(issue.comments), 1)
# Check the @localonly
- pagure.APP.config['IP_ALLOWED_INTERNAL'].remove(None)
+ before = pagure.APP.config['IP_ALLOWED_INTERNAL'][:]
+ pagure.APP.config['IP_ALLOWED_INTERNAL'] = []
+
output = self.app.put('/pv/ticket/comment/', data=data)
self.assertEqual(output.status_code, 403)
+ pagure.APP.config['IP_ALLOWED_INTERNAL'] = before[:]
+
@patch('pagure.lib.notify.send_email')
def test_mergeable_request_pull_FF(self, send_email):
""" Test the mergeable_request_pull endpoint with a fast-forward
diff --git a/tests/test_pagure_flask_ui_login.py b/tests/test_pagure_flask_ui_login.py
index 88c790f..966a35f 100644
--- a/tests/test_pagure_flask_ui_login.py
+++ b/tests/test_pagure_flask_ui_login.py
@@ -21,6 +21,7 @@ import sys
import tempfile
import os
+import flask
import pygit2
from mock import patch
@@ -232,9 +233,16 @@ class PagureFlaskLogintests(tests.Modeltests):
self.assertIn(
'', output.data)
- self.assertIn(
- 'Could not set the session in the db, please report this error '
- 'to an admin', output.data)
+
+ # I'm not sure if the change was in flask or werkzeug, but in older
+ # version flask.request.remote_addr was returning None, while it
+ # now returns 127.0.0.1 making our logic pass where it used to
+ # partly fail
+ if hasattr(flask, '__version__') and \
+ tuple(flask.__version__.split('.')) <= (0,12,0):
+ self.assertIn(
+ 'Could not set the session in the db, please report '
+ 'this error to an admin', output.data)
# Make the password invalid
item = pagure.lib.search_user(self.session, username='foouser')
@@ -284,9 +292,16 @@ class PagureFlaskLogintests(tests.Modeltests):
self.assertIn(
'', output.data)
- self.assertIn(
- 'Could not set the session in the db, please report this error '
- 'to an admin', output.data)
+
+ # I'm not sure if the change was in flask or werkzeug, but in older
+ # version flask.request.remote_addr was returning None, while it
+ # now returns 127.0.0.1 making our logic pass where it used to
+ # partly fail
+ if hasattr(flask, '__version__') and \
+ tuple(flask.__version__.split('.')) <= (0,12,0):
+ self.assertIn(
+ 'Could not set the session in the db, please report '
+ 'this error to an admin', output.data)
def test_confirm_user(self):
""" Test the confirm_user endpoint. """