def _add_defaults(app): """Add default tenant, admin user and provider context to the DB """ provider_context = models.ProviderContext(id=PROVIDER_CONTEXT_ID, name=PROVIDER_NAME, context=PROVIDER_CONTEXT) db.session.add(provider_context) default_tenant = create_default_user_tenant_and_roles( admin_username=utils.get_manager_username(), admin_password=utils.get_manager_password(), ) app.config[CURRENT_TENANT_CONFIG] = default_tenant
def prepare_reset_storage_script(): reset_script = get_resource('scripts/reset_storage.py') copy_file_to_manager(reset_script, SCRIPT_PATH) with tempfile.NamedTemporaryFile(delete=False) as f: json.dump( { 'config': { '': constants.CONFIG_FILE_LOCATION, 'security': SECURITY_FILE_LOCATION, 'authorization': constants.AUTHORIZATION_FILE_LOCATION }, 'ip': utils.get_manager_ip(), 'username': utils.get_manager_username(), 'password': utils.get_manager_password(), 'provider_context': PROVIDER_CONTEXT }, f) try: copy_file_to_manager(f.name, CONFIG_PATH) finally: os.unlink(f.name)
def _test_client(self, client_version, url_version_postfix): shell_script_path = resource('scripts/test_old_rest_client.sh') python_script_path = resource('scripts/test_old_rest_client.py') result_path = os.path.join(self.workdir, 'result.json') env = os.environ.copy() env.update({ 'python_script_path': python_script_path, 'client_version': client_version, 'manager_ip': self.get_manager_ip(), 'manager_user': utils.get_manager_username(), 'manager_password': utils.get_manager_password(), 'manager_tenant': utils.get_manager_tenant(), 'url_version_postfix': url_version_postfix, 'result_path': result_path }) subprocess.check_call(shell_script_path, shell=True, cwd=self.workdir, env=env) with open(result_path) as f: result = json.load(f) if result['failed']: self.fail('Failed to get manager status from old client. ' '[error={0}]'.format(result['details']))
def _test_client(self, client_version, url_version_postfix): shell_script_path = resource('scripts/test_old_rest_client.sh') python_script_path = resource('scripts/test_old_rest_client.py') result_path = os.path.join(self.workdir, 'result.json') env = os.environ.copy() env.update({ 'python_script_path': python_script_path, 'client_version': client_version, 'manager_ip': self.get_manager_ip(), 'manager_user': utils.get_manager_username(), 'manager_password': utils.get_manager_password(), 'manager_tenant': utils.get_manager_tenant(), 'url_version_postfix': url_version_postfix, 'result_path': result_path }) subprocess.check_call(shell_script_path, shell=True, cwd=self.workdir, env=env) with open(result_path) as f: result = json.load(f) if result['failed']: self.fail('Failed to get manager status from old client. ' '[error={0}]'.format(result['details']))
def test_valid_credentials_authenticate(self): self._assert_authorized(username=utils.get_manager_username(), password=utils.get_manager_password())