def _configure_static_serve(auth_backends=None):
    """Configure the static file serve."""
    cfg = hookenv.config()
    vhost_config = setup.get_virtualhost_config(auth_backends,
                                                cfg['resource-name'],
                                                cfg['auth-cache-enabled'],
                                                cfg['auth-cache-duration'],
                                                cfg['auth-cache-inactivity'])
    configure_site('archive-auth-mirror', 'nginx-static.j2', **vhost_config)
Exemple #2
0
 def test_virtualhost_config(self):
     """get_virtualhost_config returns the config for the virtualhost."""
     hookenv = FakeHookEnv()
     config = get_virtualhost_config(hookenv=hookenv)
     self.assertEqual(
         {'domain': '1.2.3.4',
          'document_root': '/srv/archive-auth-mirror/static',
          'basic_auth_file': '/srv/archive-auth-mirror/basic-auth'},
         config)
Exemple #3
0
 def test_virtualhost_config_auth_cache_time(self):
     """If caching time is passed, it's included in the vhost config."""
     hookenv = FakeHookEnv()
     config = get_virtualhost_config(auth_cache_time='5m', hookenv=hookenv)
     self.assertEqual(
         {
             'domain': '1.2.3.4',
             'document_root': '/srv/archive-auth-mirror/static',
             'auth_backends': [],
             'auth_cache_time': '5m',
             'basic_auth_file': '/srv/archive-auth-mirror/basic-auth'
         }, config)
Exemple #4
0
 def test_virtualhost_config_auth_backends(self):
     """If backends are passed, they're included in the vhost config."""
     hookenv = FakeHookEnv()
     auth_backends = [('1.2.3.4', '8080'), ('5.6.7.8', '9090')]
     config = get_virtualhost_config(auth_backends=auth_backends,
                                     hookenv=hookenv)
     self.assertEqual(
         {
             'domain': '1.2.3.4',
             'document_root': '/srv/archive-auth-mirror/static',
             'auth_backends': auth_backends,
             'auth_cache_time': None,
             'basic_auth_file': '/srv/archive-auth-mirror/basic-auth'
         }, config)
 def test_virtualhost_config_auth_cache_time(self):
     """If caching time is passed, it's included in the vhost config."""
     hookenv = FakeHookEnv()
     auth_backends = []
     resource_name = 'esm-apps'
     auth_cache_enabled = True
     auth_cache_duration, auth_cache_inactivity = "1h", "5m"
     config = get_virtualhost_config(auth_backends,
                                     resource_name,
                                     auth_cache_enabled,
                                     auth_cache_duration,
                                     auth_cache_inactivity,
                                     hookenv=hookenv)
     self.assertEqual(
         {
             'domain': '1.2.3.4',
             'document_root': '/srv/archive-auth-mirror/static',
             'auth_backends': [],
             'auth_cache_enabled': True,
             'auth_cache_duration': "1h",
             'auth_cache_inactivity': "5m",
             'basic_auth_file': '/srv/archive-auth-mirror/basic-auth',
             'resource_name': 'esm-apps'
         }, config)
 def test_virtualhost_config_auth_backends(self):
     """If backends are passed, they're included in the vhost config."""
     hookenv = FakeHookEnv()
     auth_backends = [('1.2.3.4', '8080'), ('5.6.7.8', '9090')]
     resource_name = 'fips'
     auth_cache_enabled = False
     auth_cache_duration = auth_cache_inactivity = ""
     config = get_virtualhost_config(auth_backends,
                                     resource_name,
                                     auth_cache_enabled,
                                     auth_cache_duration,
                                     auth_cache_inactivity,
                                     hookenv=hookenv)
     self.assertEqual(
         {
             'domain': '1.2.3.4',
             'document_root': '/srv/archive-auth-mirror/static',
             'auth_backends': auth_backends,
             'auth_cache_enabled': False,
             'auth_cache_duration': "",
             'auth_cache_inactivity': "",
             'basic_auth_file': '/srv/archive-auth-mirror/basic-auth',
             'resource_name': 'fips'
         }, config)
 def test_virtualhost_config(self):
     """get_virtualhost_config returns the config for the virtualhost."""
     hookenv = FakeHookEnv()
     auth_backends = []
     resource_name = 'esm'
     auth_cache_enabled = False
     auth_cache_duration = auth_cache_inactivity = ""
     config = get_virtualhost_config(auth_backends,
                                     resource_name,
                                     auth_cache_enabled,
                                     auth_cache_duration,
                                     auth_cache_inactivity,
                                     hookenv=hookenv)
     self.assertEqual(
         {
             'domain': '1.2.3.4',
             'document_root': '/srv/archive-auth-mirror/static',
             'auth_backends': [],
             'auth_cache_enabled': False,
             'auth_cache_duration': "",
             'auth_cache_inactivity': "",
             'basic_auth_file': '/srv/archive-auth-mirror/basic-auth',
             'resource_name': 'esm'
         }, config)
Exemple #8
0
def _configure_static_serve(auth_backends=None):
    """Configure the static file serve."""
    auth_cache_time = hookenv.config()['auth-cache-time']
    vhost_config = setup.get_virtualhost_config(
        auth_backends=auth_backends, auth_cache_time=auth_cache_time)
    configure_site('archive-auth-mirror', 'nginx-static.j2', **vhost_config)
Exemple #9
0
def _configure_static_serve():
    """Configure the static file serve."""
    vhost_config = setup.get_virtualhost_config()
    configure_site('archive-auth-mirror', 'nginx-static.j2', **vhost_config)