def test_02_check_role_permission(self):
        # create users
        self.user.create(self.pulp)
        self.assertPulpOK()

        self.user2.create(self.pulp)
        self.assertPulpOK()

        # add users to the role
        self.role.add_user(
            self.pulp,
            data={'login': self.user.data['login']}
        )
        self.assertPulp(code=200)

        self.role.add_user(
            self.pulp,
            data={'login': self.user2.data['login']}
        )
        self.assertPulp(code=200)

        # check users' permissions
        with self.user_pulp.asserting(True):
            Repo.list(self.user_pulp)

        with self.user_pulp2.asserting(True):
            Repo.list(self.user_pulp2)
Exemplo n.º 2
0
 def test_15_check_bindings_removed(self):
     self.role.delete(self.pulp)
     self.assertPulpOK()
     #check that after role deletion user binding are also removed
     with self.assertRaises(AssertionError):
         with self.user_pulp.asserting(True):
             Repo.list(self.user_pulp)
Exemplo n.º 3
0
 def test_15_check_bindings_removed(self):
     self.role.delete(self.pulp)
     self.assertPulpOK()
     #check that after role deletion user binding are also removed
     with self.assertRaises(AssertionError):
         with self.user_pulp.asserting(True):
             Repo.list(self.user_pulp)
    def test_04_check_role_permission(self):
        # create users
        self.user.create(self.pulp)
        self.assertPulpOK()

        self.user2.create(self.pulp)
        self.assertPulpOK()

        # add users to the role
        self.role.add_user(
            self.pulp,
            self.user.id
        )
        self.assertPulp(code=200)

        self.role.add_user(
            self.pulp,
            self.user2.id
        )
        self.assertPulp(code=200)

        # check users' permissions, that thay can access resource after been added to specific role
        with self.user_pulp.asserting(True):
            Repo.list(self.user_pulp)

        with self.user_pulp2.asserting(True):
            Repo.list(self.user_pulp2)
 def test_07_sync_repo(self):
     x = Repo.get(self.pulp, self.repo.id).data['content_unit_counts']['puppet_module']
     response = self.repo.sync(self.pulp)
     self.assertPulp(code=202)
     Task.wait_for_report(self.pulp, response)
     y = Repo.get(self.pulp, self.repo.id).data['content_unit_counts']['puppet_module']
     #FIXME result can change with time as number of modules is not constant!
     #check that the second i.e. updated query was also processed.
     self.assertTrue(x != y)
 def test_02_get_repo(self):
     repo = Repo.get(self.pulp, self.repo.id)
     self.assertEqual(repo.id, self.repo.id)
     self.repo.reload(self.pulp)
     self.assertEqual(self.repo, repo)
     #get unexistant repo
     with self.assertRaises(AssertionError):
         Repo.get(self.pulp, 'some_id')
     self.assertPulp(code=404)
 def test_02_get_repo(self):
     repo = Repo.get(self.pulp, self.repo.id)
     self.assertEqual(repo.id, self.repo.id)
     self.repo.reload(self.pulp)
     self.assertEqual(self.repo, repo)
     #get unexistant repo
     with self.assertRaises(AssertionError):
         Repo.get(self.pulp, 'some_id')
     self.assertPulp(code=404)
 def test_02_copy_repo1_to_repo2(self):
     with self.pulp.asserting(True):
         response = self.repo2.copy(self.pulp, self.repo1.id, data={})
     Task.wait_for_report(self.pulp, response)
     
     #check that the number of modules are the same
     repo1 = Repo.get(self.pulp, self.repo1.id)
     repo2 = Repo.get(self.pulp, self.repo2.id)
     self.assertEqual(repo1.data['content_unit_counts'], repo2.data['content_unit_counts'])
 def setUpClass(cls):
     super(RepoGroupTest, cls).setUpClass()
     cls.repo = Repo(data={'id': cls.__name__ + "_repo"})
     cls.repo2 = Repo(data={'id': cls.__name__ + "_repo2"})
     cls.repo_group = RepoGroup(data={'id': cls.__name__ + "_repo_group"})
     cls.repo_group1 = RepoGroup(data={'id': cls.__name__ + "_repo_group1"})
     cls.repo_group2 = RepoGroup(data={'id': cls.__name__ + "_repo_group2", 'repo_ids': [cls.repo.id]})
     cls.repo_group3 = RepoGroup(data={'id': cls.__name__ + "_repo_group3", 'repo_ids': [cls.repo2.id]})
     cls.feed = 'http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/'
Exemplo n.º 10
0
    def test_02_copy_repo1_to_repo2(self):
        with self.pulp.asserting(True):
            response = self.repo2.copy(self.pulp, self.repo1.id, data={})
        Task.wait_for_report(self.pulp, response)

        #check that the number of modules are the same
        repo1 = Repo.get(self.pulp, self.repo1.id)
        repo2 = Repo.get(self.pulp, self.repo2.id)
        self.assertEqual(repo1.data['content_unit_counts'],
                         repo2.data['content_unit_counts'])
