def test_get_nginx_configuration_spec_3(self): port_spec = {'nginx': [{'proxied_port':'8000', 'boot2docker_ip': '127.0.0.0', 'host_address': 'local.gcapi.com', 'host_port': '8001'}, {'proxied_port':'80', 'host_address': 'local.gc.com', 'boot2docker_ip': '127.0.0.0', 'host_port': '80'}]} expected_output = cleanse("""http { server { client_max_body_size 500M; listen 8001; server_name local.gcapi.com; location / { proxy_pass http://127.0.0.0:8000; } } server { client_max_body_size 500M; listen 80; server_name local.gc.com; location / { proxy_pass http://127.0.0.0:80; } } } """) output = cleanse(get_nginx_configuration_spec(port_spec)) self.assertEqual(output, expected_output)
def test_get_nginx_configuration_spec_stream(self): expected_output = cleanse(""" server { listen 222; proxy_pass 172.17.42.1:8000; } """) output = cleanse(get_nginx_configuration_spec(self.port_spec_dict_3, '172.17.42.1')['stream']) self.assertEqual(output, expected_output)
def test_get_nginx_configuration_spec_3(self): port_spec = {'nginx': [{'proxied_port':'8000', 'host_address': 'local.gcapi.com', 'host_port': '8001', 'type': 'http'}, {'proxied_port':'80', 'host_address': 'local.gc.com', 'host_port': '80', 'type': 'http'}]} expected_output = cleanse(""" server { client_max_body_size 500M; listen 8001; server_name local.gcapi.com; location / { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://172.17.42.1:8000; } error_page 502 /dusty_custom_502.html; location = /dusty_custom_502.html { root /etc/nginx/conf.d/html; internal; } } server { client_max_body_size 500M; listen 80; server_name local.gc.com; location / { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://172.17.42.1:80; } error_page 502 /dusty_custom_502.html; location = /dusty_custom_502.html { root /etc/nginx/conf.d/html; internal; } } """) output = cleanse(get_nginx_configuration_spec(port_spec, '172.17.42.1')['http']) self.assertEqual(output, expected_output)
def test_get_nginx_configuration_spec_2(self): expected_output = cleanse("""http { server { client_max_body_size 500M; listen 8001; server_name local.gcapi.com; location / { proxy_pass http://127.0.0.0:8000; } } } """) output = cleanse(get_nginx_configuration_spec(self.port_spec_dict_2)) self.assertEqual(output, expected_output)
def test_get_nginx_configuration_spec_2(self): expected_output = cleanse(""" server { client_max_body_size 500M; listen 8001; server_name local.gcapi.com; location / { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass http://172.17.42.1:8000; } } """) output = cleanse(get_nginx_configuration_spec(self.port_spec_dict_2, '172.17.42.1')['http']) self.assertEqual(output, expected_output)
def test_get_nginx_configuration_spec_2(self): expected_output = cleanse(""" server { client_max_body_size 500M; listen 8001; server_name local.gcapi.com; location / { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass http://172.17.42.1:8000; } } """) output = cleanse( get_nginx_configuration_spec(self.port_spec_dict_2, '172.17.42.1')['http']) self.assertEqual(output, expected_output)
def test_get_nginx_configuration_spec_3(self): port_spec = { "nginx": [ {"proxied_port": "8000", "host_address": "local.gcapi.com", "host_port": "8001"}, {"proxied_port": "80", "host_address": "local.gc.com", "host_port": "80"}, ] } expected_output = cleanse( """ server { client_max_body_size 500M; listen 8001; server_name local.gcapi.com; location / { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass http://172.17.42.1:8000; } } server { client_max_body_size 500M; listen 80; server_name local.gc.com; location / { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass http://172.17.42.1:80; } } """ ) output = cleanse(get_nginx_configuration_spec(port_spec)) self.assertEqual(output, expected_output)
def test_get_nginx_configuration_spec_1(self): expected_output = cleanse(""" server { client_max_body_size 500M; listen 80; server_name local.gc.com; location / { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://172.17.42.1:80; } error_page 502 /dusty_custom_502.html; location = /dusty_custom_502.html { root /etc/nginx/conf.d/html; internal; } } """) output = cleanse(get_nginx_configuration_spec(self.port_spec_dict_1, '172.17.42.1')['http']) self.assertEqual(output, expected_output)