Exemplo n.º 1
0
    def test_positive_delete(self):
        """Create a filter and delete it afterwards.

        :id: 97d1093c-0d49-454b-86f6-f5be87b32775

        :expectedresults: The deleted filter cannot be fetched.

        :CaseImportance: Critical
        """
        filter_ = make_filter({'role-id': self.role['id'], 'permissions': self.perms})
        Filter.delete({'id': filter_['id']})
        with self.assertRaises(CLIReturnCodeError):
            Filter.info({'id': filter_['id']})
Exemplo n.º 2
0
    def test_positive_delete(self):
        """Create a filter and delete it afterwards.

        @id: 97d1093c-0d49-454b-86f6-f5be87b32775

        @Assert: The deleted filter cannot be fetched.
        """
        filter_ = make_filter({
            'role-id': self.role['id'],
            'permissions': self.perms,
        })
        Filter.delete({'id': filter_['id']})
        with self.assertRaises(CLIReturnCodeError):
            Filter.info({'id': filter_['id']})
Exemplo n.º 3
0
    def test_positive_delete(self):
        """Create a filter and delete it afterwards.

        @id: 97d1093c-0d49-454b-86f6-f5be87b32775

        @Assert: The deleted filter cannot be fetched.
        """
        filter_ = make_filter({
            'role-id': self.role['id'],
            'permissions': self.perms,
        })
        Filter.delete({'id': filter_['id']})
        with self.assertRaises(CLIReturnCodeError):
            Filter.info({'id': filter_['id']})
Exemplo n.º 4
0
def test_positive_update_org_loc(module_perms, function_role):
    """Create a filter and assign it to another organization and location.

    :id: 9bb59109-9701-4ef3-95c6-81f387d372da

    :expectedresults: Filter is created and assigned to new org and loc.

    :BZ: 1401469

    :CaseImportance: Critical
    """
    org = make_org()
    loc = make_location()
    filter_ = make_filter({
        'role-id': function_role['id'],
        'permissions': module_perms,
        'organization-ids': org['id'],
        'location-ids': loc['id'],
        'override': 1,
    })
    # Update org and loc
    new_org = make_org()
    new_loc = make_location()
    Filter.update({
        'id': filter_['id'],
        'permissions': module_perms,
        'organization-ids': new_org['id'],
        'location-ids': new_loc['id'],
        'override': 1,
    })
    filter_ = Filter.info({'id': filter_['id']})
    # We expect here only one organization and location
    assert filter_['organizations'][0] == new_org['name']
    assert filter_['locations'][0] == new_loc['name']
Exemplo n.º 5
0
    def test_positive_update_org_loc(self):
        """Create a filter and assign it to another organization and location.

         @id: 9bb59109-9701-4ef3-95c6-81f387d372da

         @Assert: Filter is created and assigned to new org and loc.
         """
        org = make_org()
        loc = make_location()
        filter_ = make_filter({
            'role-id': self.role['id'],
            'permissions': self.perms,
            'organization-ids': org['id'],
            'location-ids': loc['id']
        })
        # Update org and loc
        new_org = make_org()
        new_loc = make_location()
        Filter.update({
            'id': filter_['id'],
            'permissions': self.perms,
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id']
        })
        filter_ = Filter.info({'id': filter_['id']})
        # We expect here only one organization and location
        self.assertEqual(filter_['organizations'][0], new_org['name'])
        self.assertEqual(filter_['locations'][0], new_loc['name'])
Exemplo n.º 6
0
    def test_positive_update_permissions(self):
        """Create a filter and update its permissions.

        @id: 3d6a52d8-2f8f-4f97-a155-9b52888af16e

        @Assert: Permissions updated.
        """
        filter_ = make_filter({
            'role-id': self.role['id'],
            'permissions': self.perms,
        })
        new_perms = [
            permission['name']
            for permission in Filter.available_permissions(
                {'resource-type': 'User'})
            ]
        Filter.update({
            'id': filter_['id'],
            'permissions': new_perms
        })
        filter_ = Filter.info({'id': filter_['id']})
        self.assertEqual(
            set(filter_['permissions'].split(", ")),
            set(new_perms)
        )