Exemplo n.º 11
0
class RepoTest(pulp_test.PulpTest):
    def setUp(self):
        super(RepoTest, self).setUp()
        self.repo = Repo(data={'id': type(self).__name__ + "_repo"})
        self.feed = 'http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/'
        # assert connection works
        self.pulp.send(login.request())
        self.assertPulpOK()

    def tearDown(self):
        self.repo.delete(self.pulp)
Exemplo n.º 12
0
 def test_07_sync_repo(self):
     x = Repo.get(self.pulp,
                  self.repo.id).data['content_unit_counts']['puppet_module']
     response = self.repo.sync(self.pulp)
     self.assertPulp(code=202)
     Task.wait_for_report(self.pulp, response)
     y = Repo.get(self.pulp,
                  self.repo.id).data['content_unit_counts']['puppet_module']
     #FIXME result can change with time as number of modules is not constant!
     #check that the second i.e. updated query was also processed.
     self.assertTrue(x != y)
Exemplo n.º 13
0
 def setUpClass(cls):
     super(SimpleOrphanTest, cls).setUpClass()
     # prepare orphans by syncing and deleting a repo
     # make sure the repo is gone
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     repo = Repo(repo_config)
     repo.delete(cls.pulp)
     # create and sync repo
     cls.repo, _, _ = create_yum_repo(cls.pulp, **repo_config)
     Task.wait_for_report(cls.pulp, cls.repo.sync(cls.pulp))
     # this is where orphans appear
     Task.wait_for_report(cls.pulp, cls.repo.delete(cls.pulp))
Exemplo n.º 14
0
    def test_02_copy_repo_to_repo_copy_and_publish(self):
        with self.pulp.asserting(True):
            response = self.repo_copy.copy(self.pulp, self.repo.id, data={})
        Task.wait_for_report(self.pulp, response)
        
        #check that the number of modules are the same
        repo = Repo.get(self.pulp, self.repo.id)
        repo_copy = Repo.get(self.pulp, self.repo_copy.id)
        self.assertEqual(repo.data['content_unit_counts'], repo_copy.data['content_unit_counts'])

        with self.pulp.asserting(True):        
            response = self.repo_copy.publish(self.pulp, self.distributor_copy.id)
        Task.wait_for_report(self.pulp, response)        
    def setUpClass(cls):
        super(SimpleRepoCopyTest, cls).setUpClass()
        #Destination repo
        # make sure repos don't exist
        # no need to wait for repos.delete to happen
        dest_repo_name = cls.__name__ + '_copy'
        dest_repo1 = Repo({'id': dest_repo_name})
        dest_repo1.delete(cls.pulp)
        cls.dest_repo1, _, _ = YumRepo(
            id=dest_repo_name,
            importer=YumImporter(None),
            distributors=[YumDistributor(relative_url='abc')]).create(cls.pulp)

        #2nd Destination Repo
        dest_repo_name = cls.__name__ + '_copy1'
        dest_repo2 = Repo({'id': dest_repo_name})
        dest_repo2.delete(cls.pulp)
        cls.dest_repo2, _, _ = YumRepo(
            id=dest_repo_name,
            importer=YumImporter(None),
            distributors=[YumDistributor(relative_url='xyz')]).create(cls.pulp)

        # Source repo
        default_repo_config = [
            repo for repo in ROLES.repos if repo.type == 'rpm'
        ][0]
        cls.source_repo, _, _ = YumRepo.from_role(default_repo_config).create(
            cls.pulp)
        Task.wait_for_report(cls.pulp, cls.source_repo.sync(cls.pulp))
Exemplo n.º 16
0
 def setUpClass(cls):
     super(RepoGroupTest, cls).setUpClass()
     cls.repo = Repo(data={'id': cls.__name__ + "_repo"})
     cls.repo2 = Repo(data={'id': cls.__name__ + "_repo2"})
     cls.repo_group = RepoGroup(data={'id': cls.__name__ + "_repo_group"})
     cls.repo_group1 = RepoGroup(data={'id': cls.__name__ + "_repo_group1"})
     cls.repo_group2 = RepoGroup(data={
         'id': cls.__name__ + "_repo_group2",
         'repo_ids': [cls.repo.id]
     })
     cls.repo_group3 = RepoGroup(data={
         'id': cls.__name__ + "_repo_group3",
         'repo_ids': [cls.repo2.id]
     })
