예제 #1
0
    def test_0060_vdc_metadata(self):
        """Test the methods related to metadata manipulation in vdc.py.

        This test passes if all the metadata operations are successful.
        """
        vapp_author_client = None
        sys_admin_client = None
        try:
            logger = Environment.get_default_logger()

            vapp_author_client = Environment.get_client_in_default_org(
                CommonRoles.VAPP_AUTHOR)
            vdc_vapp_author_view = VDC(client=vapp_author_client,
                                       href=TestOrgVDC._new_vdc_href)

            sys_admin_client = Environment.get_sys_admin_client()
            vdc_sys_admin_view = VDC(client=sys_admin_client,
                                     href=TestOrgVDC._new_vdc_href)

            # try to add new metadata as vapp author
            try:
                logger.debug(f'Adding metadata [key={TestOrgVDC._metadata_key}'
                             ', value={TestOrgVDC._metadata_value}]) as vApp '
                             'author')
                vdc_vapp_author_view.set_metadata(
                    key=TestOrgVDC._metadata_key,
                    value=TestOrgVDC._metadata_value)
                self.assertFail('vApp author shouldn\'t have been able to '
                                'add new metadta entry.')
            except OperationNotSupportedException as e:
                pass

            # add new metadata as sys admin
            logger.debug(f'Adding metadata [key={TestOrgVDC._metadata_key},'
                         'value={TestOrgVDC._metadata_value}]) as Sys admin.')
            task = vdc_sys_admin_view.set_metadata(
                key=TestOrgVDC._metadata_key,
                value=TestOrgVDC._metadata_value)
            result = sys_admin_client.get_task_monitor().wait_for_success(task)
            self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)

            # retrieve metadata as vapp author
            logger.debug(f'Retriving metadata with key='
                         '{TestOrgVDC._metadata_key} as vApp author.')
            metadata_value = vdc_vapp_author_view.get_metadata_value(
                key=TestOrgVDC._metadata_key)
            self.assertEqual(extract_metadata_value(metadata_value),
                             TestOrgVDC._metadata_value)

            # try to retrieve non existent metadata entry
            try:
                logger.debug(f'Retriving metadata with invalid key='
                             '{TestOrgVDC._non_existent_metadata_key} as vApp '
                             'author')
                metadata_value = vdc_vapp_author_view.get_metadata_value(
                    key=TestOrgVDC._non_existent_metadata_key)
                self.assertFail('Shouldn\'t have been able to retrieve metadta'
                                ' entry with bad key.')
            except AccessForbiddenException as e:
                pass

            # try to update metadata value as vapp author
            try:
                logger.debug(f'Trying to update metadata with key='
                             '{TestOrgVDC._metadata_key} to value='
                             '{TestOrgVDC._metadata_new_value} as vApp '
                             'author.')
                vdc_vapp_author_view.set_metadata(
                    key=TestOrgVDC._metadata_key,
                    value=TestOrgVDC._metadata_new_value)
                self.assertFail('Shouldn\'t have been able to update metadta'
                                ' entry as vApp author.')
            except OperationNotSupportedException as e:
                pass

            # update metadata value as sys admin
            logger.debug(f'Updtaing metadata with key='
                         '{TestOrgVDC._metadata_key} to value='
                         '{TestOrgVDC._metadata_new_value} as Sys Admin.')
            task = vdc_sys_admin_view.set_metadata(
                key=TestOrgVDC._metadata_key,
                value=TestOrgVDC._metadata_new_value)
            sys_admin_client.get_task_monitor().wait_for_success(task)
            metadata_value = vdc_sys_admin_view.get_metadata_value(
                key=TestOrgVDC._metadata_key)
            self.assertEqual(extract_metadata_value(metadata_value),
                             TestOrgVDC._metadata_new_value)

            # try to remove metadata as vapp author
            try:
                logger.debug(f'Trying to remove metadata with key='
                             '{TestOrgVDC._metadata_key} as vApp author.')
                task = vdc_vapp_author_view.remove_metadata(
                    key=TestOrgVDC._metadata_key)
                self.assertFail('Shouldn\'t have been able to remove metadta '
                                'entry as vApp author.')
            except OperationNotSupportedException as e:
                pass

            # remove metadata entry as sys admin
            logger.debug(f'Removing metadata with '
                         'key={TestOrgVDC._metadata_key},as Sys Admin.')
            task = vdc_sys_admin_view.remove_metadata(
                key=TestOrgVDC._metadata_key)
            result = sys_admin_client.get_task_monitor().wait_for_success(task)
            self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
        finally:
            if sys_admin_client is not None:
                sys_admin_client.logout()
            if vapp_author_client is not None:
                vapp_author_client.logout()
예제 #2
0
 def test_0060_vdc_metadata(self):
     """Test the methods related to metadata manipulation in vdc.py.
     This test passes if all the metadata operations are successful.
     """
     vapp_author_client = None
     sys_admin_client = None
     try:
         logger = Environment.get_default_logger()
         vapp_author_client = Environment.get_client_in_default_org(
             CommonRoles.VAPP_AUTHOR)
         vdc_vapp_author_view = VDC(client=vapp_author_client,
                                    href=get_non_admin_href(
                                        TestOrgVDC._new_vdc_href))
         sys_admin_client = Environment.get_sys_admin_client()
         vdc_sys_admin_view = VDC(client=sys_admin_client,
                                  href=TestOrgVDC._new_vdc_href)
         # try to add new metadata as vapp author
         try:
             logger.debug(f'Adding metadata [key={TestOrgVDC._metadata_key}'
                          ', value={TestOrgVDC._metadata_value}]) as vApp '
                          'author')
             vdc_vapp_author_view.set_metadata(
                 key=TestOrgVDC._metadata_key,
                 value=TestOrgVDC._metadata_value)
             self.assertFail('vApp author shouldn\'t have been able to '
                             'add new metadta entry.')
         except OperationNotSupportedException as e:
             pass
         # add new metadata as sys admin
         logger.debug(f'Adding metadata [key={TestOrgVDC._metadata_key},'
                      'value={TestOrgVDC._metadata_value}]) as Sys admin.')
         task = vdc_sys_admin_view.set_metadata(
             key=TestOrgVDC._metadata_key, value=TestOrgVDC._metadata_value)
         result = sys_admin_client.get_task_monitor().wait_for_success(task)
         self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
         # retrieve metadata as vapp author
         logger.debug(f'Retriving metadata with key='
                      '{TestOrgVDC._metadata_key} as vApp author.')
         metadata_value = vdc_vapp_author_view.get_metadata_value(
             key=TestOrgVDC._metadata_key)
         self.assertEqual(extract_metadata_value(metadata_value),
                          TestOrgVDC._metadata_value)
         # try to retrieve non existent metadata entry
         try:
             logger.debug(f'Retriving metadata with invalid key='
                          '{TestOrgVDC._non_existent_metadata_key} as vApp '
                          'author')
             metadata_value = vdc_vapp_author_view.get_metadata_value(
                 key=TestOrgVDC._non_existent_metadata_key)
             self.assertFail('Shouldn\'t have been able to retrieve metadta'
                             ' entry with bad key.')
         except AccessForbiddenException as e:
             pass
         # try to update metadata value as vapp author
         try:
             logger.debug(f'Trying to update metadata with key='
                          '{TestOrgVDC._metadata_key} to value='
                          '{TestOrgVDC._metadata_new_value} as vApp '
                          'author.')
             vdc_vapp_author_view.set_metadata(
                 key=TestOrgVDC._metadata_key,
                 value=TestOrgVDC._metadata_new_value)
             self.assertFail('Shouldn\'t have been able to update metadta'
                             ' entry as vApp author.')
         except OperationNotSupportedException as e:
             pass
         # update metadata value as sys admin
         logger.debug(f'Updtaing metadata with key='
                      '{TestOrgVDC._metadata_key} to value='
                      '{TestOrgVDC._metadata_new_value} as Sys Admin.')
         task = vdc_sys_admin_view.set_metadata(
             key=TestOrgVDC._metadata_key,
             value=TestOrgVDC._metadata_new_value)
         sys_admin_client.get_task_monitor().wait_for_success(task)
         metadata_value = vdc_sys_admin_view.get_metadata_value(
             key=TestOrgVDC._metadata_key)
         self.assertEqual(extract_metadata_value(metadata_value),
                          TestOrgVDC._metadata_new_value)
         # try to remove metadata as vapp author
         try:
             logger.debug(f'Trying to remove metadata with key='
                          '{TestOrgVDC._metadata_key} as vApp author.')
             task = vdc_vapp_author_view.remove_metadata(
                 key=TestOrgVDC._metadata_key)
             self.assertFail('Shouldn\'t have been able to remove metadta '
                             'entry as vApp author.')
         except OperationNotSupportedException as e:
             pass
         # remove metadata entry as sys admin
         logger.debug(f'Removing metadata with '
                      'key={TestOrgVDC._metadata_key},as Sys Admin.')
         task = vdc_sys_admin_view.remove_metadata(
             key=TestOrgVDC._metadata_key)
         result = sys_admin_client.get_task_monitor().wait_for_success(task)
         self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
     finally:
         if sys_admin_client is not None:
             sys_admin_client.logout()
         if vapp_author_client is not None:
             vapp_author_client.logout()
