Пример #1
0
 def test_get_admin_passwd_pwd_file_load(self, isfile):
     self.test_config.set('admin-password', '')
     isfile.return_value = True
     with patch('__builtin__.open') as mock_open:
         mock_open.return_value.__enter__ = lambda s: s
         mock_open.return_value.__exit__ = Mock()
         mock_open.return_value.readline.return_value = 'supersecretfilepwd'
         self.assertEqual(utils.get_admin_passwd(), 'supersecretfilepwd')
Пример #2
0
 def test_get_admin_passwd_pwd_file_load(self, isfile):
     self.test_config.set('admin-password', '')
     isfile.return_value = True
     with patch('__builtin__.open') as mock_open:
         mock_open.return_value.__enter__ = lambda s: s
         mock_open.return_value.__exit__ = Mock()
         mock_open.return_value.readline.return_value = 'supersecretfilepwd'
         self.assertEqual(utils.get_admin_passwd(), 'supersecretfilepwd')
Пример #3
0
def admin_relation_changed(relation_id=None):
    # TODO: fixup
    relation_data = {
        'service_hostname': resolve_address(ADMIN),
        'service_port': config('service-port'),
        'service_username': config('admin-user'),
        'service_tenant_name': config('admin-role'),
        'service_region': config('region'),
    }
    relation_data['service_password'] = get_admin_passwd()
    relation_set(relation_id=relation_id, **relation_data)
Пример #4
0
def admin_relation_changed(relation_id=None):
    # TODO: fixup
    relation_data = {
        'service_hostname': resolve_address(ADMIN),
        'service_port': config('service-port'),
        'service_username': config('admin-user'),
        'service_tenant_name': config('admin-role'),
        'service_region': config('region'),
    }
    relation_data['service_password'] = get_admin_passwd()
    relation_set(relation_id=relation_id, **relation_data)
Пример #5
0
def admin_relation_changed(relation_id=None):
    # TODO: fixup
    relation_data = {
        "service_hostname": resolve_address(ADMIN),
        "service_port": config("service-port"),
        "service_username": config("admin-user"),
        "service_tenant_name": config("admin-role"),
        "service_region": config("region"),
        "service_protocol": "https" if https() else "http",
    }
    relation_data["service_password"] = get_admin_passwd()
    relation_set(relation_id=relation_id, **relation_data)
Пример #6
0
def admin_relation_changed(relation_id=None):
    # TODO: fixup
    if expect_ha() and not is_clustered():
        log("Expected to be HA but no hacluster relation yet", level=INFO)
        return
    relation_data = {
        'service_hostname': resolve_address(ADMIN),
        'service_port': config('service-port'),
        'service_username': config('admin-user'),
        'service_tenant_name': config('admin-role'),
        'service_region': config('region'),
        'service_protocol': 'https' if https() else 'http',
        'api_version': get_api_version(),
    }
    if relation_data['api_version'] > 2:
        relation_data['service_user_domain_name'] = ADMIN_DOMAIN
        relation_data['service_project_domain_name'] = ADMIN_DOMAIN
        relation_data['service_project_name'] = ADMIN_PROJECT
    relation_data['service_password'] = get_admin_passwd()
    relation_set(relation_id=relation_id, **relation_data)
Пример #7
0
def admin_relation_changed(relation_id=None):
    # TODO: fixup
    if expect_ha() and not is_clustered():
        log("Expected to be HA but no hacluster relation yet", level=INFO)
        return
    relation_data = {
        'service_hostname': resolve_address(ADMIN),
        'service_port': config('service-port'),
        'service_username': config('admin-user'),
        'service_tenant_name': config('admin-role'),
        'service_region': config('region'),
        'service_protocol': 'https' if https() else 'http',
        'api_version': get_api_version(),
    }
    if relation_data['api_version'] > 2:
        relation_data['service_user_domain_name'] = ADMIN_DOMAIN
        relation_data['service_project_domain_name'] = ADMIN_DOMAIN
        relation_data['service_project_name'] = ADMIN_PROJECT
    relation_data['service_password'] = get_admin_passwd()
    relation_set(relation_id=relation_id, **relation_data)
Пример #8
0
 def test_get_admin_passwd_genpass(self, isfile, store_admin_passwd):
     self.test_config.set('admin-password', '')
     isfile.return_value = False
     self.subprocess.check_output.return_value = 'supersecretgen'
     self.assertEqual(utils.get_admin_passwd(), 'supersecretgen')
Пример #9
0
 def test_get_admin_passwd_pwd_set(self):
     self.test_config.set('admin-password', 'supersecret')
     self.assertEqual(utils.get_admin_passwd(), 'supersecret')
Пример #10
0
 def test_get_admin_passwd_genpass(self, isfile, store_admin_passwd):
     self.test_config.set('admin-password', '')
     isfile.return_value = False
     self.subprocess.check_output.return_value = 'supersecretgen'
     self.assertEqual(utils.get_admin_passwd(), 'supersecretgen')
Пример #11
0
 def test_get_admin_passwd_pwd_set(self):
     self.test_config.set('admin-password', 'supersecret')
     self.assertEqual(utils.get_admin_passwd(), 'supersecret')