[CVP] Use correct proto in UI tests according to reclass

Change-Id: I6646d8752ae221e36b5f77d71dfd4e51f62b970c
Related-PROD: PROD-30969
Related-PROD: PROD-30859
(cherry picked from commit 7d4f07eb6e058eda4f7fe2af811ea3b0abb8a6fc)
diff --git a/test_set/cvp-sanity/tests/test_stacklight.py b/test_set/cvp-sanity/tests/test_stacklight.py
index 31ac01e..7340951 100644
--- a/test_set/cvp-sanity/tests/test_stacklight.py
+++ b/test_set/cvp-sanity/tests/test_stacklight.py
@@ -11,14 +11,18 @@
     salt_output = local_salt_client.pillar_get(
         tgt='kibana:server',
         param='_param:haproxy_elasticsearch_bind_host')
+    ssl = local_salt_client.pillar_get(
+        tgt='elasticsearch:server',
+        param='haproxy:proxy:listen:elasticsearch:binds:ssl:enabled')
+    proto = "https" if ssl else "http"
 
     proxies = {"http": None, "https": None}
     IP = salt_output
-    assert requests.get('http://{}:9200/'.format(IP),
-                        proxies=proxies).status_code == 200, \
+    assert requests.get('{0}://{1}:9200/'.format(proto, IP),
+                        proxies=proxies, verify=False).status_code == 200, \
         'Cannot check elasticsearch url on {}.'.format(IP)
-    resp = requests.get('http://{}:9200/_cat/health'.format(IP),
-                        proxies=proxies).content
+    resp = requests.get('{0}://{1}:9200/_cat/health'.format(proto, IP),
+                        proxies=proxies, verify=False).content
     assert resp.split()[3] == 'green', \
         'elasticsearch status is not good {}'.format(
         json.dumps(resp, indent=4))
@@ -43,8 +47,13 @@
 def test_kibana_status(local_salt_client):
     proxies = {"http": None, "https": None}
     IP = local_salt_client.pillar_get(param='_param:stacklight_log_address')
-    resp = requests.get('http://{}:5601/api/status'.format(IP),
-                        proxies=proxies).content
+    ssl = local_salt_client.pillar_get(
+        tgt='kibana:server',
+        param='haproxy:proxy:listen:kibana:binds:ssl:enabled')
+    proto = "https" if ssl else "http"
+
+    resp = requests.get('{0}://{1}:5601/api/status'.format(proto, IP),
+                        proxies=proxies, verify=False).content
     body = json.loads(resp)
     assert body['status']['overall']['state'] == "green", \
         "Kibana status is not expected: {}".format(
@@ -65,6 +74,11 @@
         param='_param:haproxy_elasticsearch_bind_host')
 
     IP = salt_output
+    ssl = local_salt_client.pillar_get(
+        tgt='elasticsearch:server',
+        param='haproxy:proxy:listen:elasticsearch:binds:ssl:enabled')
+    proto = "https" if ssl else "http"
+
     headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
     proxies = {"http": None, "https": None}
     data = ('{"size": 0, "aggs": '
@@ -72,9 +86,10 @@
             '{"terms": {"size": 500, '
             '"field": "Hostname.keyword"}}}}')
     response = requests.post(
-        'http://{0}:9200/log-{1}/_search?pretty'.format(IP, today),
+        '{0}://{1}:9200/log-{2}/_search?pretty'.format(proto, IP, today),
         proxies=proxies,
         headers=headers,
+        verify = False,
         data=data)
     assert 200 == response.status_code, 'Unexpected code {}'.format(
         response.text)
@@ -124,13 +139,15 @@
 @pytest.mark.usefixtures('check_prometheus')
 def test_prometheus_alert_count(local_salt_client, ctl_nodes_pillar):
     IP = local_salt_client.pillar_get(param='_param:cluster_public_host')
+    proto = local_salt_client.pillar_get(
+        param='_param:cluster_public_protocol')
     # keystone:server can return 3 nodes instead of 1
     # this will be fixed later
     # TODO
     nodes_info = local_salt_client.cmd(
         tgt=ctl_nodes_pillar,
-        param='curl -s http://{}:15010/alerts | grep icon-chevron-down | '
-              'grep -v "0 active"'.format(IP),
+        param='curl -k -s {0}://{1}:15010/alerts | grep icon-chevron-down | '
+              'grep -v "0 active"'.format(proto, IP),
         expr_form='pillar')
 
     result = nodes_info[nodes_info.keys()[0]].replace('</td>', '').replace(
@@ -205,4 +222,4 @@
               in salt_output.items()
               if status is False]
     assert result == [], 'Fluentd check failed: td-agent service is not ' \
