~ubuntuone-pqm-team/canonical-identity-provider/trunk

« back to all changes in this revision

Viewing changes to identityprovider/tests/test_views_consumer.py

  • Committer: Danny Tamez
  • Date: 2010-04-21 15:29:24 UTC
  • Revision ID: danny.tamez@canonical.com-20100421152924-lq1m92tstk2iz75a
Canonical SSO Provider (Open Source) - Initial Commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2010 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
import unittest
 
5
 
 
6
from identityprovider.views.consumer import getBaseURL
 
7
 
 
8
 
 
9
class DummyRequest(object):
 
10
    def __init__(self, META):
 
11
        self.META = META
 
12
 
 
13
 
 
14
class GetBaseURLTestCase(unittest.TestCase):
 
15
    def setUp(self):
 
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',
 
24
                                       'HTTPS': 1})
 
25
 
 
26
    def test_http_consumer(self):
 
27
        url = getBaseURL(self.http_proto_req)
 
28
        self.assertEqual(url, self.http_consumer_url)
 
29
 
 
30
    def test_https_consumer(self):
 
31
        url = getBaseURL(self.https_proto_req)
 
32
        self.assertEqual(url, self.https_consumer_url)
 
33
 
 
34
        url = getBaseURL(self.https_req)
 
35
        self.assertEqual(url, self.https_consumer_url)