You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ja...@apache.org on 2015/03/27 02:00:47 UTC

[1/2] trafficserver git commit: add initial remap tests

Repository: trafficserver
Updated Branches:
  refs/heads/master d8d1b0871 -> 3210351f3


add initial remap tests


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7cb8b29b
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7cb8b29b
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7cb8b29b

Branch: refs/heads/master
Commit: 7cb8b29b0509f06553b09bb280a7fe3373565fff
Parents: d8d1b08
Author: Feifei Cai <ff...@yahoo-inc.com>
Authored: Wed Mar 4 10:35:10 2015 +0000
Committer: Thomas Jackson <ja...@apache.org>
Committed: Thu Mar 26 17:59:50 2015 -0700

----------------------------------------------------------------------
 ci/new_tsqa/tests/test_remap.py | 119 +++++++++++++++++++++++++++++++++++
 1 file changed, 119 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7cb8b29b/ci/new_tsqa/tests/test_remap.py
----------------------------------------------------------------------
diff --git a/ci/new_tsqa/tests/test_remap.py b/ci/new_tsqa/tests/test_remap.py
new file mode 100644
index 0000000..c6acd59
--- /dev/null
+++ b/ci/new_tsqa/tests/test_remap.py
@@ -0,0 +1,119 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+import os
+import requests
+import time
+import logging
+
+import helpers
+
+import tsqa.test_cases
+import tsqa.utils
+import tsqa.endpoint
+
+log = logging.getLogger(__name__)
+
+unittest = tsqa.utils.import_unittest()
+
+class TestRemapHTTP(helpers.EnvironmentCase):
+    @classmethod
+    def setUpEnv(cls, env):
+        cls.configs['records.config']['CONFIG'].update({
+            'proxy.config.diags.debug.enabled': 1,
+            'proxy.config.diags.debug.tags': 'url.*',
+        })
+
+        # test with a httpbin running on localhost and port 8000
+        cls.configs['remap.config'].add_line('map http://www.example.com http://127.0.0.1:8000/\n');
+        cls.configs['remap.config'].add_line('map http://www.example.com:8080 http://127.0.0.1:8000/\n');
+
+    def test_remap_http(self):
+        s = requests.Session()
+        http_port = self.configs['records.config']['CONFIG']['proxy.config.http.server_ports']
+        url = 'http://127.0.0.1:{0}/get'.format(http_port)
+
+        ret = s.get(url)
+        self.assertEqual(ret.status_code, 404)
+
+        s.headers.update({'Host': 'www.example.com'})
+        ret = s.get(url)
+        self.assertEqual(ret.status_code, 200)
+
+        s.headers.update({'Host': 'www.example.com:80'})
+        ret = s.get(url)
+        self.assertEqual(ret.status_code, 200)
+
+        s.headers.update({'Host': 'www.example.com:8080'})
+        ret = s.get(url)
+        self.assertEqual(ret.status_code, 200)
+
+        s.headers.update({'Host': 'www.test.com'})
+        ret = s.get(url)
+        self.assertEqual(ret.status_code, 404)
+
+        s.headers.update({'Host': 'www.example.com:1234'})
+        ret = s.get(url)
+        self.assertEqual(ret.status_code, 404)
+
+class TestRemapHTTPS(helpers.EnvironmentCase):
+    @classmethod
+    def setUpEnv(cls, env):
+        # set an SSL port to ATS
+        cls.ssl_port = tsqa.utils.bind_unused_port()[1]
+        cls.configs['records.config']['CONFIG']['proxy.config.http.server_ports'] += ' {0}:ssl'.format(cls.ssl_port)
+        cls.configs['records.config']['CONFIG'].update({
+            'proxy.config.diags.debug.enabled': 1,
+            'proxy.config.diags.debug.tags': 'url.*'
+        })
+
+        # test with a httpbin running on localhost and port 8000
+        cls.configs['remap.config'].add_line('map https://www.example.com http://127.0.0.1:8000/\n');
+        cls.configs['remap.config'].add_line('map https://www.example.com:4443 http://127.0.0.1:8000/\n');
+        # configure SSL multicert
+        cls.configs['ssl_multicert.config'].add_line('dest_ip=* ssl_cert_name={0}'.format(helpers.tests_file_path('rsa_keys/www.example.com.pem')))
+
+    def test_remap_https(self):
+        s = requests.Session()
+        url = 'https://127.0.0.1:{0}/get'.format(self.ssl_port)
+
+        # We lack of SNI support in requests module, so we do not verify SSL certificate here.
+        #ret = s.get(url, verify=(helpers.tests_file_path('certs/ca.crt')))
+        ret = s.get(url, verify=False)
+        self.assertEqual(ret.status_code, 404)
+
+        s.headers.update({'Host': 'www.example.com'})
+        ret = s.get(url, verify=False)
+        self.assertEqual(ret.status_code, 200)
+
+        s.headers.update({'Host': 'www.example.com:443'})
+        ret = s.get(url)
+        self.assertEqual(ret.status_code, 200)
+
+        s.headers.update({'Host': 'www.example.com:4443'})
+        ret = s.get(url)
+        self.assertEqual(ret.status_code, 200)
+
+        s.headers.update({'Host': 'www.test.com'})
+        ret = s.get(url)
+        self.assertEqual(ret.status_code, 404)
+
+        s.headers.update({'Host': 'www.example.com:1234'})
+        ret = s.get(url)
+        self.assertEqual(ret.status_code, 404)
+ 
+if __name__ == '__main__':
+    unittest.main()


