Skip to content
Snippets Groups Projects
Commit 48329ad3 authored by ale's avatar ale
Browse files

More py3 fixes

parent 90107820
No related branches found
No related tags found
1 merge request!4Drop Python 2 support
......@@ -237,7 +237,7 @@ class HttpdIntegrationTestBase(unittest.TestCase):
"status": 401 }),
]
for name, check in checks:
for i in xrange(repeats):
for i in range(repeats):
print('CHECKING %s (%d of 10)' % (name, i), check)
status, body, location = _query(check["url"],
host=check.get("http_host"),
......@@ -250,7 +250,7 @@ class HttpdIntegrationTestBase(unittest.TestCase):
name, check["url"], status, check["status"]))
if "body" in check:
self.assertTrue(
check["body"] in body,
check["body"].encode('utf-8') in body,
"test: '%s'\nbody mismatch for %s (exp '%s')" % (
name, check["url"], check["body"]))
if "location" in check:
......@@ -324,7 +324,7 @@ class HttpdIntegrationTest(HttpdIntegrationTestBase):
# between requests.
n = 100
errors = 0
for i in xrange(n):
for i in range(n):
cookie = 'SSO_test=%s' % self._ticket()
status, body, location = _query("/index.html", cookie=cookie)
self.assertEquals(200, status)
......@@ -336,10 +336,10 @@ class HttpdIntegrationTest(HttpdIntegrationTestBase):
cookie=mkcookie(tkt))
self.assertEquals(200, status)
self.assertTrue(body)
self.assertTrue("REMOTE_USER=testuser" in body)
self.assertTrue("SSO_USER=testuser" in body)
self.assertTrue("SSO_SERVICE=service.example.com/" in body)
self.assertTrue(("SSO_TICKET=" + tkt) in body)
self.assertTrue(b"REMOTE_USER=testuser" in body)
self.assertTrue(b"SSO_USER=testuser" in body)
self.assertTrue(b"SSO_SERVICE=service.example.com/" in body)
self.assertTrue((b"SSO_TICKET=" + tkt.encode('utf-8')) in body)
def test_sso_login(self):
# Call the /sso_login endpoint, verify that it sets the local
......@@ -374,7 +374,7 @@ class HttpdIntegrationTestWithNonces(HttpdIntegrationTestBase):
CONFIG = 'test-httpd-2.4-nonces.conf'
def setUp(self):
with open('session.key', 'w') as fd:
with open('session.key', 'wb') as fd:
fd.write(os.urandom(32))
HttpdIntegrationTestBase.setUp(self)
......@@ -388,11 +388,11 @@ class HttpdIntegrationTestWithNonces(HttpdIntegrationTestBase):
cookie=mkcookie(tkt))
self.assertEquals(200, status)
self.assertTrue(body)
self.assertTrue("REMOTE_USER=testuser" in body)
self.assertTrue("SSO_USER=testuser" in body)
self.assertTrue("SSO_SERVICE=service.example.com/" in body)
self.assertTrue(("SSO_TICKET=" + tkt) in body)
self.assertTrue("SSO_NONCE=NONCE1" in body)
self.assertTrue(b"REMOTE_USER=testuser" in body)
self.assertTrue(b"SSO_USER=testuser" in body)
self.assertTrue(b"SSO_SERVICE=service.example.com/" in body)
self.assertTrue(b("SSO_TICKET=" + tkt.encode('utf-8')) in body)
self.assertTrue(b"SSO_NONCE=NONCE1" in body)
def test_login_workflow(self):
self._login_workflow("service.example.com", "/protected-user/index.html",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment