コード例 #1
0
    def test_positive_generate_with_name_and_org(self):
        """Generate Host Status report, specifying template name and organization

        :id: 5af03399-b918-468a-1306-1c76dda6f369

        :setup: User with reporting access rights, some report template, some host

        :steps:

            0. use default report template called Host - Statuses
            1. hammer report-template generate --name ... --organization ...

        :expectedresults: Report successfully generated (in BZ, it results in
            "ERF42-5227 [Foreman::Exception]: unknown parent permission for
            api/v2/report_templates#generate")

        :CaseImportance: Medium

        :BZ: 1750924
        """
        host_name = gen_string('alpha')
        host = make_fake_host({'name': host_name})

        # make sure the template is in the default org
        org_names = ReportTemplate.info({'name': 'Host - Statuses'})['organizations']
        default_org = Org.info({'name': DEFAULT_ORG})
        if default_org['name'] not in org_names:
            org_ids = [Org.info({'name': org_name})['id'] for org_name in org_names]
            org_ids.append(default_org['id'])
            ReportTemplate.update({'name': 'Host - Statuses', 'organization-ids': org_ids})

        result = ReportTemplate.generate({'name': 'Host - Statuses', 'organization': DEFAULT_ORG})

        self.assertIn(host['name'], [item.split(',')[0] for item in result])
コード例 #2
0
ファイル: test_auth.py プロジェクト: renzon/robottelo
    def test_positive_session_survives_unauthenticated_call(self):
        """Check if session stays up after unauthenticated call

        :id: 8bc304a0-70ea-489c-9c3f-ea8343c5284c

        :Steps:

            1. Set use_sessions
            2. Authenticate, assert credentials are not demanded
               on next command run
            3. Run `hammer ping`

        :expectedresults: The session is unchanged

        """
        result = configure_sessions()
        self.assertEqual(result, 0, 'Failed to configure hammer sessions')
        Auth.login({'username': self.uname_admin, 'password': self.password})
        result = Auth.with_user().status()
        self.assertIn(LOGEDIN_MSG.format(self.uname_admin),
                      result[0][u'message'])
        # list organizations without supplying credentials
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
        result = ssh.command('hammer ping')
        self.assertEqual(result.return_code, 0, 'Failed to run hammer ping')
        result = Auth.with_user().status()
        self.assertIn(LOGEDIN_MSG.format(self.uname_admin),
                      result[0][u'message'])
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
コード例 #3
0
ファイル: test_auth.py プロジェクト: JacobCallahan/robottelo
    def test_positive_change_session(self):
        """Change from existing session to a different session

        :id: b6ea6f3c-fcbd-4e7b-97bd-f3e0e6b9da8f

        :Steps:

            1. Set use_sessions
            2. Authenticate, assert credentials are not demanded
               on next command run
            3. Login as a different user

        :expectedresults: The session is altered

        """
        result = configure_sessions()
        self.assertEqual(result, 0, 'Failed to configure hammer sessions')
        Auth.login({'username': self.uname_admin, 'password': self.password})
        result = Auth.with_user().status()
        self.assertIn(
            LOGEDIN_MSG.format(self.uname_admin),
            result[0][u'message']
        )
        # list organizations without supplying credentials
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
        Auth.login({'username': self.uname_viewer, 'password': self.password})
        result = Auth.with_user().status()
        self.assertIn(
            LOGEDIN_MSG.format(self.uname_viewer),
            result[0][u'message']
        )
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
コード例 #4
0
    def test_negative_create_same_name(self):
        """Create organization with valid values, then create a new one with
        same values

        @feature: Organization

        @assert: organization is not created
        """
        for desc, name, label in zip(
                valid_data_list(),
                valid_org_names_list(),
                cycle(valid_labels_list()),
        ):
            with self.subTest(desc + name + label):
                Org.create({
                    'description': desc,
                    'label': label,
                    'name': name,
                })
                with self.assertRaises(CLIReturnCodeError):
                    Org.create({
                        'description': desc,
                        'label': label,
                        'name': name,
                    })
コード例 #5
0
ファイル: test_auth.py プロジェクト: JacobCallahan/robottelo
    def test_positive_log_out_from_session(self):
        """Check if session is terminated when user logs out

        :id: 0ba05f2d-7b83-4b0c-a04c-80e62b7c4cf2

        :Steps:

            1. Set use_sessions
            2. Authenticate, assert credentials are not demanded
               on next command run
            3. Run `hammer auth logout`

        :expectedresults: The session is terminated

        """
        result = configure_sessions()
        self.assertEqual(result, 0, 'Failed to configure hammer sessions')
        Auth.login({'username': self.uname_admin, 'password': self.password})
        result = Auth.with_user().status()
        self.assertIn(
            LOGEDIN_MSG.format(self.uname_admin),
            result[0][u'message']
        )
        # list organizations without supplying credentials
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
        Auth.logout()
        result = Auth.with_user().status()
        self.assertIn(
            LOGEDOFF_MSG.format(self.uname_admin),
            result[0][u'message']
        )
        with self.assertRaises(CLIReturnCodeError):
            Org.with_user().list()
コード例 #6
0
    def test_positive_remove_compresource_by_name(self):
        """Remove a compute resource from organization by its name

        @id: 1b1313a8-8326-4b33-8113-17c5cf0d4ffb

        @Assert: Compute resource is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        compute_res = make_compute_resource({
            'provider': FOREMAN_PROVIDERS['libvirt'],
            'url': u'qemu+ssh://root@{0}/system'.format(
                settings.compute_resources.libvirt_hostname
            )
        })
        Org.add_compute_resource({
            'compute-resource': compute_res['name'],
            'name': org['name'],
        })
        Org.remove_compute_resource({
            'compute-resource': compute_res['name'],
            'name': org['name'],
        })
        org = Org.info({'name': org['name']})
        self.assertNotIn(compute_res['name'], org['compute-resources'])
コード例 #7
0
    def test_positive_add_template_by_name(self):
        """Add a provisioning template to organization by its name

        @id: bd46a192-488f-4da0-bf47-1f370ae5f55c

        @Assert: Template is added to the org

        @CaseLevel: Integration
        """
        for name in valid_data_list():
            with self.subTest(name):
                org = make_org()
                template = make_template({
                    'content': gen_string('alpha'),
                    'name': name,
                })
                Org.add_config_template({
                    'config-template': template['name'],
                    'name': org['name'],
                })
                org = Org.info({'name': org['name']})
                self.assertIn(
                    u'{0} ({1})'. format(template['name'], template['type']),
                    org['templates']
                )
コード例 #8
0
    def test_positive_remove_compresource_by_id(self):
        """Remove a compute resource from organization by its ID

        @id: 415c14ab-f879-4ed8-9ba7-8af4ada2e277

        @Assert: Compute resource is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        compute_res = make_compute_resource({
            'provider': FOREMAN_PROVIDERS['libvirt'],
            'url': u'qemu+ssh://root@{0}/system'.format(
                settings.compute_resources.libvirt_hostname
            )
        })
        Org.add_compute_resource({
            'compute-resource-id': compute_res['id'],
            'id': org['id'],
        })
        Org.remove_compute_resource({
            'compute-resource-id': compute_res['id'],
            'id': org['id'],
        })
        org = Org.info({'id': org['id']})
        self.assertNotIn(compute_res['name'], org['compute-resources'])