Exemplo n.º 17
0
    def test_02_copy_repo_to_repo_copy_and_publish(self):
        with self.pulp.asserting(True):
            response = self.repo_copy.copy(self.pulp, self.repo.id, data={})
        Task.wait_for_report(self.pulp, response)

        #check that the number of modules are the same
        repo = Repo.get(self.pulp, self.repo.id)
        repo_copy = Repo.get(self.pulp, self.repo_copy.id)
        self.assertEqual(repo.data['content_unit_counts'],
                         repo_copy.data['content_unit_counts'])

        with self.pulp.asserting(True):
            response = self.repo_copy.publish(self.pulp,
                                              self.distributor_copy.id)
        Task.wait_for_report(self.pulp, response)
Exemplo n.º 18
0
 def test_99_node_unbind_repo(self):
     self.node.unbind_repo(self.pulp, self.repo.id, self.node_distributor.id)
     self.assertPulpOK()
     # nodes keep the repos after updating
     child_repos = Repo.list(self.pulp_child)
     for repo in child_repos:
         Task.wait_for_report(self.pulp_child, repo.delete(self.pulp_child))
 def setUpClass(cls):
     super(ImporterDistributorTest, cls).setUpClass()
     #create repo with inporter/distributer associated
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     cls.repo, _, cls.distributor = create_yum_repo(cls.pulp, **repo_config)
     cls.importer = cls.repo.get_importer(cls.pulp, "yum_importer")
     cls.repo1 = Repo(data={'id': cls.__name__ + "_repo1"})
Exemplo n.º 20
0
 def test_04_check_update_was_correct(self):
     self.assertEqual(
         Repo.get(self.pulp, self.repo.id).data['display_name'], "NewName")
     importer = self.repo.get_importer(self.pulp, "yum_importer")
     self.assertEqual(importer.data["config"]["num_units"], 6)
     distributor = self.repo.get_distributor(self.pulp, "yum_distributor")
     self.assertEqual(distributor.data["config"]["relative_url"], "my_url")
 def setUpClass(cls):
     super(PuppetCopyRepoTest, cls).setUpClass()
     # this repo role is hardwired because of the search strings
     # refering to exact names as e.g. tomcat7_rhel
     # The proxy role is considered
     repo = {
         'id': cls.__name__,
         'feed': 'https://forge.puppetlabs.com',
         'queries': ['tomcat'],
         'proxy': ROLES.get('proxy'),
     }
     # create source repo and sync it to have modules fetched
     cls.source_repo, _, _ = PuppetRepo.from_role(repo).create(cls.pulp)
     Task.wait_for_report(cls.pulp, cls.source_repo.sync(cls.pulp))
     # create two destinations repos for copy purpose
     importer = PuppetImporter(feed=None, queries=[])
     distributors = [PuppetDistributor()]
     cls.dest_repo1, _, _ = PuppetRepo(id=cls.__name__ + '1',
                                       importer=importer,
                                       distributors=distributors).create(
                                           cls.pulp)
     cls.dest_repo2, _, _ = PuppetRepo(id=cls.__name__ + '2',
                                       importer=importer,
                                       distributors=distributors).create(
                                           cls.pulp)
     # create data for repo
     cls.invalid_repo = Repo(data={'id': cls.__name__ + "_invalidrepo"})
     # create yum repo
     cls.yumrepo, _, _ = YumRepo(
         id=cls.__name__ + 'yum',
         importer=YumImporter(feed=None),
         distributors=[YumDistributor(relative_url='xyz')]).create(cls.pulp)
Exemplo n.º 22
0
 def tearDownClass(cls):
     with cls.pulp. async ():
         for repo_id in [
                 'SimpleRepoCopyTest_repo', 'SimpleRepoCopyTest_copy',
                 'SimpleRepoCopyTest_copy1'
         ]:
             Repo({'id': repo_id}).delete(cls.pulp)
 def test_12_delete_repos(self):
     for repo_id in [
             self.dest_repo1.id, self.dest_repo2.id, self.source_repo.id,
             self.yumrepo.id
     ]:
         response = Repo({'id': repo_id}).delete(self.pulp)
         Task.wait_for_report(self.pulp, response)