[2/2] trafficserver git commit: use the dynamic endpoint as origin server

Posted by ja...@apache.org.
use the dynamic endpoint as origin server

This closes #176


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/3210351f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/3210351f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/3210351f

Branch: refs/heads/master
Commit: 3210351f33b2585ad3d638621d6f89454a4d7023
Parents: 7cb8b29
Author: Feifei Cai <ff...@yahoo-inc.com>
Authored: Thu Mar 26 10:01:10 2015 +0000
Committer: Thomas Jackson <ja...@apache.org>
Committed: Thu Mar 26 18:00:08 2015 -0700

----------------------------------------------------------------------
 ci/new_tsqa/tests/test_remap.py | 40 +++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3210351f/ci/new_tsqa/tests/test_remap.py
----------------------------------------------------------------------
diff --git a/ci/new_tsqa/tests/test_remap.py b/ci/new_tsqa/tests/test_remap.py
index c6acd59..aac6e8e 100644
--- a/ci/new_tsqa/tests/test_remap.py
+++ b/ci/new_tsqa/tests/test_remap.py
@@ -27,9 +27,7 @@ import tsqa.endpoint
 
 log = logging.getLogger(__name__)
 
-unittest = tsqa.utils.import_unittest()
-
-class TestRemapHTTP(helpers.EnvironmentCase):
+class TestRemapHTTP(tsqa.test_cases.DynamicHTTPEndpointCase, helpers.EnvironmentCase):
     @classmethod
     def setUpEnv(cls, env):
         cls.configs['records.config']['CONFIG'].update({
@@ -37,14 +35,19 @@ class TestRemapHTTP(helpers.EnvironmentCase):
             'proxy.config.diags.debug.tags': 'url.*',
         })
 
-        # test with a httpbin running on localhost and port 8000
-        cls.configs['remap.config'].add_line('map http://www.example.com http://127.0.0.1:8000/\n');
-        cls.configs['remap.config'].add_line('map http://www.example.com:8080 http://127.0.0.1:8000/\n');
+        cls.configs['remap.config'].add_line(
+            'map http://www.example.com http://127.0.0.1:{0}'.format(cls.http_endpoint.address[1]));
+        cls.configs['remap.config'].add_line(
+            'map http://www.example.com:8080 http://127.0.0.1:{0}'.format(cls.http_endpoint.address[1]));
+
+        def hello(request):
+            return 'hello'
+        cls.http_endpoint.add_handler('/', hello)
 
     def test_remap_http(self):
         s = requests.Session()
         http_port = self.configs['records.config']['CONFIG']['proxy.config.http.server_ports']
-        url = 'http://127.0.0.1:{0}/get'.format(http_port)
+        url = 'http://127.0.0.1:{0}/'.format(http_port)
 
         ret = s.get(url)
         self.assertEqual(ret.status_code, 404)
@@ -69,7 +72,7 @@ class TestRemapHTTP(helpers.EnvironmentCase):
         ret = s.get(url)
         self.assertEqual(ret.status_code, 404)
 
-class TestRemapHTTPS(helpers.EnvironmentCase):
+class TestRemapHTTPS(tsqa.test_cases.DynamicHTTPEndpointCase, helpers.EnvironmentCase):
     @classmethod
     def setUpEnv(cls, env):
         # set an SSL port to ATS
@@ -80,18 +83,24 @@ class TestRemapHTTPS(helpers.EnvironmentCase):
             'proxy.config.diags.debug.tags': 'url.*'
         })
 
-        # test with a httpbin running on localhost and port 8000
-        cls.configs['remap.config'].add_line('map https://www.example.com http://127.0.0.1:8000/\n');
-        cls.configs['remap.config'].add_line('map https://www.example.com:4443 http://127.0.0.1:8000/\n');
+        cls.configs['remap.config'].add_line(
+                'map https://www.example.com http://127.0.0.1:{0}'.format(cls.http_endpoint.address[1]));
+        cls.configs['remap.config'].add_line(
+                'map https://www.example.com:4443 http://127.0.0.1:{0}'.format(cls.http_endpoint.address[1]));
         # configure SSL multicert
-        cls.configs['ssl_multicert.config'].add_line('dest_ip=* ssl_cert_name={0}'.format(helpers.tests_file_path('rsa_keys/www.example.com.pem')))
+        cls.configs['ssl_multicert.config'].add_line(
+                'dest_ip=* ssl_cert_name={0}'.format(helpers.tests_file_path('rsa_keys/www.example.com.pem')))
+
+        def hello(request):
+            return 'hello'
+        cls.http_endpoint.add_handler('/', hello)
 
     def test_remap_https(self):
         s = requests.Session()
-        url = 'https://127.0.0.1:{0}/get'.format(self.ssl_port)
+        url = 'https://127.0.0.1:{0}/'.format(self.ssl_port)
 
         # We lack of SNI support in requests module, so we do not verify SSL certificate here.
-        #ret = s.get(url, verify=(helpers.tests_file_path('certs/ca.crt')))
+        # ret = s.get(url, verify=(helpers.tests_file_path('certs/ca.crt')))
         ret = s.get(url, verify=False)
         self.assertEqual(ret.status_code, 404)
 
@@ -114,6 +123,3 @@ class TestRemapHTTPS(helpers.EnvironmentCase):
         s.headers.update({'Host': 'www.example.com:1234'})
         ret = s.get(url)
         self.assertEqual(ret.status_code, 404)
- 
-if __name__ == '__main__':
-    unittest.main()