コード例 #9
0
    def test_positive_remove_capsule_by_name(self):
        """Remove a capsule from organization by its name

        @id: f56eaf46-fef5-4b52-819f-e30e61f0ec4a

        @Assert: Capsule is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        proxy = make_proxy()
        # Add capsule and org to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
        self.addCleanup(org_cleanup, org['id'])

        Org.add_smart_proxy({
            'name': org['name'],
            'smart-proxy': proxy['name'],
        })
        Org.remove_smart_proxy({
            'name': org['name'],
            'smart-proxy': proxy['name'],
        })
        org = Org.info({'name': org['name']})
        self.assertNotIn(proxy['name'], org['smart-proxies'])
コード例 #10
0
    def test_positive_remove_capsule_by_id(self):
        """Remove a capsule from organization by its id

        @id: 71af64ec-5cbb-4dd8-ba90-652e302305ec

        @Assert: Capsule is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        proxy = make_proxy()
        # Add capsule and org to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
        self.addCleanup(org_cleanup, org['id'])

        Org.add_smart_proxy({
            'id': org['id'],
            'smart-proxy-id': proxy['id'],
        })
        Org.remove_smart_proxy({
            'id': org['id'],
            'smart-proxy-id': proxy['id'],
        })
        org = Org.info({'id': org['id']})
        self.assertNotIn(proxy['name'], org['smart-proxies'])
コード例 #11
0
ファイル: test_auth.py プロジェクト: JacobCallahan/robottelo
    def test_positive_session_survives_unauthenticated_call(self):
        """Check if session stays up after unauthenticated call

        :id: 8bc304a0-70ea-489c-9c3f-ea8343c5284c

        :Steps:

            1. Set use_sessions
            2. Authenticate, assert credentials are not demanded
               on next command run
            3. Run `hammer ping`

        :expectedresults: The session is unchanged

        """
        result = configure_sessions()
        self.assertEqual(result, 0, 'Failed to configure hammer sessions')
        Auth.login({'username': self.uname_admin, 'password': self.password})
        result = Auth.with_user().status()
        self.assertIn(
            LOGEDIN_MSG.format(self.uname_admin),
            result[0][u'message']
        )
        # list organizations without supplying credentials
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
        result = ssh.command('hammer ping')
        self.assertEqual(result.return_code, 0, 'Failed to run hammer ping')
        result = Auth.with_user().status()
        self.assertIn(
            LOGEDIN_MSG.format(self.uname_admin),
            result[0][u'message']
        )
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
コード例 #12
0
    def test_positive_remove_capsule_by_id(self):
        """Remove a capsule from organization by its id

        @id: 71af64ec-5cbb-4dd8-ba90-652e302305ec

        @Assert: Capsule is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        proxy = make_proxy()
        # Add capsule and org to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
        self.addCleanup(org_cleanup, org['id'])

        Org.add_smart_proxy({
            'id': org['id'],
            'smart-proxy-id': proxy['id'],
        })
        Org.remove_smart_proxy({
            'id': org['id'],
            'smart-proxy-id': proxy['id'],
        })
        org = Org.info({'id': org['id']})
        self.assertNotIn(proxy['name'], org['smart-proxies'])
コード例 #13
0
ファイル: test_auth.py プロジェクト: synkd/robottelo
def test_positive_change_session(admin_user, non_admin_user):
    """Change from existing session to a different session

    :id: b6ea6f3c-fcbd-4e7b-97bd-f3e0e6b9da8f

    :Steps:

        1. Set use_sessions
        2. Authenticate, assert credentials are not demanded
           on next command run
        3. Login as a different user

    :expectedresults: The session is altered

    """
    result = configure_sessions()
    assert result == 0, 'Failed to configure hammer sessions'
    AuthLogin.basic({'username': admin_user['login'], 'password': password})
    result = Auth.with_user().status()
    assert LOGEDIN_MSG.format(admin_user['login']) in result[0]['message']
    # list organizations without supplying credentials
    assert Org.with_user().list()
    AuthLogin.basic({
        'username': non_admin_user['login'],
        'password': password
    })
    result = Auth.with_user().status()
    assert LOGEDIN_MSG.format(non_admin_user['login']) in result[0]['message']
    assert Org.with_user().list()
コード例 #14
0
ファイル: test_auth.py プロジェクト: renzon/robottelo
    def test_positive_disable_session(self):
        """Check if user logs out when session is disabled

        :id: 38ee0d85-c2fe-4cac-a992-c5dbcec11031

        :Steps:

            1. Set use_sessions
            2. Authenticate, assert credentials are not demanded
               on next command run
            3. Disable use_sessions

        :expectedresults: The session is terminated

        """
        result = configure_sessions()
        self.assertEqual(result, 0, 'Failed to configure hammer sessions')
        Auth.login({'username': self.uname_admin, 'password': self.password})
        result = Auth.with_user().status()
        self.assertIn(LOGEDIN_MSG.format(self.uname_admin),
                      result[0][u'message'])
        # list organizations without supplying credentials
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
        # disabling sessions
        result = configure_sessions(False)
        self.assertEqual(result, 0, 'Failed to configure hammer sessions')
        result = Auth.with_user().status()
        self.assertIn(NOTCONF_MSG.format(self.uname_admin),
                      result[0][u'message'])
        with self.assertRaises(CLIReturnCodeError):
            Org.with_user().list()
コード例 #15
0
    def test_positive_remove_compresource_by_id(self):
        """Remove a compute resource from organization by its ID

        @id: 415c14ab-f879-4ed8-9ba7-8af4ada2e277

        @Assert: Compute resource is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        compute_res = make_compute_resource({
            'provider': FOREMAN_PROVIDERS['libvirt'],
            'url': u'qemu+ssh://root@{0}/system'.format(
                settings.compute_resources.libvirt_hostname
            )
        })
        Org.add_compute_resource({
            'compute-resource-id': compute_res['id'],
            'id': org['id'],
        })
        Org.remove_compute_resource({
            'compute-resource-id': compute_res['id'],
            'id': org['id'],
        })
        org = Org.info({'id': org['id']})
        self.assertNotIn(compute_res['name'], org['compute-resources'])
