Esempio n. 1
0
def process_cert_based_auth(repo, config):
    """
    Write the CA and Cert files in the PKI, if present. Remove them, if not.

    :param repo: repository to validate the config for
    :type  repo: pulp.server.db.model.Repository
    :param config: configuration instance to validate
    :type  config: pulp.plugins.config.PluginCallConfiguration or dict
    """

    auth_ca = config.get('auth_ca', None)
    auth_cert = config.get('auth_cert', None)

    relative_path = get_repo_relative_path(repo, config)
    auth_config = load_config(REPO_AUTH_CONFIG_FILE)

    protected_repo_utils_instance = protected_repo_utils.ProtectedRepoUtils(
        auth_config)

    if None in (auth_ca, auth_cert):
        protected_repo_utils_instance.delete_protected_repo(relative_path)

    else:
        repo_cert_utils_instance = repo_cert_utils.RepoCertUtils(auth_config)
        bundle = {'ca': auth_ca, 'cert': auth_cert}

        repo_cert_utils_instance.write_consumer_cert_bundle(
            repo.repo_id, bundle)
        protected_repo_utils_instance.add_protected_repo(
            relative_path, repo.repo_id)
Esempio n. 2
0
 def setUp(self):
     self.utils = repo_cert_utils.RepoCertUtils(CONFIG)
     self.clean()