1
# Copyright 2010 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
6
from identityprovider.views.consumer import getBaseURL
9
class DummyRequest(object):
10
def __init__(self, META):
14
class GetBaseURLTestCase(unittest.TestCase):
16
self.http_consumer_url = "http://localhost/"
17
self.https_consumer_url = "https://localhost/"
18
self.http_proto_req = DummyRequest({'HTTP_HOST': 'localhost',
19
'SERVER_PROTOCOL': 'HTTP/1.1'})
20
self.https_proto_req = DummyRequest({'HTTP_HOST': 'localhost',
21
'SERVER_PROTOCOL': 'HTTPS/1.1'})
22
self.https_req = DummyRequest({'HTTP_HOST': 'localhost',
23
'SERVER_PROTOCOL': 'HTTP/1.1',
26
def test_http_consumer(self):
27
url = getBaseURL(self.http_proto_req)
28
self.assertEqual(url, self.http_consumer_url)
30
def test_https_consumer(self):
31
url = getBaseURL(self.https_proto_req)
32
self.assertEqual(url, self.https_consumer_url)
34
url = getBaseURL(self.https_req)
35
self.assertEqual(url, self.https_consumer_url)