当前位置: 首页>>代码示例>>Python>>正文


Python Environment.get_username_for_role_in_test_org方法代码示例

本文整理汇总了Python中pyvcloud.system_test_framework.environment.Environment.get_username_for_role_in_test_org方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_username_for_role_in_test_org方法的具体用法?Python Environment.get_username_for_role_in_test_org怎么用?Python Environment.get_username_for_role_in_test_org使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyvcloud.system_test_framework.environment.Environment的用法示例。


在下文中一共展示了Environment.get_username_for_role_in_test_org方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _login

# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_username_for_role_in_test_org [as 别名]
 def _login(self):
     org = VmTest._config['vcd']['default_org_name']
     user = Environment.get_username_for_role_in_test_org(
         CommonRoles.ORGANIZATION_ADMINISTRATOR)
     password = VmTest._config['vcd']['default_org_user_password']
     login_args = [
         VmTest._config['vcd']['host'], org, user, "-i", "-w",
         "--password={0}".format(password)
     ]
     result = VmTest._runner.invoke(login, args=login_args)
     self.assertEqual(0, result.exit_code)
     self.assertTrue("logged in" in result.output)
开发者ID:vmware,项目名称:vca-cli,代码行数:14,代码来源:vm_tests.py

示例2: test_0080_change_catalog_ownership

# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_username_for_role_in_test_org [as 别名]
    def test_0080_change_catalog_ownership(self):
        """Test the method org.change_catalog_owner().

        Change the ownership of the catalog to org administrator and back to
        the original owner.

        This test passes if the catalog owner change operation succeeds without
        raising any errors. And the new owner is able to access the catalog.
        """
        logger = Environment.get_default_logger()
        org_admin_client = Environment.get_client_in_default_org(
            CommonRoles.ORGANIZATION_ADMINISTRATOR)
        org = Environment.get_test_org(org_admin_client)

        catalog_name = TestCatalog._test_catalog_name
        original_owner_username = \
            Environment.get_username_for_role_in_test_org(
                TestCatalog._test_runner_role)
        org_admin_username = Environment.get_username_for_role_in_test_org(
            CommonRoles.ORGANIZATION_ADMINISTRATOR)
        try:
            logger.debug('Changing owner of catalog:' + catalog_name +
                         ' to ' + org_admin_username)
            org.change_catalog_owner(catalog_name, org_admin_username)
            catalog_admin_resource = org.get_catalog(catalog_name,
                                                     is_admin_operation=True)
            self.assertEqual(catalog_admin_resource.Owner.User.get('name'),
                             org_admin_username)

            logger.debug('Changing owner of catalog ' + catalog_name +
                         ' back to ' + original_owner_username)
            org.change_catalog_owner(catalog_name, original_owner_username)
            catalog_admin_resource = org.get_catalog(catalog_name,
                                                     is_admin_operation=True)
            self.assertEqual(catalog_admin_resource.Owner.User.get('name'),
                             original_owner_username)
        finally:
            org_admin_client.logout()
开发者ID:vmware,项目名称:pyvcloud,代码行数:40,代码来源:catalog_tests.py

示例3: test_0015_tenant_login

# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_username_for_role_in_test_org [as 别名]
 def test_0015_tenant_login(self):
     """Login with valid tenant credentials succeeds and shows 'logged in' tag
     """
     org = self._config['vcd']['default_org_name']
     user = Environment.get_username_for_role_in_test_org(
         CommonRoles.VAPP_USER)
     password = self._config['vcd']['default_org_user_password']
     login_args = [
         self._host, org, user, "-i",
         "-w", "--password={0}".format(password)
     ]
     result = self._runner.invoke(login, args=login_args)
     self.assertEqual(0, result.exit_code)
     self.assertTrue("logged in" in result.output)
     self._logout()
开发者ID:vmware,项目名称:vca-cli,代码行数:17,代码来源:login_and_vcd_tests.py

示例4: test_0090_change_vapp_owner

# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_username_for_role_in_test_org [as 别名]
    def test_0090_change_vapp_owner(self):
        """Test the method vapp.change_owner().

        This test passes if the owner of the vApp is successfuly changed to the
        desired user.
        """
        try:
            logger = Environment.get_default_logger()
            org_admin_client = Environment.get_client_in_default_org(
                CommonRoles.ORGANIZATION_ADMINISTRATOR)

            vapp_name = TestVApp._empty_vapp_name
            vapp = Environment.get_vapp_in_test_vdc(
                client=org_admin_client, vapp_name=vapp_name)

            vapp_user_name = Environment.get_username_for_role_in_test_org(
                CommonRoles.VAPP_USER)
            vapp_user_href = Environment.get_user_href_in_test_org(
                vapp_user_name)

            logger.debug('Changing owner of vApp ' + vapp_name + ' to ' +
                         vapp_user_name)
            vapp.change_owner(vapp_user_href)
            vapp.reload()
            self.assertEqual(vapp.get_resource().Owner.User.get('name'),
                             vapp_user_name)

            logger.debug('Changing owner of vApp ' + vapp_name + ' back to ' +
                         TestVApp._empty_vapp_owner_name)
            original_owner_href = Environment.get_user_href_in_test_org(
                TestVApp._empty_vapp_owner_name)
            vapp.change_owner(original_owner_href)
            vapp.reload()
            self.assertEqual(vapp.get_resource().Owner.User.get('name'),
                             TestVApp._empty_vapp_owner_name)
        finally:
            org_admin_client.logout()
