Beispiel #1
0
    def test_unbind_missing_repo(self):
        """
        Tests that calling unbind on a repo that isn't bound does not result in
        an error.
        """

        # Setup
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, ['http://pulp'], {}, None, None, ENABLED, LOCK)

        # Test
        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, 'fake-repo', LOCK)
Beispiel #2
0
    def test_unbind_missing_file(self):
        """
        Tests that calling unbind in the case where the underlying .repo file has been
        deleted does not result in an error.
        """

        # Setup
        self.assertTrue(not os.path.exists(TEST_REPO_FILENAME))

        # Test
        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, LOCK)
Beispiel #3
0
    def test_unbind_repo_with_keys(self):
        """
        Tests that unbinding a repo that had GPG keys deletes the key files.
        """

        # Setup
        url_list = ['http://pulp1']
        keys = {'key1' : 'KEY1', 'key2' : 'KEY2'}

        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, keys, None, None, ENABLED, LOCK)

        self.assertTrue(os.path.exists(os.path.join(TEST_KEYS_DIR, REPO_ID)))

        # Test
        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, LOCK)

        # Verify
        self.assertTrue(not os.path.exists(os.path.join(TEST_KEYS_DIR, REPO_ID)))
Beispiel #4
0
    def test_unbind_repo_with_mirrorlist(self):
        """
        Tests that unbinding a repo that had a mirror list deletes the mirror list
        file.
        """

        # Setup
        url_list = ['http://pulp1', 'http://pulp2', 'http://pulp3']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, url_list, {}, None, None, ENABLED, LOCK)
        self.assertTrue(os.path.exists(TEST_MIRROR_LIST_FILENAME))

        # Test
        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, LOCK)

        # Verify
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()
        self.assertEqual(0, len(repo_file.all_repos()))

        self.assertTrue(not os.path.exists(TEST_MIRROR_LIST_FILENAME))
Beispiel #5
0
    def test_unbind_repo_exists(self):
        """
        Tests the normal case of unbinding a repo that exists in the repo file.
        """

        # Setup
        repoid = 'test-unbind-repo'
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.add_repo(Repo(repoid))
        repo_file.save()

        # Test
        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, 'test-unbind-repo', LOCK)

        # verify
        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load(allow_missing=False) # the file should still be there, so error if it doesn't

        self.assertEqual(0, len(repo_file.all_repos()))
        
        certdir = os.path.join(TEST_CERT_DIR, repoid)
        self.assertFalse(os.path.exists(certdir))
Beispiel #6
0
 def unbind(self, conduit, repo_id, options):
     """
     Bind a repository.
         @param conduit: A handler conduit.
     @type conduit: L{pulp.agent.lib.conduit.Conduit}
     @param repo_id: A repository ID.
     @type repo_id: str
     @param options: Unbind options.
     @type options: dict
     @return: An unbind report.
     @rtype: L{BindReport}
     """
     log.info('unbind: %s, options:%s', repo_id, options)
     cfg = conduit.get_consumer_config().graph()
     report = BindReport(repo_id)
     repolib.unbind(
         cfg.filesystem.repo_file,
         os.path.join(cfg.filesystem.mirror_list_dir, repo_id),
         cfg.filesystem.gpg_keys_dir,
         cfg.filesystem.cert_dir,
         repo_id)
     report.set_succeeded()
     return report