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')
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)
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)
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)
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')
def test_get_admin_passwd_pwd_set(self): self.test_config.set('admin-password', 'supersecret') self.assertEqual(utils.get_admin_passwd(), 'supersecret')