Exemplo n.º 24
0
 def test_99_node_unbind_repo(self):
     self.node.unbind_repo(self.pulp, self.repo.id,
                           self.node_distributor.id)
     self.assertPulpOK()
     # nodes keep the repos after updating
     child_repos = Repo.list(self.pulp_child)
     for repo in child_repos:
         Task.wait_for_report(self.pulp_child, repo.delete(self.pulp_child))
 def test_04_update_repo(self):
     display_name = 'A %s repo' % self.__class__.__name__
     self.repo |= {'display_name': display_name}
     self.repo.delta_update(self.pulp)
     self.assertPulp(code=200)
     self.assertEqual(
         Repo.get(self.pulp, self.repo.id).data['display_name'],
         display_name)
    def test_11_two_roles_two_users(self):
        # create users
        self.user.create(self.pulp)
        self.assertPulpOK()

        self.user2.create(self.pulp)
        self.assertPulpOK()

        # grant permissions
        self.role.grant_permission(self.pulp, self.role.id, "/", ["READ", "EXECUTE"])
        self.role.grant_permission(self.pulp, self.role.id, "/repositories/", ["READ", "EXECUTE"])
        self.assertPulpOK()

        self.role2.grant_permission(self.pulp, self.role2.id, "/", ["READ", "EXECUTE"])
        self.role2.grant_permission(self.pulp, self.role2.id, "/repositories/", ["READ", "EXECUTE"])
        self.assertPulpOK()

        # add users to roles
        self.role.add_user(
            self.pulp,
            self.user.id
        )
        self.assertPulp(code=200)

        self.role2.add_user(
            self.pulp,
            self.user.id
        )
        self.assertPulp(code=200)

        self.role2.add_user(
            self.pulp,
            self.user2.id
        )
        self.assertPulp(code=200)

        # check users' permissions
        with self.user_pulp.asserting(True):
            Repo.list(self.user_pulp)

        with self.user_pulp2.asserting(True):
            Repo.list(self.user_pulp2)

        # revoke permissions from role2
        self.role2.revoke_permission(self.pulp, self.role2.id, "/", ["READ", "EXECUTE"])
        self.role2.revoke_permission(self.pulp, self.role2.id, "/repositories/", ["READ", "EXECUTE"])
        self.assertPulpOK()

        # check users' permissions
        # user should still be able to access resource as it belongs to other role
        with self.user_pulp.asserting(True):
            Repo.list(self.user_pulp)
        # user2 should not be able to access resource as no more pemissions are granted to it
        with self.assertRaises(AssertionError):
            with self.user_pulp2.asserting(True):
                Repo.list(self.user_pulp2)
    def test_06_two_roles_two_users(self):
        # create users
        self.user.create(self.pulp)
        self.assertPulpOK()

        self.user2.create(self.pulp)
        self.assertPulpOK()

        # grant permissions
        self.role.grant_permission(self.pulp, data={"role_id": self.role.data['id'], "resource": "/", "operations": ["READ", "EXECUTE"]})
        self.role.grant_permission(self.pulp, data={"role_id": self.role.data['id'], "resource": "/repositories/", "operations": ["READ", "EXECUTE"]})
        self.assertPulpOK()

        self.role2.grant_permission(self.pulp, data={"role_id": self.role2.data['id'], "resource": "/", "operations": ["READ", "EXECUTE"]})
        self.role2.grant_permission(self.pulp, data={"role_id": self.role2.data['id'], "resource": "/repositories/", "operations": ["READ", "EXECUTE"]})
        self.assertPulpOK()

        # add users to roles
        self.role.add_user(
            self.pulp,
            data={'login': self.user.data['login']}
        )
        self.assertPulp(code=200)

        self.role2.add_user(
            self.pulp,
            data={'login': self.user.data['login']}
        )
        self.assertPulp(code=200)

        self.role2.add_user(
            self.pulp,
            data={'login': self.user2.data['login']}
        )
        self.assertPulp(code=200)

        # check users' permissions
        with self.user_pulp.asserting(True):
            Repo.list(self.user_pulp)

        with self.user_pulp2.asserting(True):
            Repo.list(self.user_pulp2)

        # revoke permissions from role2
        self.role2.revoke_permission(self.pulp, data={"role_id": self.role2.data['id'], "resource": "/", "operations": ["READ", "EXECUTE"]})
        self.role2.revoke_permission(self.pulp, data={"role_id": self.role2.data['id'], "resource": "/repositories/", "operations": ["READ", "EXECUTE"]})
        self.assertPulpOK()

        # check users' permissions
        with self.user_pulp.asserting(True):
            Repo.list(self.user_pulp)

        with self.assertRaises(AssertionError):
            with self.user_pulp2.asserting(True):
                Repo.list(self.user_pulp2)
Exemplo n.º 28
0
def pulp_repo_url(pulp, repo_id, distributor_type_id='yum_distributor'):
    '''return repo content url for given repo id or None'''
    repo = Repo.get(pulp, repo_id)
    # this should at most 1 item (for any given type)
    distributors = [distributor for distributor in repo.list_distributors(pulp) \
        if distributor['distributor_type_id'] == distributor_type_id]
    if not distributors:
        return None
    return Distributor(data=distributors[0]).content_url(pulp)
Exemplo n.º 29
0
 def setUpClass(cls):
     super(IsoRepoTest, cls).setUpClass()
     # FIXME: hardwired role
     cls.repo_role = {
         'id': cls.__name__ + '_repo',
         'feed': DEFAULT_FEED,
         'proxy': ROLES.get('proxy'),
     }
     cls.repo = Repo(data=IsoRepo.from_role(cls.repo_role).as_data())