コード例 #16
0
def test_positive_add_and_remove_locations(module_org):
    """Add and remove a locations from organization

    :id: 37b63e5c-8fd5-439c-9540-972b597b590a

    :expectedresults: Locations are handled

    :BZ: 1395229, 1473387

    :steps:
        1. add and remove locations by name
        2. add and remove locations by id

    :CaseLevel: Integration
    """
    locations = [make_location() for _ in range(0, 2)]
    Org.add_location({'location-id': locations[0]['id'], 'name': module_org.name})
    Org.add_location({'location': locations[1]['name'], 'name': module_org.name})
    org_info = Org.info({'id': module_org.id})
    assert len(org_info['locations']) == 2, "Failed to add locations"
    assert locations[0]['name'] in org_info['locations']
    assert locations[1]['name'] in org_info['locations']
    Org.remove_location({'location-id': locations[0]['id'], 'id': module_org.id})
    Org.remove_location({'location': locations[1]['name'], 'id': module_org.id})
    org_info = Org.info({'id': module_org.id})
    assert not org_info.get('locations'), "Failed to remove locations"
コード例 #17
0
    def test_positive_remove_compresource_by_name(self):
        """Remove a compute resource from organization by its name

        @id: 1b1313a8-8326-4b33-8113-17c5cf0d4ffb

        @Assert: Compute resource is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        compute_res = make_compute_resource({
            'provider': FOREMAN_PROVIDERS['libvirt'],
            'url': u'qemu+ssh://root@{0}/system'.format(
                settings.compute_resources.libvirt_hostname
            )
        })
        Org.add_compute_resource({
            'compute-resource': compute_res['name'],
            'name': org['name'],
        })
        Org.remove_compute_resource({
            'compute-resource': compute_res['name'],
            'name': org['name'],
        })
        org = Org.info({'name': org['name']})
        self.assertNotIn(compute_res['name'], org['compute-resources'])
コード例 #18
0
ファイル: test_auth.py プロジェクト: vsedmik/robottelo
    def test_positive_session_survives_failed_login(self):
        """Check if session stays up after failed login attempt

        :id: 6c4d5c4c-eff0-411b-829f-0c2f2ec26132

        :BZ: 1465552

        :Steps:

            1. Set use_sessions
            2. Authenticate, assert credentials are not demanded
               on next command run
            3. Run login with invalid credentials

        :expectedresults: The session is unchanged

        """
        result = configure_sessions()
        self.assertEqual(result, 0, 'Failed to configure hammer sessions')
        AuthLogin.basic({'username': self.uname_admin, 'password': self.password})
        result = Auth.with_user().status()
        self.assertIn(LOGEDIN_MSG.format(self.uname_admin), result[0]['message'])
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
        # using invalid password
        with self.assertRaises(CLIReturnCodeError):
            AuthLogin.basic({'username': self.uname_viewer, 'password': gen_string('alpha')})
        # checking the session status again
        result = Auth.with_user().status()
        self.assertIn(LOGEDIN_MSG.format(self.uname_admin), result[0]['message'])
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
コード例 #19
0
ファイル: test_auth.py プロジェクト: ldjebran/robottelo
def test_positive_log_out_from_session(admin_user, target_sat):
    """Check if session is terminated when user logs out

    :id: 0ba05f2d-7b83-4b0c-a04c-80e62b7c4cf2

    :Steps:

        1. Set use_sessions
        2. Authenticate, assert credentials are not demanded
           on next command run
        3. Run `hammer auth logout`

    :expectedresults: The session is terminated

    """
    result = configure_sessions(target_sat)
    assert result == 0, 'Failed to configure hammer sessions'
    AuthLogin.basic({'username': admin_user['login'], 'password': password})
    result = Auth.with_user().status()
    assert LOGEDIN_MSG.format(admin_user['login']) in result[0]['message']
    # list organizations without supplying credentials
    assert Org.with_user().list()
    Auth.logout()
    result = Auth.with_user().status()
    assert LOGEDOFF_MSG.format(admin_user['login']) in result[0]['message']
    with pytest.raises(CLIReturnCodeError):
        Org.with_user().list()
コード例 #20
0
ファイル: test_auth.py プロジェクト: renzon/robottelo
    def test_positive_log_out_from_session(self):
        """Check if session is terminated when user logs out

        :id: 0ba05f2d-7b83-4b0c-a04c-80e62b7c4cf2

        :Steps:

            1. Set use_sessions
            2. Authenticate, assert credentials are not demanded
               on next command run
            3. Run `hammer auth logout`

        :expectedresults: The session is terminated

        """
        result = configure_sessions()
        self.assertEqual(result, 0, 'Failed to configure hammer sessions')
        Auth.login({'username': self.uname_admin, 'password': self.password})
        result = Auth.with_user().status()
        self.assertIn(LOGEDIN_MSG.format(self.uname_admin),
                      result[0][u'message'])
        # list organizations without supplying credentials
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
        Auth.logout()
        result = Auth.with_user().status()
        self.assertIn(LOGEDOFF_MSG.format(self.uname_admin),
                      result[0][u'message'])
        with self.assertRaises(CLIReturnCodeError):
            Org.with_user().list()
コード例 #21
0
    def test_positive_add_and_remove_domains(self):
        """Add and remove domains to organization

        :id: 97359ffe-4ce6-4e44-9e3f-583d3fdebbc8

        :expectedresults: Domains are handled correctly

        :BZ: 1395229

        :steps:
            1. Add and remove domain by name
            2. Add and remove domain by id

        :CaseLevel: Integration
        """
        domain_a = make_domain()
        domain_b = make_domain()
        Org.add_domain({'domain-id': domain_a['id'], 'name': self.org['name']})
        Org.add_domain({'domain': domain_b['name'], 'name': self.org['name']})
        org_info = Org.info({'id': self.org['id']})
        self.assertEqual(len(org_info['domains']), 2, "Failed to add domains")
        self.assertIn(domain_a['name'], org_info['domains'])
        self.assertIn(domain_b['name'], org_info['domains'])
        Org.remove_domain({
            'domain': domain_a['name'],
            'name': self.org['name']
        })
        Org.remove_domain({'domain-id': domain_b['id'], 'id': self.org['id']})
        org_info = Org.info({'id': self.org['id']})
        self.assertEqual(len(org_info['domains']), 0,
                         "Failed to remove domains")
コード例 #22
0
    def test_positive_add_and_remove_locations(self):
        """Add and remove a locations from organization

        :id: 37b63e5c-8fd5-439c-9540-972b597b590a

        :expectedresults: Locations are handled

        :BZ: 1395229, 1473387

        :steps:
            1. add and remove locations by name
            2. add and remove locations by id

        :CaseLevel: Integration
        """
        loc_a = make_location()
        loc_b = make_location()
        Org.add_location({
            'location-id': loc_a['id'],
            'name': self.org['name']
        })
        Org.add_location({'location': loc_b['name'], 'name': self.org['name']})
        org_info = Org.info({'id': self.org['id']})
        self.assertEqual(len(org_info['locations']), 2,
                         "Failed to add locations")
        self.assertIn(loc_a['name'], org_info['locations'])
        self.assertIn(loc_b['name'], org_info['locations'])
        Org.remove_location({'location-id': loc_a['id'], 'id': self.org['id']})
        Org.remove_location({'location': loc_b['name'], 'id': self.org['id']})
        org_info = Org.info({'id': self.org['id']})
        self.assertNotIn('locations', org_info, "Failed to remove locations")
コード例 #23
0
    def test_positive_add_and_remove_subnets(self):
        """add and remove a subnet from organization

        :id: adb5310b-76c5-4aca-8220-fdf0fe605cb0

        :BZ:
            1. Add and remove subnet by name
            2. Add and remove subnet by id

        :expectedresults: Subnets are handled as expected

        :BZ: 1395229

        :CaseLevel: Integration
        """
        subnet_a = make_subnet()
        subnet_b = make_subnet()
        Org.add_subnet({'name': self.org['name'], 'subnet': subnet_a['name']})
        Org.add_subnet({'name': self.org['name'], 'subnet-id': subnet_b['id']})
        org_info = Org.info({'id': self.org['id']})
        self.assertEqual(len(org_info['subnets']), 2, "Failed to add subnets")
        Org.remove_subnet({
            'name': self.org['name'],
            'subnet': subnet_a['name']
        })
        Org.remove_subnet({
            'name': self.org['name'],
            'subnet-id': subnet_b['id']
        })
        org_info = Org.info({'id': self.org['id']})
        self.assertEqual(len(org_info['subnets']), 0,
                         "Failed to remove subnets")
コード例 #24
0
    def test_positive_add_and_remove_media(self):
        """Add and remove medium to organization

        :id: c2943a81-c8f7-44c4-926b-388055d7c290

        :expectedresults: Media are handled as expected

        :BZ: 1395229

        :steps:
            1. add and remove medium by id
            2. add and remove medium by name

        :CaseLevel: Integration
        """
        medium_a = make_medium()
        medium_b = make_medium()
        Org.add_medium({'id': self.org['id'], 'medium-id': medium_a['id']})
        Org.add_medium({'name': self.org['name'], 'medium': medium_b['name']})
        org_info = Org.info({'id': self.org['id']})
        self.assertIn(medium_a['name'], org_info['installation-media'],
                      "Failed to add medium by id")
        self.assertIn(medium_b['name'], org_info['installation-media'],
                      "Failed to add medium by name")
        Org.remove_medium({
            'name': self.org['name'],
            'medium': medium_a['name']
        })
        Org.remove_medium({'id': self.org['id'], 'medium-id': medium_b['id']})
        org_info = Org.info({'id': self.org['id']})
        self.assertNotIn(medium_a['name'], org_info['installation-media'],
                         "Failed to remove medium by name")
        self.assertNotIn(medium_b['name'], org_info['installation-media'],
                         "Failed to remove medium by id")
コード例 #25
0
ファイル: test_auth.py プロジェクト: renzon/robottelo
    def test_positive_change_session(self):
        """Change from existing session to a different session

        :id: b6ea6f3c-fcbd-4e7b-97bd-f3e0e6b9da8f

        :Steps:

            1. Set use_sessions
            2. Authenticate, assert credentials are not demanded
               on next command run
            3. Login as a different user

        :expectedresults: The session is altered

        """
        result = configure_sessions()
        self.assertEqual(result, 0, 'Failed to configure hammer sessions')
        Auth.login({'username': self.uname_admin, 'password': self.password})
        result = Auth.with_user().status()
        self.assertIn(LOGEDIN_MSG.format(self.uname_admin),
                      result[0][u'message'])
        # list organizations without supplying credentials
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
        Auth.login({'username': self.uname_viewer, 'password': self.password})
        result = Auth.with_user().status()
        self.assertIn(LOGEDIN_MSG.format(self.uname_viewer),
                      result[0][u'message'])
        with self.assertNotRaises(CLIReturnCodeError):
            Org.with_user().list()
コード例 #26
0
ファイル: test_auth.py プロジェクト: ldjebran/robottelo
def test_positive_session_survives_unauthenticated_call(
        admin_user, target_sat):
    """Check if session stays up after unauthenticated call

    :id: 8bc304a0-70ea-489c-9c3f-ea8343c5284c

    :Steps:

        1. Set use_sessions
        2. Authenticate, assert credentials are not demanded
           on next command run
        3. Run `hammer ping`

    :CaseImportance: Medium

    :expectedresults: The session is unchanged

    """
    result = configure_sessions(target_sat)
    assert result == 0, 'Failed to configure hammer sessions'
    AuthLogin.basic({'username': admin_user['login'], 'password': password})
    result = Auth.with_user().status()
    assert LOGEDIN_MSG.format(admin_user['login']) in result[0]['message']
    # list organizations without supplying credentials
    Org.with_user().list()
    result = target_sat.execute('hammer ping')
    assert result.status == 0, 'Failed to run hammer ping'
    result = Auth.with_user().status()
    assert LOGEDIN_MSG.format(admin_user['login']) in result[0]['message']
    Org.with_user().list()
コード例 #27
0
ファイル: test_auth.py プロジェクト: ldjebran/robottelo
def test_positive_session_survives_failed_login(admin_user, non_admin_user,
                                                target_sat):
    """Check if session stays up after failed login attempt

    :id: 6c4d5c4c-eff0-411b-829f-0c2f2ec26132

    :BZ: 1465552

    :Steps:

        1. Set use_sessions
        2. Authenticate, assert credentials are not demanded
           on next command run
        3. Run login with invalid credentials

    :expectedresults: The session is unchanged

    """
    result = configure_sessions(target_sat)
    assert result == 0, 'Failed to configure hammer sessions'
    AuthLogin.basic({'username': admin_user['login'], 'password': password})
    result = Auth.with_user().status()
    assert LOGEDIN_MSG.format(admin_user['login']) in result[0]['message']
    Org.with_user().list()
    # using invalid password
    with pytest.raises(CLIReturnCodeError):
        AuthLogin.basic({
            'username': non_admin_user['login'],
            'password': gen_string('alpha')
        })
    # checking the session status again
    result = Auth.with_user().status()
    assert LOGEDIN_MSG.format(admin_user['login']) in result[0]['message']
    Org.with_user().list()
コード例 #28
0
def test_positive_add_and_remove_domains(module_org):
    """Add and remove domains to organization

    :id: 97359ffe-4ce6-4e44-9e3f-583d3fdebbc8

    :expectedresults: Domains are handled correctly

    :BZ: 1395229

    :steps:
        1. Add and remove domain by name
        2. Add and remove domain by id

    :CaseLevel: Integration
    """
    domains = [make_domain() for _ in range(0, 2)]
    Org.add_domain({'domain-id': domains[0]['id'], 'name': module_org.name})
    Org.add_domain({'domain': domains[1]['name'], 'name': module_org.name})
    org_info = Org.info({'id': module_org.id})
    assert len(org_info['domains']) == 2, "Failed to add domains"
    assert domains[0]['name'] in org_info['domains']
    assert domains[1]['name'] in org_info['domains']
    Org.remove_domain({'domain': domains[0]['name'], 'name': module_org.name})
    Org.remove_domain({'domain-id': domains[1]['id'], 'id': module_org.id})
    org_info = Org.info({'id': module_org.id})
    assert len(org_info['domains']) == 0, "Failed to remove domains"
コード例 #29
0
def test_positive_add_and_remove_parameter(module_org):
    """Remove a parameter from organization

    :id: e4099279-4e73-4c14-9e7c-912b3787b99f

    :expectedresults: Parameter is removed from the org

    :CaseImportance: Critical
    """
    param_name = gen_string('alpha')
    param_new_value = gen_string('alpha')

    org_info = Org.info({'id': module_org.id})
    assert len(org_info['parameters']) == 0

    # Create parameter
    Org.set_parameter(
        {'name': param_name, 'value': gen_string('alpha'), 'organization-id': module_org.id}
    )
    org_info = Org.info({'id': module_org.id})
    assert len(org_info['parameters']) == 1

    # Update
    Org.set_parameter(
        {'name': param_name, 'value': param_new_value, 'organization': module_org.name}
    )
    org_info = Org.info({'id': module_org.id})
    assert len(org_info['parameters']) == 1
    assert param_new_value == org_info['parameters'][param_name.lower()]

    # Delete parameter
    Org.delete_parameter({'name': param_name, 'organization': module_org.name})
    org_info = Org.info({'id': module_org.id})
    assert len(org_info['parameters']) == 0
    assert param_name.lower() not in org_info['parameters']
コード例 #30
0
    def test_negative_create_same_name(self):
        """Create organization with valid values, then create a new one with
        same values

        :id: 07924e1f-1eff-4bae-b0db-e41b84966bc1

        :expectedresults: organization is not created

        :CaseImportance: Critical
        """
        name = valid_org_names_list()[0]
        desc = valid_data_list()[0]
        label = valid_labels_list()[0]

        Org.create({
            'description': desc,
            'label': label,
            'name': name,
        })
        with self.assertRaises(CLIReturnCodeError):
            Org.create({
                'description': desc,
                'label': label,
                'name': name,
            })
コード例 #31
0
def test_positive_add_and_remove_hostgroups(module_org):
    """add and remove a hostgroup from an organization

    :id: 34e2c7c8-dc20-4709-a5a9-83c0dee9d84d

    :expectedresults: Hostgroups are handled as expected

    :BZ: 1395229

    :steps:
        1. add and remove hostgroup by name
        2. add and remove hostgroup by id

    :CaseLevel: Integration
    """
    hostgroups = [make_hostgroup() for _ in range(0, 2)]

    Org.add_hostgroup({'hostgroup-id': hostgroups[0]['id'], 'id': module_org.id})
    Org.add_hostgroup({'hostgroup': hostgroups[1]['name'], 'name': module_org.name})
    org_info = Org.info({'name': module_org.name})
    assert hostgroups[0]['name'] in org_info['hostgroups'], "Failed to add hostgroup by id"
    assert hostgroups[1]['name'] in org_info['hostgroups'], "Failed to add hostgroup by name"
    Org.remove_hostgroup({'hostgroup-id': hostgroups[1]['id'], 'id': module_org.id})
    Org.remove_hostgroup({'hostgroup': hostgroups[0]['name'], 'name': module_org.name})
    org_info = Org.info({'id': module_org.id})
    assert hostgroups[0]['name'] not in org_info['hostgroups'], "Failed to remove hostgroup by name"
    assert hostgroups[1]['name'] not in org_info['hostgroups'], "Failed to remove hostgroup by id"
コード例 #32
0
    def test_positive_add_template_by_name(self):
        """Add a provisioning template to organization by its name

        @id: bd46a192-488f-4da0-bf47-1f370ae5f55c

        @Assert: Template is added to the org

        @CaseLevel: Integration
        """
        for name in valid_data_list():
            with self.subTest(name):
                org = make_org()
                template = make_template({
                    'content': gen_string('alpha'),
                    'name': name,
                })
                Org.add_config_template({
                    'config-template': template['name'],
                    'name': org['name'],
                })
                org = Org.info({'name': org['name']})
                self.assertIn(
                    u'{0} ({1})'. format(template['name'], template['type']),
                    org['templates']
                )
コード例 #33
0
def test_positive_add_and_remove_media(module_org):
    """Add and remove medium to organization

    :id: c2943a81-c8f7-44c4-926b-388055d7c290

    :expectedresults: Media are handled as expected

    :BZ: 1395229

    :steps:
        1. add and remove medium by id
        2. add and remove medium by name

    :CaseLevel: Integration
    """
    media = [make_medium() for _ in range(0, 2)]
    Org.add_medium({'id': module_org.id, 'medium-id': media[0]['id']})
    Org.add_medium({'name': module_org.name, 'medium': media[1]['name']})
    org_info = Org.info({'id': module_org.id})
    assert media[0]['name'] in org_info['installation-media'], "Failed to add medium by id"
    assert media[1]['name'] in org_info['installation-media'], "Failed to add medium by name"
    Org.remove_medium({'name': module_org.name, 'medium': media[0]['name']})
    Org.remove_medium({'id': module_org.id, 'medium-id': media[1]['id']})
    org_info = Org.info({'id': module_org.id})
    assert media[0]['name'] not in org_info['installation-media'], "Failed to remove medium by name"
    assert media[1]['name'] not in org_info['installation-media'], "Failed to remove medium by id"
コード例 #34
0
ファイル: test_auth.py プロジェクト: ldjebran/robottelo
def test_positive_disable_session(admin_user, target_sat):
    """Check if user logs out when session is disabled

    :id: 38ee0d85-c2fe-4cac-a992-c5dbcec11031

    :Steps:

        1. Set use_sessions
        2. Authenticate, assert credentials are not demanded
           on next command run
        3. Disable use_sessions

    :expectedresults: The session is terminated

    """
    result = configure_sessions(target_sat)
    assert result == 0, 'Failed to configure hammer sessions'
    AuthLogin.basic({'username': admin_user['login'], 'password': password})
    result = Auth.with_user().status()
    assert LOGEDIN_MSG.format(admin_user['login']) in result[0]['message']
    # list organizations without supplying credentials
    assert Org.with_user().list()
    # disabling sessions
    result = configure_sessions(satellite=target_sat, enable=False)
    assert result == 0, 'Failed to configure hammer sessions'
    result = Auth.with_user().status()
    assert NOTCONF_MSG.format(admin_user['login']) in result[0]['message']
    with pytest.raises(CLIReturnCodeError):
        Org.with_user().list()
コード例 #35
0
    def test_negative_create_same_name(self):
        """Create organization with valid values, then create a new one with
        same values

        @id: 07924e1f-1eff-4bae-b0db-e41b84966bc1

        @assert: organization is not created
        """
        for desc, name, label in zip(
                valid_data_list(),
                valid_org_names_list(),
                cycle(valid_labels_list()),
        ):
            with self.subTest(desc + name + label):
                Org.create({
                    'description': desc,
                    'label': label,
                    'name': name,
                })
                with self.assertRaises(CLIReturnCodeError):
                    Org.create({
                        'description': desc,
                        'label': label,
                        'name': name,
                    })
コード例 #36
0
    def test_positive_remove_capsule_by_name(self):
        """Remove a capsule from organization by its name

        @id: f56eaf46-fef5-4b52-819f-e30e61f0ec4a

        @Assert: Capsule is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        proxy = make_proxy()
        # Add capsule and org to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
        self.addCleanup(org_cleanup, org['id'])

        Org.add_smart_proxy({
            'name': org['name'],
            'smart-proxy': proxy['name'],
        })
        Org.remove_smart_proxy({
            'name': org['name'],
            'smart-proxy': proxy['name'],
        })
        org = Org.info({'name': org['name']})
        self.assertNotIn(proxy['name'], org['smart-proxies'])