开发者ID:vmware,项目名称:pyvcloud,代码行数:39,代码来源:vapp_tests.py

示例5: test_0050_vdc_acl

# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_username_for_role_in_test_org [as 别名]
    def test_0050_vdc_acl(self):
        """Test the methods related to access control list in vdc.py.

        This test passes if all the acl operations are successful.
        """
        logger = Environment.get_default_logger()
        vdc = VDC(TestOrgVDC._client, href=TestOrgVDC._new_vdc_href)
        vdc_name = TestOrgVDC._new_vdc_name

        vapp_user_name = Environment.get_username_for_role_in_test_org(
            CommonRoles.VAPP_USER)
        console_user_name = Environment.get_username_for_role_in_test_org(
            CommonRoles.CONSOLE_ACCESS_ONLY)

        # remove all
        logger.debug('Removing all access control from vdc ' + vdc_name)
        control_access = vdc.remove_access_settings(remove_all=True)
        self.assertFalse(hasattr(control_access, 'AccessSettings'))

        # add
        logger.debug('Adding 2 access control rule to vdc ' + vdc_name)
        vdc.reload()
        control_access = vdc.add_access_settings(
            access_settings_list=[{
                'name': vapp_user_name,
                'type': 'user'
            }, {
                'name': console_user_name,
                'type': 'user',
                'access_level': 'ReadOnly'
            }])
        self.assertEqual(len(control_access.AccessSettings.AccessSetting), 2)

        # get
        logger.debug('Fetching access control rules for vdc ' + vdc_name)
        vdc.reload()
        control_access = vdc.get_access_settings()
        self.assertEqual(len(control_access.AccessSettings.AccessSetting), 2)

        # remove
        logger.debug('Removing 1 access control rule for vdc ' + vdc_name)
        control_access = vdc.remove_access_settings(
            access_settings_list=[{
                'name': vapp_user_name,
                'type': 'user'
            }])
        self.assertEqual(len(control_access.AccessSettings.AccessSetting), 1)

        # share
        logger.debug('Sharing vdc ' + vdc_name + ' with everyone in the org')
        vdc.reload()
        control_access = vdc.share_with_org_members()
        self.assertEqual(control_access.IsSharedToEveryone.text, 'true')
        self.assertEqual(control_access.EveryoneAccessLevel.text, 'ReadOnly')

        # unshare
        logger.debug(
            'Un-sharing vdc ' + vdc_name + ' from everyone in the org')
        vdc.reload()
        control_access = vdc.unshare_from_org_members()
        self.assertEqual(control_access.IsSharedToEveryone.text, 'false')

        # re-share, before performing any other ACL operation to avoid
        # running into https://github.com/vmware/pyvcloud/issues/279
        logger.debug('Re-sharing vdc ' + vdc_name + ' with everyone in the ' +
                     'org')
        vdc.reload()
        control_access = vdc.share_with_org_members()
        self.assertEqual(control_access.IsSharedToEveryone.text, 'true')
        self.assertEqual(control_access.EveryoneAccessLevel.text, 'ReadOnly')

        # remove the last access setting
        logger.debug('Removing the last remaining access control from'
                     ' vdc ' + vdc_name)
        vdc.reload()
        control_access = vdc.remove_access_settings(remove_all=True)
        self.assertFalse(hasattr(control_access, 'AccessSettings'))
开发者ID:vmware,项目名称:pyvcloud,代码行数:79,代码来源:vdc_tests.py

示例6: test_0070_vapp_acl

# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_username_for_role_in_test_org [as 别名]
    def test_0070_vapp_acl(self):
        """Test the method related to access control list in vapp.py.

        This test passes if all the acl operations are successful.
        """
        logger = Environment.get_default_logger()
        vapp_name = TestVApp._customized_vapp_name
        vapp = Environment.get_vapp_in_test_vdc(
            client=TestVApp._client, vapp_name=vapp_name)

        vapp_user_name = Environment.get_username_for_role_in_test_org(
            CommonRoles.VAPP_USER)
        console_user_name = Environment.get_username_for_role_in_test_org(
            CommonRoles.CONSOLE_ACCESS_ONLY)

        # remove all
        logger.debug('Removing all access control from vApp ' + vapp_name)
        control_access = vapp.remove_access_settings(remove_all=True)
        self.assertFalse(hasattr(control_access, 'AccessSettings'))

        # add
        logger.debug('Adding 2 access control rule to vApp ' + vapp_name)
        vapp.reload()
        access_settings_list = [{
            'name': console_user_name,
            'type': 'user'
        }, {
            'name': vapp_user_name,
            'type': 'user',
            'access_level': 'Change'
        }]
        control_access = vapp.add_access_settings(access_settings_list)
        self.assertEqual(len(control_access.AccessSettings.AccessSetting), 2)

        # get
        logger.debug('Fetching access control rules for vApp ' + vapp_name)
        vapp.reload()
        control_access = vapp.get_access_settings()
        self.assertEqual(len(control_access.AccessSettings.AccessSetting), 2)

        # remove
        logger.debug('Removing 1 access control rule for vApp ' + vapp_name)
        vapp.reload()
        control_access = vapp.remove_access_settings(
            access_settings_list=[{
                'name': vapp_user_name,
                'type': 'user'
            }])
        self.assertEqual(len(control_access.AccessSettings.AccessSetting), 1)

        # share
        logger.debug('Sharing vApp ' + vapp_name + ' with everyone in the org')
        vapp.reload()
        control_access = vapp.share_with_org_members(
            everyone_access_level='ReadOnly')
        self.assertEqual(control_access.IsSharedToEveryone.text, 'true')
        self.assertEqual(control_access.EveryoneAccessLevel.text, 'ReadOnly')

        # unshare
        logger.debug('Un-sharing vApp ' + vapp_name +
                     ' from everyone in the org')
        vapp.reload()
        control_access = vapp.unshare_from_org_members()
        self.assertEqual(control_access.IsSharedToEveryone.text, 'false')

        # remove all access control rules again
        logger.debug('Removing all access control from vApp ' + vapp_name)
        control_access = vapp.remove_access_settings(remove_all=True)
        self.assertFalse(hasattr(control_access, 'AccessSettings'))
开发者ID:vmware,项目名称:pyvcloud,代码行数:71,代码来源:vapp_tests.py

示例7: _0110_catalog_access_settings

# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_username_for_role_in_test_org [as 别名]
    def _0110_catalog_access_settings(self):
        """Test the access control methods for catalogs.

        This test passes if all the acl operations complete successfully.
        """
        logger = Environment.get_default_logger()
        org = Environment.get_test_org(TestCatalog._client)

        org_name = org.get_name()
        print(org_name)
        catalog_name = TestCatalog._test_catalog_name
        vapp_author_username = Environment.get_username_for_role_in_test_org(
            CommonRoles.VAPP_AUTHOR)
        org_admin_username = Environment.get_username_for_role_in_test_org(
            CommonRoles.ORGANIZATION_ADMINISTRATOR)

        # remove all access control settings to the catalog
        logger.debug('Removing all access control settings from catalog:' +
                     catalog_name)
        control_access = org.remove_catalog_access_settings(catalog_name,
                                                            remove_all=True)
        self.assertFalse(hasattr(control_access, 'AccessSettings'))

        # add three access control settings to the catalog
        logger.debug('Adding three acl rule to the catalog:' + catalog_name)
        control_access = org.add_catalog_access_settings(
            catalog_name,
            access_settings_list=[{
                'name': vapp_author_username,
                'type': 'user',
                'access_level': 'ReadOnly'
            }, {
                'name': org_admin_username,
                'type': 'user',
                'access_level': 'Change'
            }, {
                'name': org_name,
                'type': 'org',
                'access_level': 'ReadOnly'
            }])
        self.assertEqual(len(control_access.AccessSettings.AccessSetting),
                         3)
        # TODO() : Test that vapp author can actually access the catalog

        # retrieve access control settings of the catalog
        logger.debug('Retrieving acl rule from catalog:' + catalog_name)
        control_access = org.get_catalog_access_settings(catalog_name)
        self.assertEqual(len(control_access.AccessSettings.AccessSetting),
                         3)

        # remove partial access control settings from the catalog
        logger.debug('Removing 2 acl rule from catalog:' + catalog_name)
        control_access = org.remove_catalog_access_settings(
            catalog_name,
            access_settings_list=[{
                'name': org_admin_username,
                'type': 'user'
            }, {
                'name': org_name,
                'type': 'org'
            }])
        self.assertEqual(len(control_access.AccessSettings.AccessSetting),
                         1)

        # test removal of non existing access control settings from the catalog
        logger.debug('Trying to remove non existent acl rule from catalog:' +
                     catalog_name)
        try:
            org.remove_catalog_access_settings(
                catalog_name,
                access_settings_list=[{
                    'name': org_admin_username,
                    'type': 'user'
                }])
            self.fail('Removing non existing acl should fail.')
        except EntityNotFoundException:
            pass

        # remove all access control settings from the catalog
        logger.debug('Removing all access control settings from catalog:' +
                     catalog_name)
        control_access = org.remove_catalog_access_settings(
            catalog_name, remove_all=True)
        self.assertFalse(hasattr(control_access, 'AccessSettings'))
开发者ID:vmware,项目名称:pyvcloud,代码行数:86,代码来源:catalog_tests.py


注:本文中的pyvcloud.system_test_framework.environment.Environment.get_username_for_role_in_test_org方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。