-                         'running on following nodes:'.format(result)
\ No newline at end of file
+                         'running on following nodes:'.format(result)
diff --git a/test_set/cvp-sanity/tests/test_ui_addresses.py b/test_set/cvp-sanity/tests/test_ui_addresses.py
index 40ff120..22e4a7f 100644
--- a/test_set/cvp-sanity/tests/test_ui_addresses.py
+++ b/test_set/cvp-sanity/tests/test_ui_addresses.py
@@ -7,12 +7,14 @@
     IP = local_salt_client.pillar_get(
         tgt='horizon:server',
         param='_param:cluster_public_host')
+    proto = local_salt_client.pillar_get(
+        param='_param:cluster_public_protocol')
     if not IP:
         pytest.skip("Horizon is not enabled on this environment")
     result = local_salt_client.cmd_any(
         tgt=ctl_nodes_pillar,
-        param='curl --insecure https://{}/auth/login/ 2>&1 | \
-               grep Login'.format(IP),
+        param='curl -k {0}://{1}/auth/login/ 2>&1 | \
+               grep Login'.format(proto, IP),
         expr_form='pillar')
     assert len(result) != 0, \
         'Horizon login page is not reachable on {} from ctl nodes'.format(
@@ -23,9 +25,10 @@
 @pytest.mark.usefixtures('check_openstack')
 def test_public_openstack(local_salt_client, ctl_nodes_pillar):
     IP = local_salt_client.pillar_get(param='_param:cluster_public_host')
-    protocol = 'https'
+    proto = local_salt_client.pillar_get(
+        param='_param:cluster_public_protocol')
     port = '5000'
-    url = "{}://{}:{}/v3".format(protocol, IP, port)
+    url = "{}://{}:{}/v3".format(proto, IP, port)
     result = local_salt_client.cmd(
         tgt=ctl_nodes_pillar,
         param='curl -k {}/ 2>&1 | \
@@ -41,12 +44,15 @@
 @pytest.mark.usefixtures('check_kibana')
 def test_internal_ui_kibana(local_salt_client, ctl_nodes_pillar):
     IP = local_salt_client.pillar_get(param='_param:stacklight_log_address')
-    protocol = 'http'
+    ssl = local_salt_client.pillar_get(
+        tgt='kibana:server',
+        param='haproxy:proxy:listen:kibana:binds:ssl:enabled')
+    proto = "https" if ssl == "True" else "http"
     port = '5601'
-    url = "{}://{}:{}".format(protocol, IP, port)
+    url = "{}://{}:{}".format(proto, IP, port)
     result = local_salt_client.cmd(
         tgt=ctl_nodes_pillar,
-        param='curl {}/app/kibana 2>&1 | \
+        param='curl -k {}/app/kibana 2>&1 | \
                grep loading'.format(url),
         expr_form='pillar')
     assert len(result[result.keys()[0]]) != 0, \
@@ -58,12 +64,13 @@
 @pytest.mark.usefixtures('check_kibana')
 def test_public_ui_kibana(local_salt_client, ctl_nodes_pillar):
     IP = local_salt_client.pillar_get(param='_param:cluster_public_host')
-    protocol = 'https'
+    proto = local_salt_client.pillar_get(
+        param='_param:cluster_public_protocol')
     port = '5601'
-    url = "{}://{}:{}".format(protocol, IP, port)
+    url = "{}://{}:{}".format(proto, IP, port)
     result = local_salt_client.cmd(
         tgt=ctl_nodes_pillar,
-        param='curl {}/app/kibana 2>&1 | \
+        param='curl -k {}/app/kibana 2>&1 | \
                grep loading'.format(url),
         expr_form='pillar')
     assert len(result[result.keys()[0]]) != 0, \
@@ -94,12 +101,13 @@
 @pytest.mark.usefixtures('check_prometheus')
 def test_public_ui_prometheus(local_salt_client, ctl_nodes_pillar):
     IP = local_salt_client.pillar_get(param='_param:cluster_public_host')
-    protocol = 'https'
+    proto = local_salt_client.pillar_get(
+        param='_param:cluster_public_protocol')
     port = '15010'
-    url = "{}://{}:{}".format(protocol, IP, port)
+    url = "{}://{}:{}".format(proto, IP, port)
     result = local_salt_client.cmd(
         tgt=ctl_nodes_pillar,
-        param='curl {}/graph 2>&1 | \
+        param='curl -k {}/graph 2>&1 | \
                grep Prometheus'.format(url),
         expr_form='pillar')
     assert len(result[result.keys()[0]]) != 0, \
@@ -129,12 +137,13 @@
 @pytest.mark.usefixtures('check_prometheus')
 def test_public_ui_alert_manager(local_salt_client, ctl_nodes_pillar):
     IP = local_salt_client.pillar_get(param='_param:cluster_public_host')
-    protocol = 'https'
+    proto = local_salt_client.pillar_get(
+        param='_param:cluster_public_protocol')
     port = '15011'
-    url = "{}://{}:{}".format(protocol, IP, port)
+    url = "{}://{}:{}".format(proto, IP, port)
     result = local_salt_client.cmd(
         tgt=ctl_nodes_pillar,
-        param='curl -s {}/ | grep Alertmanager'.format(url),
+        param='curl -k -s {}/ | grep Alertmanager'.format(url),
         expr_form='pillar')
     assert len(result[result.keys()[0]]) != 0, \
         'Public AlertManager page is not reachable on {} ' \
@@ -163,12 +172,13 @@
 @pytest.mark.usefixtures('check_grafana')
 def test_public_ui_grafana(local_salt_client, ctl_nodes_pillar):
     IP = local_salt_client.pillar_get(param='_param:cluster_public_host')
-    protocol = 'https'
+    proto = local_salt_client.pillar_get(
+        param='_param:cluster_public_protocol')
     port = '8084'
-    url = "{}://{}:{}".format(protocol, IP, port)
+    url = "{}://{}:{}".format(proto, IP, port)
     result = local_salt_client.cmd(
         tgt=ctl_nodes_pillar,
-        param='curl {}/login 2>&1 | grep Grafana'.format(url),
+        param='curl -k {}/login 2>&1 | grep Grafana'.format(url),
         expr_form='pillar')
     assert len(result[result.keys()[0]]) != 0, \
         'Public Grafana page is not reachable on {} from ctl nodes'.format(url)
@@ -196,12 +206,13 @@
 @pytest.mark.usefixtures('check_alerta')
 def test_public_ui_alerta(local_salt_client, ctl_nodes_pillar):
     IP = local_salt_client.pillar_get(param='_param:cluster_public_host')
-    protocol = 'https'
+    proto = local_salt_client.pillar_get(
+        param='_param:cluster_public_protocol')
     port = '15017'
-    url = "{}://{}:{}".format(protocol, IP, port)
+    url = "{}://{}:{}".format(proto, IP, port)
     result = local_salt_client.cmd(
         tgt=ctl_nodes_pillar,
-        param='curl {}/ 2>&1 | \
+        param='curl -k {}/ 2>&1 | \
                grep Alerta'.format(url),
         expr_form='pillar')
     assert len(result[result.keys()[0]]) != 0, \
@@ -213,9 +224,10 @@
 @pytest.mark.usefixtures('check_drivetrain')
 def test_public_ui_jenkins(local_salt_client, ctl_nodes_pillar):
     IP = local_salt_client.pillar_get(param='_param:cluster_public_host')
-    protocol = 'https'
+    proto = local_salt_client.pillar_get(
+        param='_param:cluster_public_protocol')
     port = '8081'
-    url = "{}://{}:{}".format(protocol, IP, port)
+    url = "{}://{}:{}".format(proto, IP, port)
     result = local_salt_client.cmd(
         tgt=ctl_nodes_pillar,
         param='curl -k {}/ 2>&1 | \
@@ -230,13 +242,14 @@
 @pytest.mark.usefixtures('check_drivetrain')
 def test_public_ui_gerrit(local_salt_client, ctl_nodes_pillar):
     IP = local_salt_client.pillar_get(param='_param:cluster_public_host')
-    protocol = 'https'
+    proto = local_salt_client.pillar_get(
+        param='_param:cluster_public_protocol')
     port = '8070'
-    url = "{}://{}:{}".format(protocol, IP, port)
+    url = "{}://{}:{}".format(proto, IP, port)
     result = local_salt_client.cmd(
         tgt=ctl_nodes_pillar,
         param='curl -k {}/ 2>&1 | \
                grep "Gerrit Code Review"'.format(url),
         expr_form='pillar')
     assert len(result[result.keys()[0]]) != 0, \
-        'Public Gerrit page is not reachable on {} from ctl nodes'.format(url)
\ No newline at end of file
+        'Public Gerrit page is not reachable on {} from ctl nodes'.format(url)