Exemplo n.º 7
0
    def test_positive_update_org_loc(self):
        """Create a filter and assign it to another organization and location.

         @id: 9bb59109-9701-4ef3-95c6-81f387d372da

         @Assert: Filter is created and assigned to new org and loc.
         """
        org = make_org()
        loc = make_location()
        filter_ = make_filter({
            'role-id': self.role['id'],
            'permissions': self.perms,
            'organization-ids': org['id'],
            'location-ids': loc['id']
        })
        # Update org and loc
        new_org = make_org()
        new_loc = make_location()
        Filter.update({
            'id': filter_['id'],
            'permissions': self.perms,
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id']
        })
        filter_ = Filter.info({'id': filter_['id']})
        # We expect here only one organization and location
        self.assertEqual(filter_['organizations'][0], new_org['name'])
        self.assertEqual(filter_['locations'][0], new_loc['name'])
Exemplo n.º 8
0
    def test_positive_update_permissions(self):
        """Create a filter and update its permissions.

        :id: 3d6a52d8-2f8f-4f97-a155-9b52888af16e

        :expectedresults: Permissions updated.

        :CaseImportance: Critical
        """
        filter_ = make_filter({
            'role-id': self.role['id'],
            'permissions': self.perms,
        })
        new_perms = [
            permission['name']
            for permission in Filter.available_permissions(
                {'resource-type': 'User'})
            ]
        Filter.update({
            'id': filter_['id'],
            'permissions': new_perms
        })
        filter_ = Filter.info({'id': filter_['id']})
        self.assertEqual(
            set(filter_['permissions'].split(", ")),
            set(new_perms)
        )
Exemplo n.º 9
0
    def test_positive_delete_role(self):
        """Create a filter and delete the role it points at.

        :id: e2adb6a4-e408-4912-a32d-2bf2c43187d9

        :expectedresults: The filter cannot be fetched.

        :CaseImportance: Critical
        """
        filter_ = make_filter({'role-id': self.role['id'], 'permissions': self.perms})

        # A filter depends on a role. Deleting a role implicitly deletes the
        # filter pointing at it.
        Role.delete({'id': self.role['id']})
        with self.assertRaises(CLIReturnCodeError):
            Role.info({'id': self.role['id']})
        with self.assertRaises(CLIReturnCodeError):
            Filter.info({'id': filter_['id']})
Exemplo n.º 10
0
    def test_positive_delete_role(self):
        """Create a filter and delete the role it points at.

        @id: e2adb6a4-e408-4912-a32d-2bf2c43187d9

        @Assert: The filter cannot be fetched.
        """
        filter_ = make_filter({
            'role-id': self.role['id'],
            'permissions': self.perms,
        })

        # A filter depends on a role. Deleting a role implicitly deletes the
        # filter pointing at it.
        Role.delete({'id': self.role['id']})
        with self.assertRaises(CLIReturnCodeError):
            Role.info({'id': self.role['id']})
        with self.assertRaises(CLIReturnCodeError):
            Filter.info({'id': filter_['id']})
Exemplo n.º 11
0
    def test_positive_update_role(self):
        """Create a filter and assign it to another role.

        :id: 2950b3a1-2bce-447f-9df2-869b1d10eaf5

        :expectedresults: Filter is created and assigned to new role.

        :CaseImportance: Critical
        """
        filter_ = make_filter({'role-id': self.role['id'], 'permissions': self.perms})
        # Update with another role
        new_role = make_role()
        Filter.update({'id': filter_['id'], 'role-id': new_role['id']})
        filter_ = Filter.info({'id': filter_['id']})
        self.assertEqual(filter_['role'], new_role['name'])
Exemplo n.º 12
0
    def test_positive_update_role(self):
        """Create a filter and assign it to another role.

        @id: 2950b3a1-2bce-447f-9df2-869b1d10eaf5

        @Assert: Filter is created and assigned to new role.
        """
        filter_ = make_filter({
            'role-id': self.role['id'],
            'permissions': self.perms,
        })
        # Update with another role
        new_role = make_role()
        Filter.update({
            'id': filter_['id'],
            'role-id': new_role['id'],
        })
        filter_ = Filter.info({'id': filter_['id']})
        self.assertEqual(filter_['role'], new_role['name'])
