def test_empty(self): setServerURL = self._getFUT() environ = {} setServerURL(environ) self.assertEqual(environ, {'SERVER_URL': 'http://localhost:8080'})
def test_with_http_host_no_port(self): setServerURL = self._getFUT() environ = {'SERVER_NAME': 'example.com', 'SERVER_PORT': '8081', 'SCRIPT_NAME': '/script', 'HTTP_HOST':'localhost', } setServerURL(environ) self.assertEqual(environ['SERVER_URL'], 'http://localhost')
def test_with_http_host_has_default_port(self): setServerURL = self._getFUT() environ = { 'SERVER_NAME': 'example.com', 'SERVER_PORT': '80', 'SCRIPT_NAME': '/script', 'HTTP_HOST': 'localhost:80', } setServerURL(environ) self.assertEqual(environ['SERVER_URL'], 'http://localhost')
def test_vhm_host_base_no_port(self): setServerURL = self._getFUT() environ = {'SERVER_NAME': 'example.com', 'SERVER_PORT': '8081', 'SCRIPT_NAME': '/script', 'HTTP_HOST':'localhost:8080', 'repoze.vhm.virtual_host_base':'www.example.com', } setServerURL(environ) self.assertEqual(environ['SERVER_URL'], 'http://www.example.com')
def test_with_alternate_port(self): setServerURL = self._getFUT() environ = {'wsgi.url_scheme': 'https', 'SERVER_NAME': 'example.com', 'SERVER_PORT': '4433', 'SCRIPT_NAME': '/script', } setServerURL(environ) self.assertEqual(environ['SERVER_URL'], 'https://example.com:4433')
def test_with_default_port(self): setServerURL = self._getFUT() environ = {'wsgi.url_scheme': 'http', 'SERVER_NAME': 'example.com', 'SERVER_PORT': '80', 'SCRIPT_NAME': '/script', } setServerURL(environ) self.assertEqual(environ['SERVER_URL'], 'http://example.com')
def test_with_alternate_port(self): setServerURL = self._getFUT() environ = { 'wsgi.url_scheme': 'https', 'SERVER_NAME': 'example.com', 'SERVER_PORT': '4433', 'SCRIPT_NAME': '/script', } setServerURL(environ) self.assertEqual(environ['SERVER_URL'], 'https://example.com:4433')
def test_with_default_port(self): setServerURL = self._getFUT() environ = { 'wsgi.url_scheme': 'http', 'SERVER_NAME': 'example.com', 'SERVER_PORT': '80', 'SCRIPT_NAME': '/script', } setServerURL(environ) self.assertEqual(environ['SERVER_URL'], 'http://example.com')
def test_vhm_host_base_no_port(self): setServerURL = self._getFUT() environ = { 'SERVER_NAME': 'example.com', 'SERVER_PORT': '8081', 'SCRIPT_NAME': '/script', 'HTTP_HOST': 'localhost:8080', 'repoze.vhm.virtual_host_base': 'www.example.com', } setServerURL(environ) self.assertEqual(environ['SERVER_URL'], 'http://www.example.com')
def test_https_without_url_scheme_with_default_port(self): # In case of a PEP 333 violation. setServerURL = self._getFUT() environ = {'HTTPS': 'on', 'SERVER_NAME': 'example.com', 'SERVER_PORT': '443', 'SCRIPT_NAME': '/script', } setServerURL(environ) self.assertEqual(environ['SERVER_URL'], 'https://example.com')
def test_https_without_url_scheme_with_default_port(self): # In case of a PEP 333 violation. setServerURL = self._getFUT() environ = { 'HTTPS': 'on', 'SERVER_NAME': 'example.com', 'SERVER_PORT': '443', 'SCRIPT_NAME': '/script', } setServerURL(environ) self.assertEqual(environ['SERVER_URL'], 'https://example.com')