Exemplo n.º 30
0
def pulp_repo_url(pulp, repo_id, distributor_type_id='yum_distributor'):
    '''return repo content url for given repo id or None'''
    repo = Repo.get(pulp, repo_id)
    # this should at most 1 item (for any given type)
    distributors = [distributor for distributor in repo.list_distributors(pulp) \
        if distributor['distributor_type_id'] == distributor_type_id]
    if not distributors:
        return None
    return Distributor(data=distributors[0]).content_url(pulp)
    def test_11_two_roles_two_users(self):
        # create users
        self.user.create(self.pulp)
        self.assertPulpOK()

        self.user2.create(self.pulp)
        self.assertPulpOK()

        # grant permissions
        self.role.grant_permission(self.pulp, self.role.id, "/",
                                   ["READ", "EXECUTE"])
        self.role.grant_permission(self.pulp, self.role.id, "/repositories/",
                                   ["READ", "EXECUTE"])
        self.assertPulpOK()

        self.role2.grant_permission(self.pulp, self.role2.id, "/",
                                    ["READ", "EXECUTE"])
        self.role2.grant_permission(self.pulp, self.role2.id, "/repositories/",
                                    ["READ", "EXECUTE"])
        self.assertPulpOK()

        # add users to roles
        self.role.add_user(self.pulp, self.user.id)
        self.assertPulp(code=200)

        self.role2.add_user(self.pulp, self.user.id)
        self.assertPulp(code=200)

        self.role2.add_user(self.pulp, self.user2.id)
        self.assertPulp(code=200)

        # check users' permissions
        with self.user_pulp.asserting(True):
            Repo.list(self.user_pulp)

        with self.user_pulp2.asserting(True):
            Repo.list(self.user_pulp2)

        # revoke permissions from role2
        self.role2.revoke_permission(self.pulp, self.role2.id, "/",
                                     ["READ", "EXECUTE"])
        self.role2.revoke_permission(self.pulp, self.role2.id,
                                     "/repositories/", ["READ", "EXECUTE"])
        self.assertPulpOK()

        # check users' permissions
        # user should still be able to access resource as it belongs to other role
        with self.user_pulp.asserting(True):
            Repo.list(self.user_pulp)
        # user2 should not be able to access resource as no more pemissions are granted to it
        with self.assertRaises(AssertionError):
            with self.user_pulp2.asserting(True):
                Repo.list(self.user_pulp2)
Exemplo n.º 32
0
 def setUpClass(cls):
     super(PuppetRepoTest, cls).setUpClass()
     cls.repo = Repo(data={
         'id': cls.__name__ + "_repo",
         'notes': {
             "_repo-type": "puppet-repo"
         }
     })
     #modules will be fetched from puppet Forge
     cls.feed = 'http://forge.puppetlabs.com'
 def setUpClass(cls):
     super(DockerRepoTest, cls).setUpClass()
     # FIXME: hardwired role
     cls.repo_role = {
         'id': 'docker-test123',
         'feed': DEFAULT_FEED,
         'upstream_name': 'hello-world',
         'proxy': ROLES.get('proxy'),
         'relative_url': '/library/hello-world'
     }
     cls.repo = Repo(data=DockerRepo.from_role(cls.repo_role).as_data())
 def test_04_search_repo_in_repos(self):
     #search among puppet-repos by id
     repo = Repo.search(self.pulp,
                        data={
                            "criteria": {
                                "sort": None,
                                "fields": None,
                                "limit": None,
                                "filters": {
                                    "$and": [{
                                        "id":
                                        "SimplePuppetSearchRepoTest"
                                    }, {
                                        "notes._repo-type":
                                        "puppet-repo"
                                    }]
                                },
                                "skip": None
                            }
                        })
     self.assertIn(Repo({"id": self.repo.id}, ['id'], ['id']), repo)
 def test_04_check_that_one_iso(self):
     # check that there is precisly one module
     dest_repo2 = Repo.get(self.pulp, self.dest_repo2.id)
     self.assertEqual(dest_repo2.data["content_unit_counts"]["iso"], 1)
     # check that one exact module copied i.e. perform the search by modules name
     response = self.dest_repo2.within_repo_search(
         self.pulp, data={"criteria": {"type_ids": ["iso"], "filters": {"unit": {"name": "test.iso"}}}}
     )
     self.assertPulp(code=200)
     result = Association.from_response(response)
     # this means that only one module found with that name
     self.assertTrue(len(result) == 1)
    def test_04_check_role_permission(self):
        # create users
        self.user.create(self.pulp)
        self.assertPulpOK()

        self.user2.create(self.pulp)
        self.assertPulpOK()

        # add users to the role
        self.role.add_user(self.pulp, self.user.id)
        self.assertPulp(code=200)

        self.role.add_user(self.pulp, self.user2.id)
        self.assertPulp(code=200)

        # check users' permissions, that thay can access resource after been added to specific role
        with self.user_pulp.asserting(True):
            Repo.list(self.user_pulp)

        with self.user_pulp2.asserting(True):
            Repo.list(self.user_pulp2)