Exemplo n.º 13
0
def test_positive_update_permissions(module_perms, function_role):
    """Create a filter and update its permissions.

    :id: 3d6a52d8-2f8f-4f97-a155-9b52888af16e

    :expectedresults: Permissions updated.

    :CaseImportance: Critical
    """
    filter_ = make_filter({
        'role-id': function_role['id'],
        'permissions': module_perms
    })
    new_perms = [
        permission['name'] for permission in Filter.available_permissions(
            {"search": "resource_type=User"})
    ]
    Filter.update({'id': filter_['id'], 'permissions': new_perms})
    filter_ = Filter.info({'id': filter_['id']})
    assert set(filter_['permissions'].split(", ")) == set(new_perms)
Exemplo n.º 14
0
    def test_system_admin_role_end_to_end(self):
        """Test System admin role with a end to end workflow

        :id: da6b3549-d1cf-44fc-869f-08d15d407fa2

        :steps:

            1. Create a System admin role user1
            2. Login with the user1 and change global settings
                "Out of sync interval" to 31
            3. Create user2 with system admin role
            4. Login with user2 to create a Organization
            5. Clone a Org-admin role
            6. Edit the Architecture Filter and search name  =  x86_64
            7. Create a User with Cloned Org admin
            8. Login with user.

        :expectedresults:

            1. User should be assigned with System Admin role.
            2. User with sys admin role should be able to update settings
            3. User with sys admin role should be able to create users and
                assign Organizations to them.
            4. System Admin role should be able to create Organization admins
            5. User with sys admin role should be able to edit filters on roles

        :CaseLevel: System
        """
        org = make_org()
        location = make_location()
        common_pass = gen_string('alpha')
        role = Role.info({'name': 'System admin'})
        system_admin_1 = make_user(
            {
                'password': common_pass,
                'organization-ids': org['id'],
                'location-ids': location['id'],
            }
        )
        User.add_role({'id': system_admin_1['id'], 'role-id': role['id']})
        Settings.with_user(username=system_admin_1['login'], password=common_pass).set(
            {'name': "outofsync_interval", 'value': "32"}
        )
        sync_time = Settings.list({'search': 'name=outofsync_interval'})[0]
        # Asserts if the setting was updated successfully
        assert '32' == sync_time['value']

        # Create another System Admin user using the first one
        system_admin = User.with_user(
            username=system_admin_1['login'], password=common_pass
        ).create(
            {
                'auth-source-id': 1,
                'firstname': gen_string('alpha'),
                'lastname': gen_string('alpha'),
                'login': gen_string('alpha'),
                'mail': '{}@example.com'.format(gen_string('alpha')),
                'password': common_pass,
                'organizations': org['name'],
                'role-ids': role['id'],
                'locations': location['name'],
            }
        )
        # Create the Org Admin user
        org_role = Role.with_user(username=system_admin['login'], password=common_pass).clone(
            {
                'name': 'Organization admin',
                'new-name': gen_string('alpha'),
                'organization-ids': org['id'],
                'location-ids': location['id'],
            }
        )
        org_admin = User.with_user(username=system_admin['login'], password=common_pass).create(
            {
                'auth-source-id': 1,
                'firstname': gen_string('alpha'),
                'lastname': gen_string('alpha'),
                'login': gen_string('alpha'),
                'mail': '{}@example.com'.format(gen_string('alpha')),
                'password': common_pass,
                'organizations': org['name'],
                'role-ids': org_role['id'],
                'location-ids': location['id'],
            }
        )
        # Assert if the cloning was successful
        assert org_role['id'] is not None
        org_role_filters = Role.filters({'id': org_role['id']})
        search_filter = None
        for arch_filter in org_role_filters:
            if arch_filter['resource-type'] == 'Architecture':
                search_filter = arch_filter
                break
        Filter.with_user(username=system_admin['login'], password=common_pass).update(
            {'role-id': org_role['id'], 'id': arch_filter['id'], 'search': 'name=x86_64'}
        )
        # Asserts if the filter is updated
        assert 'name=x86_64' in Filter.info({'id': search_filter['id']}).values()
        org_admin = User.with_user(username=system_admin['login'], password=common_pass).info(
            {'id': org_admin['id']}
        )
        # Asserts Created Org Admin
        assert org_role['name'] in org_admin['roles']
        assert org['name'] in org_admin['organizations']