コード例 #37
0
    def test_positive_last_login_for_new_user(self):
        """Create new user with admin role and check last login updated for that user

        :id: 967282d3-92d0-42ce-9ef3-e542d2883408

        :customerscenario: true

        :expectedresults: last login should be updated for user after login using hammer

        :BZ: 1763816

        :CaseLevel: Integration
        """
        login = gen_string('alpha')
        password = gen_string('alpha')
        org_name = gen_string('alpha')

        make_user({'login': login, 'password': password})
        User.add_role({'login': login, 'role': 'System admin'})
        result_before_login = User.list({'search': f'login = {login}'})

        # this is because satellite uses the UTC timezone
        before_login_time = datetime.datetime.utcnow()
        assert result_before_login[0]['login'] == login
        assert result_before_login[0]['last-login'] == ""

        Org.with_user(username=login,
                      password=password).create({'name': org_name})
        result_after_login = User.list({'search': f'login = {login}'})

        # checking user last login should not be empty
        assert result_after_login[0]['last-login'] != ""
        after_login_time = datetime.datetime.strptime(
            result_after_login[0]['last-login'], "%Y/%m/%d %H:%M:%S")
        assert after_login_time > before_login_time
コード例 #38
0
    def test_positive_list(self):
        """@Test: Check if Org can be listed

        @Feature: Organization

        @Assert: Org is listed
        """
        Org.list()
