def setUpClass(cls):
        super(RolePermissionTest, cls).setUpClass()
        cls.user = User(
            data={
                "login": cls.__name__ + "_user",
                "name": cls.__name__,
                "password": cls.__name__
            })
        cls.user2 = User(
            data={
                "login": cls.__name__ + "_user2",
                "name": cls.__name__,
                "password": cls.__name__
            })
        cls.permission = Permission(data={"resource": "/v2/actions/login/"})
        # a new session has to be created for the user as auth credeantials of admin are used by default
        cls.user_pulp = Pulp(cls.pulp.url,
                             auth=(cls.user.data['login'],
                                   cls.user.data['password']))
        cls.user_pulp2 = Pulp(cls.pulp.url,
                              auth=(cls.user2.data['login'],
                                    cls.user2.data['password']))

        # create roles
        with cls.pulp.asserting(True):
            response = Role.create(cls.pulp,
                                   data={'role_id': cls.__name__ + "_role"})
        cls.role = Role.from_response(response)

        with cls.pulp.asserting(True):
            response = Role.create(cls.pulp,
                                   data={'role_id': cls.__name__ + "_role2"})
        cls.role2 = Role.from_response(response)
Beispiel #2
0
    def setUpClass(cls):
        super(RoleTest, cls).setUpClass()

        # create roles
        with cls.pulp.asserting(True):
            response = Role.create(cls.pulp, data={'role_id': cls.__name__ + "_role"})
        cls.role = Role.from_response(response)

        with cls.pulp.asserting(True):
            response2 = Role.create(cls.pulp, data={'role_id': cls.__name__ + "_role2"})
        cls.role2 = Role.from_response(response2)

        # users
        cls.user = User(data={"login": cls.__name__ + "_user", "name": cls.__name__, "password": cls.__name__})
        cls.user2 = User(data={"login": cls.__name__ + "_user2", "name": cls.__name__, "password": cls.__name__})
    def setUpClass(cls):
        super(RolePermissionTest, cls).setUpClass()
        cls.user = User(data={"login": cls.__name__ + "_user", "name": cls.__name__, "password": cls.__name__})
        cls.user2 = User(data={"login": cls.__name__ + "_user2", "name": cls.__name__, "password": cls.__name__})
        cls.permission = Permission(data={"resource": "/v2/actions/login/"})
        # a new session has to be created for the user as auth credeantials of admin are used by default
        cls.user_pulp = Pulp(cls.pulp.url, auth=(cls.user.data['login'], cls.user.data['password']))
        cls.user_pulp2 = Pulp(cls.pulp.url, auth=(cls.user2.data['login'], cls.user2.data['password']))

        # create roles
        with cls.pulp.asserting(True):
            response = Role.create(cls.pulp, data={'role_id': cls.__name__ + "_role"})
        cls.role = Role.from_response(response)

        with cls.pulp.asserting(True):
            response = Role.create(cls.pulp, data={'role_id': cls.__name__ + "_role2"})
        cls.role2 = Role.from_response(response)
 def test_05_update_role(self):
     display_name = 'A %s role' % self.__class__.__name__
     self.role |= {'display_name': display_name}
     self.role.delta_update(self.pulp)
     self.assertPulp(code=200)
     self.assertEqual(
         Role.get(self.pulp, self.role.id).data['display_name'],
         display_name)
Beispiel #5
0
 def test_05_remove_user(self):
     # remove user from the role
     self.role.remove_user(
         self.pulp,
         self.user.data['login']
     )
     self.assertPulp(code=200)
     self.assertEqual(Role.get(self.pulp, self.role.id).data['users'], [])
    def test_07_add_user(self):
        # create user
        self.user.create(self.pulp)
        self.assertPulpOK()

        # add user to the role
        self.role.add_user(self.pulp, self.user.id)
        self.assertPulp(code=200)
        self.assertEqual(
            Role.get(self.pulp, self.role.id).data['users'], [self.user.id])
    def test_07_add_user(self):
        # create user
        self.user.create(self.pulp)
        self.assertPulpOK()

        # add user to the role
        self.role.add_user(
            self.pulp,
            self.user.id
        )
        self.assertPulp(code=200)
        self.assertEqual(Role.get(self.pulp, self.role.id).data['users'], [self.user.id])
Beispiel #8
0
    def test_04_add_user(self):
        # create user
        self.user.create(self.pulp)
        self.assertPulpOK()

        # add user to the role
        self.role.add_user(
            self.pulp,
            data={'login': self.user.data['login']}
        )
        self.assertPulp(code=200)
        self.assertEqual(Role.get(self.pulp, self.role.id).data['users'], [self.user.data['login']])
Beispiel #9
0
 def test_03_update_role(self):
     display_name = 'A %s role' % self.__class__.__name__
     self.role |= {'display_name': display_name}
     self.role.update(self.pulp)
     self.assertPulp(code=200)
     self.assertEqual(Role.get(self.pulp, self.role.id).data['display_name'], display_name)
Beispiel #10
0
 def test_01_get_role(self):
     self.assertEqual(self.role, Role.get(self.pulp, self.role.id))
     self.assertEqual(self.role2, Role.get(self.pulp, self.role2.id))
Beispiel #11
0
 def test_02_list_roles(self):
     self.assertIn(self.role, Role.list(self.pulp))
     self.assertIn(self.role2, Role.list(self.pulp))
 def test_02_get_role(self):
     self.assertEqual(self.role, Role.get(self.pulp, self.role.id))
     self.assertEqual(self.role2, Role.get(self.pulp, self.role2.id))
 def test_01_no_dupl_role(self):
     Role.create(self.pulp, data={'role_id': self.role.id})
     self.assertPulp(code=409)
 def test_03_get_unexistant_role(self):
     with self.assertRaises(AssertionError):
         Role.get(self.pulp, 'some_id')
     self.assertPulp(code=404)
 def test_09_remove_user(self):
     # remove user from the role
     self.role.remove_user(self.pulp, self.user.id)
     self.assertPulp(code=200)
     self.assertEqual(Role.get(self.pulp, self.role.id).data['users'], [])
Beispiel #16
0
 def test_03_get_unexistant_role(self):
     with self.assertRaises(AssertionError):
         Role.get(self.pulp, 'some_id')
     self.assertPulp(code=404)
Beispiel #17
0
 def test_01_no_dupl_role(self):
     Role.create(self.pulp, data={'role_id': self.role.id})
     self.assertPulp(code=409)
 def test_04_list_roles(self):
     self.assertIn(self.role, Role.list(self.pulp))
     self.assertIn(self.role2, Role.list(self.pulp))