| import base_section | 
 |  | 
 | from runtest import conditions | 
 |  | 
 | class Dashboard(base_section.BaseSection): | 
 |  | 
 |     name = "dashboard" | 
 |     options = [ | 
 |         'dashboard_url', | 
 |         'login_url', | 
 |         'disable_ssl_certificate_validation', | 
 |     ] | 
 |  | 
 |  | 
 |     @property | 
 |     def dashboard_url(self): | 
 |  | 
 |         horizon_enable = conditions.BaseRule('horizon.server.enabled', 'eq', True,multiple='any') | 
 |         if not horizon_enable: | 
 |             return | 
 |  | 
 |         nginx_enable = conditions.BaseRule('nginx.server.enabled', 'eq', True) | 
 |  | 
 |         if self.get_item_when_condition_match('horizon.server.enabled', horizon_enable): | 
 |             if self.get_item_when_condition_match('nginx.server.site.nginx_proxy_openstack_web.enabled', nginx_enable): | 
 |                 port = self.get_item_when_condition_match('nginx.server.site.nginx_proxy_openstack_web.host.port', nginx_enable) | 
 |                 protocol = self.get_item_when_condition_match('nginx.server.site.nginx_proxy_openstack_web.host.protocol', nginx_enable) | 
 |                 ip = self.get_item_when_condition_match('nginx.server.site.nginx_proxy_openstack_web.host.name', nginx_enable) | 
 |             else: | 
 |                 port = self.get_item_when_condition_match('horizon.server.bind.port', horizon_enable) | 
 |                 protocol = 'http' | 
 |                 ip = self.get_item_when_condition_match('_param.cluster_local_address', horizon_enable) | 
 |             # When CSRF protection is enabled Refferer and Host header should match. | 
 |             # Common browsers doesn't add default ports like 80 and 443 to the headers | 
 |             # Use the same logic here to make sure test passed when CSRF protection is enabled and | 
 |             # we using default port numbers. More info may be found here: | 
 |             # * https://code.djangoproject.com/ticket/26037 | 
 |             # * https://stackoverflow.com/questions/27533011/django-csrf-error-casused-by-nginx-x-forwarded-host | 
 |             if str(port) not in ['80', '443']: | 
 |                return "{}://{}:{}".format(protocol, ip, port) | 
 |             return "{}://{}".format(protocol, ip) | 
 |  | 
 |     @property | 
 |     def login_url(self): | 
 |         if self.dashboard_url: | 
 |             return "{}/auth/login/".format(self.dashboard_url) | 
 |  | 
 |     @property | 
 |     def disable_ssl_certificate_validation(self): | 
 |         pass |