コード例 #39
0
ファイル: test_organization.py プロジェクト: jhutar/robottelo
    def test_positive_add_and_remove_compresources(self):
        """Add and remove a compute resource from organization

        :id: 415c14ab-f879-4ed8-9ba7-8af4ada2e277

        :expectedresults: Compute resource are handled as expected

        :bz: 1395229

        :steps:
            1. Add and remove compute resource by id
            2. Add and remove compute resource by name

        :CaseLevel: Integration
        """
        org = make_org()
        compute_res_a = make_compute_resource({
            'provider': FOREMAN_PROVIDERS['libvirt'],
            'url': u'qemu+ssh://root@{0}/system'.format(
                settings.compute_resources.libvirt_hostname
            )
        })
        compute_res_b = make_compute_resource({
            'provider': FOREMAN_PROVIDERS['libvirt'],
            'url': u'qemu+ssh://root@{0}/system'.format(
                settings.compute_resources.libvirt_hostname
            )
        })
        Org.add_compute_resource({
            'compute-resource-id': compute_res_a['id'],
            'id': org['id'],
        })
        Org.add_compute_resource({
            'compute-resource': compute_res_b['name'],
            'name': org['name'],
        })
        org_info = Org.info({'id': org['id']})
        self.assertEqual(len(org_info['compute-resources']), 2,
                         "Failed to add compute resources")
        Org.remove_compute_resource({
            'compute-resource-id': compute_res_a['id'],
            'id': org['id'],
        })
        Org.remove_compute_resource({
            'compute-resource': compute_res_b['name'],
            'name': org['name'],
        })
        org_info = Org.info({'id': org['id']})
        self.assertNotIn(
            compute_res_a['name'],
            org_info['compute-resources'],
            "Failed to remove cr by id"
        )
        self.assertNotIn(
            compute_res_b['name'],
            org_info['compute-resources'],
            "Failed to remove cr by name"
        )