Exemplo n.º 37
0
 def test_04_check_that_one_module(self):
     # check that there is precisly one module
     dest_repo2 = Repo.get(self.pulp, self.dest_repo2.id)
     self.assertEqual(dest_repo2.data['content_unit_counts']['puppet_module'], 1)
     # check that one exact module copied i.e. perform the search by modules name
     response = self.dest_repo2.within_repo_search(
         self.pulp,
         data={"criteria": {"type_ids": ["puppet_module"], "filters": {"unit": {"name": "tomcat7_rhel"}}}}
     )
     self.assertPulp(code=200)
     result = Association.from_response(response)
     # this means that only one module found with that name
     self.assertTrue(len(result) == 1)
Exemplo n.º 38
0
 def test_03_search_erratum(self):
     unit = ErratumUnit.search(self.pulp,
                               data={
                                   "criteria": {
                                       "filters": {},
                                       "fields":
                                       ["name", "_content_type_id"]
                                   }
                               })
     repo2 = Repo.get(self.pulp, self.repo2.id)
     # assert that number of errata _eq_ to the number repo contains
     self.assertEqual(len(unit),
                      repo2.data['content_unit_counts']['erratum'])
Exemplo n.º 39
0
 def setUpClass(cls):
     super(PuppetCopyRepoTest, cls).setUpClass()
     repo_id = cls.__name__
     queries = ['tomcat']
     # create source repo and sync it to have modules fetched
     cls.source_repo, _, _ = create_puppet_repo(cls.pulp, repo_id, queries)
     Task.wait_for_report(cls.pulp, cls.source_repo.sync(cls.pulp))
     # create two destinations repos for copy purpose
     cls.dest_repo1, _, _ = create_puppet_repo(cls.pulp, repo_id + '1', feed=None)
     cls.dest_repo2, _, _ = create_puppet_repo(cls.pulp, repo_id + '2', feed=None)
     # create data for repo
     cls.invalid_repo = Repo(data={'id': cls.__name__ + "_invalidrepo"})
     # create yum repo
     cls.yumrepo, _, _ = create_yum_repo(cls.pulp, repo_id + 'yum', feed=None)
 def test_04_search_repo_in_repos(self):
     # search among puppet-repos by id
     repo = Repo.search(
         self.pulp,
         data={
             "criteria": {
                 "sort": None,
                 "fields": None,
                 "limit": None,
                 "filters": {"$and": [{"id": "SimplePuppetSearchRepoTest"}, {"notes._repo-type": "puppet-repo"}]},
                 "skip": None,
             }
         },
     )
     self.assertIn(Repo({"id": self.repo.id}, ["id"], ["id"]), repo)
Exemplo n.º 41
0
 def setUpClass(cls):
     super(UnitSearchTest, cls).setUpClass()
     #create and sync puppet repo
     repo_id = cls.__name__
     queries = ['jenkins']
     # make sure we run clean
     response = Repo({'id': repo_id}).delete(cls.pulp)
     if response == ResponseLike(202):
         Task.wait_for_report(cls.pulp, response)
     cls.repo1, _, _ = create_puppet_repo(cls.pulp, repo_id, queries)
     Task.wait_for_report(cls.pulp, cls.repo1.sync(cls.pulp))
     # create and sync rpm repo
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     cls.repo2, _, _ = create_yum_repo(cls.pulp, **repo_config)
     Task.wait_for_report(cls.pulp, cls.repo2.sync(cls.pulp))
 def test_05_search_repo_with_regexp(self):
     # search puppet-repos with .*repo.*
     repo = Repo.search(
         self.pulp,
         data={
             "criteria": {
                 "sort": None,
                 "fields": None,
                 "limit": None,
                 "filters": {"$and": [{"notes._repo-type": "puppet-repo"}, {"id": {"$regex": ".*Repo.*"}}]},
                 "skip": None,
             }
         },
     )
     # asserting to 2 as we have two repos matched the pattern
     self.assertTrue(len(repo) == 2)
Exemplo n.º 43
0
    def setUpClass(cls):
        super(SimpleRepoCopyTest, cls).setUpClass()
        #Destination repo
        feed = None
        dest_repo_name = cls.__name__ + '_copy'
        dest_repo1 = Repo({'id': dest_repo_name})
        dest_repo1.delete(cls.pulp)
        cls.dest_repo1, _, _ = create_yum_repo(cls.pulp, dest_repo_name, feed)

        #2nd Destination Repo
        dest_repo_name = cls.__name__ + '_copy1'
        dest_repo2 = Repo({'id': dest_repo_name})
        dest_repo2.delete(cls.pulp)
        cls.dest_repo2, _, _ = create_yum_repo(cls.pulp, dest_repo_name, feed)

        # Source repo
        default_repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
        source_repo_name = cls.__name__ + '_repo'
        source_repo = Repo({'id': source_repo_name})
        source_repo.delete(cls.pulp)
        cls.source_repo, _, _ = create_yum_repo(cls.pulp, source_repo_name, default_repo_config.feed)
        sync_task = Task.from_response(cls.source_repo.sync(cls.pulp))[0]
        sync_task.wait(cls.pulp)