예제 #3
0
    def test_0110_catalog_item_metadata(self):
        """Test the methods related to metadata manipulation in catalog item.

        This test passes if all the metadata operations are successful.
        """
        print("Executing CatalogItem metadata ")

        sys_admin_client = None

        try:
            logger = Environment.get_default_logger()
            sys_admin_client = Environment.get_sys_admin_client()
            org_sys_admin = Environment.get_test_org(sys_admin_client)

            # add new metadata as sys admin
            logger.debug(f'Adding metadata '
                         f'[key={TestCatalog._test_metadata_key},'
                         f'value={TestCatalog._test_metadata_value}]) '
                         f'as Sys admin.')
            task = org_sys_admin.set_metadata_on_catalog_item(
                TestCatalog._test_catalog_name,
                TestCatalog._test_template_name,
                key=TestCatalog._test_metadata_key,
                value=TestCatalog._test_metadata_value)
            result = sys_admin_client.get_task_monitor().wait_for_success(task)
            self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)

            # retrieve existing metadata as sys admin
            logger.debug(f'Retrieving metadata '
                         f'[key={TestCatalog._test_metadata_key},'
                         f'value={TestCatalog._test_metadata_value}]) '
                         f'as Sys admin.')
            metadata_value = org_sys_admin.\
                get_metadata_value_from_catalog_item(
                    TestCatalog._test_catalog_name,
                    TestCatalog._test_template_name,
                    key=TestCatalog._test_metadata_key)
            self.assertEqual(extract_metadata_value(metadata_value),
                             TestCatalog._test_metadata_value)

            # retrieve non-existing metadata as sys admin
            try:
                logger.debug(f'Retrieving metadata '
                             f'[invalid key={TestCatalog._test_metadata_key},'
                             f'value={TestCatalog._test_metadata_value}]) '
                             f'as Sys admin.')
                metadata_value = org_sys_admin.\
                    get_metadata_value_from_catalog_item(
                        TestCatalog._test_catalog_name,
                        TestCatalog._test_template_name,
                        key=TestCatalog._test_non_existent_metadata_key)
                self.assertFail('Shouldn\'t have been able to retrieve'
                                ' metadata entry with bad key.')
            except AccessForbiddenException:
                pass

            # update existing metadata as sys admin with new value
            logger.debug(f'Update metadata '
                         f'[key={TestCatalog._test_metadata_key},'
                         f'value={TestCatalog._test_metadata_new_value}]) '
                         f'as Sys admin.')
            task = org_sys_admin.set_metadata_on_catalog_item(
                TestCatalog._test_catalog_name,
                TestCatalog._test_template_name,
                key=TestCatalog._test_metadata_key,
                value=TestCatalog._test_metadata_new_value)
            sys_admin_client.get_task_monitor().wait_for_success(task)
            metadata_value = org_sys_admin.\
                get_metadata_value_from_catalog_item(
                    TestCatalog._test_catalog_name,
                    TestCatalog._test_template_name,
                    key=TestCatalog._test_metadata_key)
            self.assertEqual(extract_metadata_value(metadata_value),
                             TestCatalog._test_metadata_new_value)

            # Remove existing metadata as sys admin
            logger.debug(f'Remove metadata '
                         f'[key={TestCatalog._test_metadata_key},'
                         f'value={TestCatalog._test_metadata_new_value}]) '
                         f'as Sys admin.')
            task = org_sys_admin.remove_metadata_from_catalog_item(
                TestCatalog._test_catalog_name,
                TestCatalog._test_template_name,
                key=TestCatalog._test_metadata_key)
            self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)

        finally:
            if sys_admin_client is not None:
                sys_admin_client.logout()