コード例 #40
0
    def test_positive_add_and_remove_compresources(self):
        """Add and remove a compute resource from organization

        :id: 415c14ab-f879-4ed8-9ba7-8af4ada2e277

        :expectedresults: Compute resource are handled as expected

        :bz: 1395229

        :steps:
            1. Add and remove compute resource by id
            2. Add and remove compute resource by name

        :CaseLevel: Integration
        """
        org = make_org()
        compute_res_a = make_compute_resource({
            'provider': FOREMAN_PROVIDERS['libvirt'],
            'url': u'qemu+ssh://root@{0}/system'.format(
                settings.compute_resources.libvirt_hostname
            )
        })
        compute_res_b = make_compute_resource({
            'provider': FOREMAN_PROVIDERS['libvirt'],
            'url': u'qemu+ssh://root@{0}/system'.format(
                settings.compute_resources.libvirt_hostname
            )
        })
        Org.add_compute_resource({
            'compute-resource-id': compute_res_a['id'],
            'id': org['id'],
        })
        Org.add_compute_resource({
            'compute-resource': compute_res_b['name'],
            'name': org['name'],
        })
        org_info = Org.info({'id': org['id']})
        self.assertEqual(len(org_info['compute-resources']), 2,
                         "Failed to add compute resources")
        Org.remove_compute_resource({
            'compute-resource-id': compute_res_a['id'],
            'id': org['id'],
        })
        Org.remove_compute_resource({
            'compute-resource': compute_res_b['name'],
            'name': org['name'],
        })
        org_info = Org.info({'id': org['id']})
        self.assertNotIn(
            compute_res_a['name'],
            org_info['compute-resources'],
            "Failed to remove cr by id"
        )
        self.assertNotIn(
            compute_res_b['name'],
            org_info['compute-resources'],
            "Failed to remove cr by name"
        )