Exemplo n.º 44
0
    def test_06_child_repo_content(self):
        # access the content of the pulp_child node
        # please note when the repo is created on the other node,
        # the distributor id used by default is yum_distributor

        # make sure the repo was published on the child node
        # the repo ID and distributor ID are the same on both the nodes
        child_repo = Repo.get(self.pulp_child, self.repo.id)
        response = child_repo.publish(self.pulp_child, self.distributor.id)
        assert response == ResponseLike(202), 'wrong response from the child node: %s' % response
        Task.wait_for_report(self.pulp_child, response)

        # fetch the repo content url on the child node
        repo_url = pulp_repo_url(self.pulp_child, self.repo.id)
        assert repo_url, 'invalid repo id on pulp_child node'
        # try accessing the content on the child node
        pkg_name = download_package_with_dnf(self.pulp_child, repo_url, 'bear')
        assert pkg_name == 'bear', 'not able to acces bear rpm on the child node'
    def setUpClass(cls):
        super(SimpleRepoCopyTest, cls).setUpClass()
        #Destination repo
        # make sure repos don't exist
        # no need to wait for repos.delete to happen
        feed = None
        dest_repo_name = cls.__name__ + '_copy'
        dest_repo1 = Repo({'id': dest_repo_name})
        dest_repo1.delete(cls.pulp)
        cls.dest_repo1, _, _ = create_yum_repo(cls.pulp, dest_repo_name, feed)

        #2nd Destination Repo
        dest_repo_name = cls.__name__ + '_copy1'
        dest_repo2 = Repo({'id': dest_repo_name})
        dest_repo2.delete(cls.pulp)
        cls.dest_repo2, _, _ = create_yum_repo(cls.pulp, dest_repo_name, feed)

        # Source repo
        default_repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
        source_repo_name = cls.__name__ + '_repo'
        source_repo = Repo({'id': source_repo_name})
        source_repo.delete(cls.pulp)
        cls.source_repo, _, _ = create_yum_repo(cls.pulp, source_repo_name, default_repo_config.feed)
        Task.wait_for_report(cls.pulp, cls.source_repo.sync(cls.pulp))
Exemplo n.º 46
0
    def test_06_child_repo_content(self):
        # access the content of the pulp_child node
        # please note when the repo is created on the other node,
        # the distributor id used by default is yum_distributor

        # make sure the repo was published on the child node
        # the repo ID and distributor ID are the same on both the nodes
        child_repo = Repo.get(self.pulp_child, self.repo.id)
        response = child_repo.publish(self.pulp_child, self.distributor.id)
        assert response == ResponseLike(
            202), 'wrong response from the child node: %s' % response
        Task.wait_for_report(self.pulp_child, response)

        # fetch the repo content url on the child node
        repo_url = pulp_repo_url(self.pulp_child, self.repo.id)
        assert repo_url, 'invalid repo id on pulp_child node'
        # try accessing the content on the child node
        pkg_name = download_package_with_dnf(self.pulp_child, repo_url, 'bear')
        assert pkg_name == 'bear', 'not able to acces bear rpm on the child node'
Exemplo n.º 47
0
 def setUpClass(cls):
     super(UnitSearchTest, cls).setUpClass()
     #create and sync puppet repo
     # FIXME: hardwired role details
     repo = {
         'id': cls.__name__,
         'queries': ['jenkins'],
         'feed': 'https://forge.puppetlabs.com',
         'proxy': ROLES.get('proxy'),
     }
     # make sure we run clean
     response = Repo({'id': repo['id']}).delete(cls.pulp)
     if response == ResponseLike(202):
         Task.wait_for_report(cls.pulp, response)
     cls.repo1, _, _ = PuppetRepo.from_role(repo).create(cls.pulp)
     Task.wait_for_report(cls.pulp, cls.repo1.sync(cls.pulp))
     # create and sync rpm repo
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     cls.repo2, _, _ = YumRepo.from_role(repo_config).create(cls.pulp)
     Task.wait_for_report(cls.pulp, cls.repo2.sync(cls.pulp))
 def test_05_search_repo_with_regexp(self):
     #search puppet-repos with .*repo.*
     repo = Repo.search(self.pulp,
                        data={
                            "criteria": {
                                "sort": None,
                                "fields": None,
                                "limit": None,
                                "filters": {
                                    "$and": [{
                                        "notes._repo-type":
                                        "puppet-repo"
                                    }, {
                                        "id": {
                                            "$regex": ".*Repo.*"
                                        }
                                    }]
                                },
                                "skip": None
                            }
                        })
     #asserting to 2 as we have two repos matched the pattern
     self.assertTrue(len(repo) == 2)