Exemplo n.º 15
0
    def test_system_admin_role_end_to_end(self):
        """Test System admin role with a end to end workflow

        :id: da6b3549-d1cf-44fc-869f-08d15d407fa2

        :steps:

            1. Create a System admin role user1
            2. Login with the user1 and change global settings
                "Out of sync interval" to 31
            3. Create user2 with system admin role
            4. Login with user2 to create a Organization
            5. Clone a Org-admin role
            6. Edit the Architecture Filter and search name  =  x86_64
            7. Create a User with Cloned Org admin
            8. Login with user.

        :expectedresults:

            1. User should be assigned with System Admin role.
            2. User with sys admin role should be able to update settings
            3. User with sys admin role should be able to create users and
                assign Organizations to them.
            4. System Admin role should be able to create Organization admins
            5. User with sys admin role should be able to edit filters on roles

        :CaseLevel: System
        """
        org = make_org()
        location = make_location()
        common_pass = gen_string('alpha')
        role = Role.info({'name': 'System admin'})
        system_admin_1 = make_user({
            'password': common_pass,
            'organization-ids': org['id'],
            'location-ids': location['id']
            })
        User.add_role({
            'id': system_admin_1['id'],
            'role-id': role['id']
            })
        Settings.with_user(
            username=system_admin_1['login'],
            password=common_pass).set({
                'name': "outofsync_interval",
                'value': "32"
                })
        sync_time = Settings.list({
            'search': 'name=outofsync_interval'
            })[0]
        # Asserts if the setting was updated successfully
        self.assertEqual('32', sync_time['value'])

        # Create another System Admin user using the first one
        system_admin = User.with_user(
                username=system_admin_1['login'],
                password=common_pass).create({
                    u'auth-source-id': 1,
                    u'firstname': gen_string('alpha'),
                    u'lastname': gen_string('alpha'),
                    u'login': gen_string('alpha'),
                    u'mail': '{0}@example.com'.format(gen_string('alpha')),
                    u'password': common_pass,
                    u'organizations': org['name'],
                    u'role-ids': role['id'],
                    u'locations': location['name']
                    })
        # Create the Org Admin user
        org_role = Role.with_user(
            username=system_admin['login'],
            password=common_pass).clone({
                'name': 'Organization admin',
                'new-name': gen_string('alpha'),
                'organization-ids': org['id'],
                'location-ids': location['id']
                })
        org_admin = User.with_user(
                username=system_admin['login'],
                password=common_pass).create({
                    u'auth-source-id': 1,
                    u'firstname': gen_string('alpha'),
                    u'lastname': gen_string('alpha'),
                    u'login': gen_string('alpha'),
                    u'mail': '{0}@example.com'.format(gen_string('alpha')),
                    u'password': common_pass,
                    u'organizations': org['name'],
                    u'role-ids': org_role['id'],
                    u'location-ids': location['id']
                    })
        # Assert if the cloning was successful
        self.assertIsNotNone(org_role['id'])
        org_role_filters = Role.filters({'id': org_role['id']})
        search_filter = None
        for arch_filter in org_role_filters:
            if arch_filter['resource-type'] == 'Architecture':
                search_filter = arch_filter
                break
        Filter.with_user(
            username=system_admin['login'],
            password=common_pass).update({
                'role-id': org_role['id'],
                'id': arch_filter['id'],
                'search': 'name=x86_64'
                })
        # Asserts if the filter is updated
        self.assertIn('name=x86_64',
                      Filter.info({
                          'id': search_filter['id']
                            }).values()
                      )
        org_admin = User.with_user(
            username=system_admin['login'],
            password=common_pass).info({'id': org_admin['id']})
        # Asserts Created Org Admin
        self.assertIn(org_role['name'], org_admin['roles'])
        self.assertIn(org['name'], org_admin['organizations'])