コード例 #41
0
    def test_positive_CRD(self):
        """Create organization with valid name, label and description

        :id: 35840da7-668e-4f78-990a-738aa688d586

        :expectedresults: organization is created with attributes

        :CaseImportance: Critical

        create read
        """
        # Create
        name = valid_org_names_list()[0]
        label = valid_labels_list()[0]
        desc = valid_data_list()[0]
        org = make_org({
            'name': name,
            'label': label,
            'description': desc,
        })
        self.assertEqual(org['name'], name)
        self.assertEqual(org['label'], label)
        self.assertEqual(org['description'], desc)

        # List
        result = Org.list({'search': 'name=%s' % org['name']})
        self.assertTrue(len(result), 1)
        self.assertEqual(result[0]['name'], org['name'])

        # Search scoped
        for query in [
                'label = {}'.format(label),
                'description ~ {}'.format(desc[:-5]),
                'name ^ "{}"'.format(org['name']),
        ]:
            result = Org.list({'search': query})
            self.assertTrue(len(result), 1)
            self.assertEqual(result[0]['name'], org['name'])

        # Search by name and label
        result = Org.exists(search=('name', org['name']))
        self.assertEqual(org['name'], result['name'])
        result = Org.exists(search=('label', org['label']))
        self.assertEqual(org['name'], result['name'])

        # Info by name and label
        result = Org.info({'label': org['label']})
        self.assertEqual(org['id'], result['id'])
        result = Org.info({'name': org['name']})
        self.assertEqual(org['id'], result['id'])

        # Delete
        Org.delete({'id': org['id']})
        with self.assertRaises(CLIReturnCodeError):
            Org.info({'id': org['id']})
コード例 #42
0
    def test_positive_delete_by_id(self):
        """Delete an organization by ID

        @feature: Organization

        @assert: organization is deleted
        """
        org = make_org()
        Org.delete({'id': org['id']})
        # Can we find the object?
        with self.assertRaises(CLIReturnCodeError):
            Org.info({'id': org['id']})
コード例 #43
0
    def test_positive_delete_by_id(self):
        """Delete an organization by ID

        @id: b1f5d246-2b12-4302-9824-00d3561f8699

        @assert: organization is deleted
        """
        org = make_org()
        Org.delete({'id': org['id']})
        # Can we find the object?
        with self.assertRaises(CLIReturnCodeError):
            Org.info({'id': org['id']})
コード例 #44
0
 def setUpClass(cls):
     super(EC2ComputeResourceTestCase, cls).setUpClass()
     cls.org = make_org()
     cls.loc = make_location()
     Org.add_location({'id': cls.org['id'], 'location-id': cls.loc['id']})
     cls.aws_access_key = settings.ec2.access_key
     cls.aws_secret_key = settings.ec2.secret_key
     cls.aws_region = settings.ec2.region
     cls.aws_image = settings.ec2.image
     cls.aws_availability_zone = settings.ec2.availability_zone
     cls.aws_subnet = settings.ec2.subnet
     cls.aws_security_groups = settings.ec2.security_groups
     cls.aws_managed_ip = settings.ec2.managed_ip
コード例 #45
0
    def test_positive_add_user_by_id(self):
        """@Test: Add an user by its ID

        @Feature: Organization

        @Assert: User is added to the org
        """
        org = make_org()
        user = make_user()
        Org.add_user({
            'name': org['name'],
            'user-id': user['id'],
        })
コード例 #46
0
    def test_positive_add_hostgroup_by_name(self):
        """@Test: Add a hostgroup by its name

        @Feature: Organization

        @Assert: Hostgroup is added to the org
        """
        org = make_org()
        hostgroup = make_hostgroup()
        Org.add_hostgroup({
            'hostgroup': hostgroup['name'],
            'name': org['name'],
        })
コード例 #47
0
    def test_positive_add_capsule_by_name(self):
        """@Test: Add a capsule by its name

        @Feature: Organization

        @Assert: Capsule is added to the org
        """
        org = make_org()
        proxy = make_proxy()
        Org.add_smart_proxy({
            'name': org['name'],
            'smart-proxy': proxy['name'],
        })
コード例 #48
0
ファイル: test_auth.py プロジェクト: JacobCallahan/robottelo
    def test_positive_session_preceeds_saved_credentials(self):
        """Check if enabled session is mutually exclusive with
        saved credentials in hammer config

        :id: e4277298-1c24-494b-84a6-22f45f96e144

        :BZ: 1471099

        :Steps:

            1. Set use_sessions, set usernam and password,
               set short expiration time
            2. Authenticate, assert credentials are not demanded
               on next command run
            3. Wait until session expires

        :expectedresults: Session expires after specified time
            and saved credentials are not applied

        """
        try:
            idle_timeout = Settings.list({
                'search': 'name=idle_timeout'})[0][u'value']
            Settings.set({'name': 'idle_timeout', 'value': 1})
            result = configure_sessions(add_default_creds=True)
            self.assertEqual(result, 0, 'Failed to configure hammer sessions')
            Auth.login({
                'username': self.uname_admin,
                'password': self.password
            })
            result = Auth.with_user().status()
            self.assertIn(
                LOGEDIN_MSG.format(self.uname_admin),
                result[0][u'message']
            )
            # list organizations without supplying credentials
            with self.assertNotRaises(CLIReturnCodeError):
                Org.with_user().list()
            # wait until session expires
            sleep(70)
            with self.assertRaises(CLIReturnCodeError):
                Org.with_user().list()
            result = Auth.with_user().status()
            self.assertIn(
                LOGEDOFF_MSG.format(self.uname_admin),
                result[0][u'message']
            )
        finally:
            # reset timeout to default
            Settings.set({'name': 'idle_timeout', 'value': '{}'.format(
                idle_timeout)})
コード例 #49
0
    def test_positive_delete_by_label(self):
        """Delete an organization by label

        @id: 5624f318-ce10-4eaa-815b-0d6ec1e6b438

        @assert: organization is deleted
        """
        for label in valid_labels_list():
            with self.subTest(label):
                org = make_org({'label': label})
                Org.delete({'label': org['label']})
                # Can we find the object?
                with self.assertRaises(CLIReturnCodeError):
                    Org.info({'id': org['id']})