Exemplo n.º 49
0
 def test_07_associate_importer(self):
     response = self.repo.associate_importer(
         self.pulp,
         data={
             'importer_type_id': 'yum_importer',
             'importer_config': {
                 'feed': self.feed
             }
         }
     )
     self.assertPulp(code=202)
     importer = Repo.from_report(response)['result']
     Task.wait_for_report(self.pulp, response)
     #https://bugzilla.redhat.com/show_bug.cgi?id=1076225
     self.assertEqual({
             'id': 'yum_importer',
             'importer_type_id': 'yum_importer',
             'repo_id': self.repo.id,
             'config': {
                 'feed': self.feed
             },
             'last_sync': None
         },
         importer)
Exemplo n.º 50
0
 def test_05_associate_importer(self):
     response = self.repo.associate_importer(
         self.pulp,
         data={
             'importer_type_id': 'iso_importer',
             'importer_config': {
                 'feed': self.feed
             }
         }
     )
     self.assertPulp(code=202)
     importer = Repo.from_report(response)['result']
     self.assertEqual(
         importer,
         {
             'id': 'iso_importer',
             'importer_type_id': 'iso_importer',
             'repo_id': self.repo.id,
             'config': {
                 'feed': self.feed
             },
             'last_sync': None
         }
     )
    def setUpClass(cls):
        super(SimpleRepoCopyTest, cls).setUpClass()
        #Destination repo
        # make sure repos don't exist
        # no need to wait for repos.delete to happen
        dest_repo_name = cls.__name__ + '_copy'
        dest_repo1 = Repo({'id': dest_repo_name})
        dest_repo1.delete(cls.pulp)
        cls.dest_repo1, _, _ = YumRepo(id=dest_repo_name, importer=YumImporter(None),
                                distributors=[YumDistributor(relative_url='abc')]).create(cls.pulp)

        #2nd Destination Repo
        dest_repo_name = cls.__name__ + '_copy1'
        dest_repo2 = Repo({'id': dest_repo_name})
        dest_repo2.delete(cls.pulp)
        cls.dest_repo2, _, _ = YumRepo(id=dest_repo_name, importer=YumImporter(None),
                                distributors=[YumDistributor(relative_url='xyz')]).create(cls.pulp)

        # Source repo
        default_repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
        cls.source_repo, _, _ = YumRepo.from_role(default_repo_config).create(cls.pulp)
        Task.wait_for_report(cls.pulp, cls.source_repo.sync(cls.pulp))
Exemplo n.º 52
0
 def test_04_update_repo(self):
     display_name = 'A %s repo' % self.__class__.__name__
     self.repo |= {'display_name': display_name}
     self.repo.update(self.pulp)
     self.assertPulp(code=200)
     self.assertEqual(Repo.get(self.pulp, self.repo.id).data['display_name'], display_name)
Exemplo n.º 53
0
 def test_03_list_repos(self):
     repos = Repo.list(self.pulp)
     self.assertIn(self.repo, repos)
Exemplo n.º 54
0
 def test_02_get_repo(self):
     repo = Repo.get(self.pulp, self.repo.id)
     self.assertEqual(repo.id, self.repo.id)
     self.repo.reload(self.pulp)
     self.assertEqual(self.repo, repo)
Exemplo n.º 55
0
 def test_03_search_erratum(self):
     unit = ErratumUnit.search(self.pulp, data={"criteria": {"filters": {}, "fields": ["name", "_content_type_id"]}})
     repo2 = Repo.get(self.pulp, self.repo2.id)
     # assert that number of errata _eq_ to the number repo contains
     self.assertEqual(len(unit), repo2.data['content_unit_counts']['erratum'])
 def test_07_check_role_permission(self):
     # check that user cannot access resource as permissions of the role were revoked
     with self.assertRaises(AssertionError):
         with self.user_pulp.asserting(True):
             Repo.list(self.user_pulp)
 def test_02_check_all_iso_copied(self):
     source_repo = Repo.get(self.pulp, self.source_repo.id)
     dest_repo1 = Repo.get(self.pulp, self.dest_repo1.id)
     #check that the number of puppet modules are the same
     self.assertEqual(source_repo.data['content_unit_counts'], dest_repo1.data['content_unit_counts'])
Exemplo n.º 58
0
 def test_04_check_update_was_correct(self):
     self.assertEqual(Repo.get(self.pulp, self.repo.id).data['display_name'], "NewName")
     importer = self.repo.get_importer(self.pulp, "yum_importer")
     self.assertEqual(importer.data["config"]["num_units"], 6)
     distributor = self.repo.get_distributor(self.pulp, "yum_distributor")
     self.assertEqual(distributor.data["config"]["relative_url"], "my_url")
 def test_03_check_user_permission(self):
     #check that user can access resource on which permissions were granted
     with self.user_pulp.asserting(True):
         Repo.list(self.user_pulp)