コード例 #50
0
ファイル: test_organization.py プロジェクト: jhutar/robottelo
    def test_positive_delete_by_id(self):
        """Delete an organization by ID

        :id: b1f5d246-2b12-4302-9824-00d3561f8699

        :expectedresults: organization is deleted

        :CaseImportance: Critical
        """
        org = make_org()
        Org.delete({'id': org['id']})
        # Can we find the object?
        with self.assertRaises(CLIReturnCodeError):
            Org.info({'id': org['id']})
コード例 #51
0
    def test_positive_delete_by_name(self):
        """Delete an organization by name

        @id: c2787b85-fa87-4aaf-bee4-4695249dd5d8

        @assert: organization is deleted
        """
        for name in valid_org_names_list():
            with self.subTest(name):
                org = make_org({'name': name})
                Org.delete({'name': org['name']})
                # Can we find the object?
                with self.assertRaises(CLIReturnCodeError):
                    Org.info({'id': org['id']})
コード例 #52
0
    def test_positive_add_subnet_by_id(self):
        """Add a subnet to organization by its ID

        @feature: Organization

        @assert: Subnet is added to the org
        """
        org = make_org()
        new_subnet = make_subnet()
        Org.add_subnet({
            'name': org['name'],
            'subnet-id': new_subnet['id'],
        })
        org = Org.info({'id': org['id']})
        self.assertIn(new_subnet['name'], org['subnets'][0])
コード例 #53
0
    def test_positive_add_hostgroup_by_name(self):
        """Add a hostgroup to organization by its name

        @Feature: Organization

        @Assert: Hostgroup is added to the org
        """
        org = make_org()
        hostgroup = make_hostgroup()
        Org.add_hostgroup({
            'hostgroup': hostgroup['name'],
            'name': org['name'],
        })
        org = Org.info({'name': org['name']})
        self.assertIn(hostgroup['name'], org['hostgroups'])
コード例 #54
0
    def test_positive_add_user_by_id(self):
        """Add an user to organization by its ID

        @Feature: Organization

        @Assert: User is added to the org
        """
        org = make_org()
        user = make_user()
        Org.add_user({
            'id': org['id'],
            'user-id': user['id'],
        })
        org = Org.info({'id': org['id']})
        self.assertIn(user['login'], org['users'])
コード例 #55
0
    def test_positive_add_medium_by_name(self):
        """Add a medium to organization by its name

        @Feature: Organization

        @Assert: Medium is added to the org
        """
        org = make_org()
        medium = make_medium()
        Org.add_medium({
            'name': org['name'],
            'medium': medium['name'],
        })
        org = Org.info({'name': org['name']})
        self.assertIn(medium['name'], org['installation-media'])
コード例 #56
0
    def test_positive_add_capsule_by_name(self):
        """Add a capsule to organization by its name

        @Feature: Organization

        @Assert: Capsule is added to the org
        """
        org = make_org()
        proxy = make_proxy()
        Org.add_smart_proxy({
            'name': org['name'],
            'smart-proxy': proxy['name'],
        })
        org = Org.info({'name': org['name']})
        self.assertIn(proxy['name'], org['smart-proxies'])
コード例 #57
0
    def test_positive_delete_by_name(self):
        """@test: Create organization with valid values then delete it
        by name

        @feature: Organization

        @assert: organization is deleted
        """
        for test_data in valid_name_desc_label():
            with self.subTest(test_data):
                org = make_org(test_data)
                Org.delete({'name': org['name']})
                # Can we find the object?
                with self.assertRaises(CLIReturnCodeError):
                    Org.info({'id': org['id']})
コード例 #58
0
ファイル: test_import.py プロジェクト: ares/robottelo
    def test_import_orgs_recovery(self, test_data):
        """@test: Try to Import organizations with the same name to invoke
        usage of a recovery strategy (rename, map, none)

        @feature: Import Organizations Recover

        @assert: 2nd Import will result in No Action Taken, 3rd one will rename
        the new organizations, and the 4th one will map them

        """
        # prepare the data
        files = dict(self.default_dataset[1])
        files['users'] = update_csv_values(
            files['users'],
            'organization_id',
            test_data,
            self.default_dataset[0]
        )
        # initial import
        self.assertEqual(
            Import.organization({'csv-file': files['users']}).return_code, 0)
        # clear the .transition_data to clear the transition mapping
        ssh.command('rm -rf "${HOME}"/.transition_data')

        # use the 'none' strategy
        orgs_before = Org.list().stdout
        Import.organization({'csv-file': files['users'], 'recover': 'none'})
        self.assertEqual(orgs_before, Org.list().stdout)

        # use the default (rename) strategy
        ssh_imp_rename = Import.organization_with_tr_data(
            {'csv-file': files['users']}
        )
        self.assertEqual(len(ssh_imp_rename[1]), len(test_data))
        for record in ssh_imp_rename[1]:
            self.assertEqual(Org.info({'id': record['sat6']}).return_code, 0)
        Import.organization({'csv-file': files['users'], 'delete': True})

        # use the 'map' strategy
        ssh_imp_map = Import.organization_with_tr_data({
            'csv-file': files['users'],
            'recover': 'map',
        })
        for record in ssh_imp_map[1]:
            self.assertEqual(
                Org.info({'id': record['sat6']}).return_code, 0
            )
        Import.organization({'csv-file': files['users'], 'delete': True})
コード例 #59
0
    def test_negative_update_name(self):
        """Create organization then fail to update its name

        @id: 582d41b8-370d-45ed-9b7b-8096608e1324

        @assert: organization name is not updated
        """
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                org = make_org()
                # Update the org name
                with self.assertRaises(CLIReturnCodeError):
                    Org.update({
                        'id': org['id'],
                        'new-name': new_name,
                    })
コード例 #60
0
ファイル: test_gpgkey.py プロジェクト: tkolhar/robottelo
    def test_positive_create_with_default_org(self):
        """@test: Create gpg key with valid name and valid gpg key via file
        import using the default created organization

        @feature: GPG Keys

        @assert: gpg key is created

        @BZ: 1172009
        """
        result = Org.list()
        self.assertGreater(len(result), 0, 'No organization found')
        org = result[0]
        for name in valid_data_list():
            with self.subTest(name):
                gpg_key = make_gpg_key({
                    'key': VALID_GPG_KEY_FILE_PATH,
                    'name': name,
                    'organization-id': org['id'],
                })
                # Can we find the new object?
                result = GPGKey.exists(
                    {'organization-id': org['id']},
                    (self.search_key, gpg_key[self.search_key])
                )
                self.assertEqual(
                    gpg_key[self.search_key],
                    result[self.search_key]
                )