def test_rename_organization(self, context):
     step("Create an organization")
     test_org = Organization.api_create(context)
     step("Update the organization, giving it new name")
     new_name = "new-{}".format(test_org.name)
     test_org.rename(new_name)
     step(
         "Check that the organization with new name is on the organization list"
     )
     orgs = Organization.api_get_list()
     assert test_org in orgs
 def test_create_delete_organization(self, context):
     step("Create an organization")
     test_org = Organization.api_create(context)
     step("Check that the organization is on the organization list")
     orgs = Organization.api_get_list()
     assert test_org in orgs
     step("Delete the organization")
     test_org.api_delete()
     step("Check that the organization is not on org list")
     assertions.assert_not_in_with_retry(test_org,
                                         Organization.api_get_list)
def test_create_and_delete_organization(context):
    """Create and Delete Organization"""
    step("Create organization")
    test_org = Organization.create(context)
    step("Check that organization is on the list")
    orgs = Organization.get_list()
    assert test_org in orgs
    step("Delete organization")
    test_org.delete()
    step("Check that the organization is not on the list")
    assertions.assert_not_in_with_retry(test_org, Organization.api_get_list)
 def test_create_and_delete_org_with_special_name(self, org_name, context):
     step("Create an organization")
     test_org = Organization.api_create(context, name=org_name)
     assert org_name == test_org.name
     step("Check that the organization is on the organization list")
     orgs = Organization.api_get_list()
     assert test_org in orgs
     step("Delete the organization")
     test_org.api_delete()
     step("Check that the organization is not on org list")
     assertions.assert_not_in_with_retry(test_org,
                                         Organization.api_get_list)
Beispiel #5
0
def core_org():
    log_fixture("core_org: Create object for core org")
    ref_org_name = config.core_org_name
    orgs = Organization.get_list()
    core_org = next((o for o in orgs if o.name == ref_org_name), None)
    assert core_org is not None, "Could not find org {}".format(ref_org_name)
    return core_org
Beispiel #6
0
 def setup(cls, request, test_org_manager, test_org_manager_client,
           class_context):
     cls.step("Create test org")
     cls.test_org = Organization.api_create(class_context)
     cls.step("Add org manager")
     cls.org_manager = test_org_manager
     cls.org_manager_client = test_org_manager_client
     cls.org_manager.api_add_to_organization(org_guid=cls.test_org.guid)
 def __init__(self):
     self.apps = len(Application.cf_api_get_list())
     self.service_instances = len(ServiceInstance.cf_api_get_list())
     self.services = len(ServiceType.cf_api_get_list())
     self.buildpacks = len(Buildpack.cf_api_get_list())
     self.orgs = len(Organization.cf_api_get_list())
     self.spaces = len(Space.cf_api_get_list())
     self.users = len(User.cf_api_get_all_users())
Beispiel #8
0
 def test_cannot_submit_transfer_in_foreign_org(self, context):
     foreign_org = Organization.api_create(context=context)
     assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN,
                                  HttpStatus.MSG_FORBIDDEN,
                                  self._create_transfer,
                                  context,
                                  org_guid=foreign_org.guid,
                                  category=self.DEFAULT_CATEGORY)
Beispiel #9
0
 def test_0_no_clusters_for_new_organization(self, class_context):
     step("Get list of clusters")
     clusters_before = KubernetesCluster.demiurge_api_get_list()
     step("Create organization and space")
     self.__class__.test_org = Organization.api_create(class_context)
     self.__class__.test_space = Space.api_create(org=self.test_org)
     step("Check that there are no new clusters created")
     clusters_after = KubernetesCluster.demiurge_api_get_list()
     assert len(clusters_before) == len(clusters_after)
Beispiel #10
0
def test_onboarding(context):
    """Test Onboarding"""
    step("Onboard new user")
    test_user, test_org = onboarding.onboard(context, check_email=False)
    step("Check that user is created")
    users = User.cf_api_get_all_users()
    assert test_user in users
    step("Check that organization is created")
    org_list = Organization.api_get_list()
    assert test_org in org_list
Beispiel #11
0
 def test_user_not_in_org_cannot_get_org_users(self):
     self.step("Create new org")
     org = Organization.api_create(self.context)
     self.step(
         "Check that the user cannot get list of users in the test org")
     self.assertRaisesUnexpectedResponse(HttpStatus.CODE_FORBIDDEN,
                                         HttpStatus.MSG_FORBIDDEN,
                                         User.api_get_list_via_organization,
                                         org_guid=org.guid,
                                         client=self.manager_client)
 def test_delete_organization_with_user(self, context):
     step("Create an organization")
     test_org = Organization.api_create(context)
     step("Add new platform user to the organization")
     User.api_create_by_adding_to_organization(context, test_org.guid)
     step("Delete the organization")
     test_org.api_delete()
     step("Check that the organization is not on org list")
     assertions.assert_not_in_with_retry(test_org,
                                         Organization.api_get_list)
 def org_space_app(self, context):
     step("Create test organization and space")
     test_org = Organization.api_create(context)
     test_space = Space.api_create(test_org)
     step("Login to cf targeting test org and test space")
     cf.cf_login(test_org.name, test_space.name)
     step("Push example app")
     example_app_path = ApplicationPath.SAMPLE_PYTHON_APP
     test_app = Application.push(context, space_guid=test_space.guid, source_directory=example_app_path)
     return test_org, test_space, test_app
 def test_non_admin_cannot_delete_org(self, test_org_manager_client,
                                      context):
     step("Create an organization")
     test_org = Organization.api_create(context)
     step("Attempt to delete the organization with the non admin client")
     assertions.assert_raises_http_exception(
         UserManagementHttpStatus.CODE_FORBIDDEN,
         UserManagementHttpStatus.MSG_FORBIDDEN,
         test_org.api_delete,
         client=test_org_manager_client)
 def test_delete_organization_with_space(self, context):
     step("Create an organization")
     test_org = Organization.api_create(context)
     step("Create a space")
     Space.api_create(org=test_org)
     step("Delete the organization")
     test_org.api_delete()
     step("Check that the organization is not on org list")
     assertions.assert_not_in_with_retry(test_org,
                                         Organization.api_get_list)
    def users(cls, request, admin_client, test_org_manager, test_org_manager_client, class_context):
        cls.context = class_context  # TODO no longer needed when this class removes unittest dependency
        cls.step("Create test organization")
        cls.test_org = Organization.api_create(class_context)
        cls.step("Create users for tests")
        cls.manager = User.api_create_by_adding_to_organization(class_context, org_guid=cls.test_org.guid,
                                                                roles=User.ORG_ROLES["manager"])
        cls.manager_client = cls.manager.login()
        cls.updated_user = User.api_create_by_adding_to_organization(class_context, org_guid=cls.test_org.guid, roles=[])

        cls.user_not_in_test_org = test_org_manager
        cls.client_not_in_test_org = test_org_manager_client
Beispiel #17
0
def test_org(request):
    context = Context()
    log_fixture("test_org: Create test organization")
    test_org = Organization.api_create(context)
    TestData.test_org = test_org

    def fin():
        log_finalizer("test_org: Delete test organization")
        context.cleanup()

    request.addfinalizer(fin)

    return test_org
 def test_cannot_get_users_in_another_org(self, context,
                                          test_org_user_clients,
                                          client_key):
     step("Create new organization")
     org = Organization.create(context)
     step(
         "Check that a user or org admin not in an org cannot get list of users in the org"
     )
     client = test_org_user_clients[client_key]
     assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN,
                                  HttpStatus.MSG_FORBIDDEN,
                                  User.get_list_in_organization,
                                  org_guid=org.guid,
                                  client=client)
 def test_0_check_hdfs_directory_is_created_for_new_org(
         self, class_context):
     step("Create test organization")
     self.__class__.test_org = Organization.api_create(class_context)
     hdfs_dirs = self._list_hdfs_directories("org")
     self._assert_directory_in_hdfs(hdfs_dirs,
                                    name=self.test_org.guid,
                                    owner="{}_admin".format(
                                        self.test_org.guid),
                                    group=self.test_org.guid)
     self._assert_directory_contains_subdirectories(name=self.test_org.guid)
     step("Check that organization namespace was created in hbase")
     org_namespace = self.test_org.guid.replace("-", "")
     assert org_namespace in self._get_hbase_namespaces(
         self.HBASE_PATH), "Organization namespace was not found"
Beispiel #20
0
    def from_reference(cls, org_guid):
        from modules.tap_object_model import Application, User, Organization, ServiceOffering, ServiceInstance, DataSet
        metrics = []
        app_down_states = [TapEntityState.FAILURE, TapEntityState.STOPPED]

        apps = Application.get_list()
        apps_count = len(apps)
        apps_running_count = len(
            [app for app in apps if app.state == TapEntityState.RUNNING])
        apps_down_count = len(
            [app for app in apps if app.state in app_down_states])
        user_count = len(User.get_all_users(org_guid))
        orgs_count = len(Organization.get_list())
        services_count = len(ServiceOffering.get_list())
        services_inst = len([
            instance for instance in ServiceInstance.get_list()
            if instance.state == TapEntityState.RUNNING
        ])

        nodes = KubernetesNode.get_list()
        for node in nodes:
            metrics.append(node.get_metrics())

        cpu_usage_org = cls.parse_cpu(metrics) / (cls.CPU_RATE_FOR_REF *
                                                  cls.NODE)
        cpu_usage_platform = cls.parse_cpu(metrics) / (cls.CPU_RATE_FOR_REF *
                                                       cls.NODE)
        memory_usage_org = cls.parse_memory(metrics)
        memory_usage_platform = cls.parse_memory(metrics)

        datasets = DataSet.api_get_list(org_guid_list=[org_guid])

        return cls(apps=apps_count,
                   apps_running=apps_running_count,
                   apps_down=apps_down_count,
                   users_org=user_count,
                   users_platform=user_count,
                   orgs=orgs_count,
                   services=services_count,
                   service_instances=services_inst,
                   service_usage=services_inst,
                   cpu_usage_org=cpu_usage_org,
                   memory_usage_org=memory_usage_org,
                   cpu_usage_platform=cpu_usage_platform,
                   memory_usage_platform=memory_usage_platform,
                   datasets=datasets)
Beispiel #21
0
 def test_get_data_sets_from_another_org(self, context):
     step("Create another test organization")
     org = Organization.create(context)
     step("Retrieve datasets from the new org")
     public_datasets = [ds for ds in self.datasets if ds.is_public]
     private_datasets = [ds for ds in self.datasets if not ds.is_public]
     datasets = [
         ds for ds in DataSet.api_get_list(org_guid_list=[org.guid])
     ]
     step("Check that no private data sets are visible in another org")
     found_private_ds = [ds for ds in private_datasets if ds in datasets]
     assert found_private_ds == [], "Private datasets from another org returned"
     step("Check that all public data sets are visible in another org")
     missing_public_ds = [
         ds for ds in public_datasets if ds not in datasets
     ]
     assert missing_public_ds == [], "Not all public data sets from another org returned"
Beispiel #22
0
def test_login():
    """
    <b>Description:</b>
    Checks if login to platform works.

    <b>Input data:</b>
    1. User name.
    2. Password.

    <b>Expected results:</b>
    Test passes when user was logged successfully into platform.

    <b>Steps:</b>
    1. Log into platform.
    2. Get organization list and verify that it's not None.
    """
    orgs_list = Organization.get_list()
    assert orgs_list is not None
Beispiel #23
0
 def user_clients(cls, request, test_org, test_space, class_context):
     cls.context = class_context  # TODO move to methods when dependency on unittest is removed
     second_test_org = Organization.api_create(class_context)
     org_manager = User.api_create_by_adding_to_organization(
         class_context, test_org.guid)
     space_manager_in_org = User.api_create_by_adding_to_space(
         class_context, test_org.guid, test_space.guid)
     org_user = User.api_create_by_adding_to_organization(
         class_context, test_org.guid, roles=User.ORG_ROLES["auditor"])
     other_org_manager = User.api_create_by_adding_to_organization(
         class_context, second_test_org.guid)
     other_user = User.api_create_by_adding_to_organization(
         class_context, second_test_org.guid, roles=[])
     cls.user_clients = {
         "admin": HttpClientFactory.get(ConsoleConfigurationProvider.get()),
         "org_manager": org_manager.login(),
         "space_manager_in_org": space_manager_in_org.login(),
         "org_user": org_user.login(),
         "other_org_manager": other_org_manager.login(),
         "other_user": other_user.login()
     }
 def org_space(self, context):
     step("Create test organization and space")
     test_org = Organization.api_create(context)
     test_space = Space.api_create(test_org)
     return test_org, test_space
Beispiel #25
0
 def org(self, class_context):
     return Organization.api_create(class_context)
Beispiel #26
0
if __name__ == "__main__":

    all_data_sets = DataSet.api_get_list()
    test_data_sets = [x for x in all_data_sets if is_test_object_name(x.title)]
    log_deleted_objects(test_data_sets, "data set")
    fixtures.tear_down_test_objects(test_data_sets)

    all_transfers = Transfer.api_get_list()
    test_transfers = [x for x in all_transfers if is_test_object_name(x.title)]
    log_deleted_objects(test_transfers, "transfer")
    fixtures.tear_down_test_objects(test_transfers)

    all_users = User.cf_api_get_all_users()
    test_users = [x for x in all_users if is_test_object_name(x.username)]
    log_deleted_objects(test_users, "user")
    fixtures.tear_down_test_objects(test_users)

    all_pending_invitations = Invitation.api_get_list()
    test_invitations = [
        x for x in all_pending_invitations if is_test_object_name(x.username)
    ]
    log_deleted_objects(test_invitations, "invitation")
    fixtures.tear_down_test_objects(test_invitations)

    all_orgs = Organization.cf_api_get_list()
    test_orgs = [x for x in all_orgs if is_test_object_name(x.name)]
    log_deleted_objects(test_orgs, "organization")
    fixtures.tear_down_test_objects(test_orgs, )

    remove_hive_databases()
 def setup(cls, class_context):
     cls.step("Create test org")
     cls.test_org = Organization.api_create(class_context)
     cls.step("Add org manager")
     User.api_create_by_adding_to_organization(class_context,
                                               org_guid=cls.test_org.guid)
Beispiel #28
0
def core_org():
    log_fixture("core_org: Create object for core org")
    ref_org_name = config.core_org_name
    orgs = Organization.cf_api_get_list()
    TestData.core_org = next(o for o in orgs if o.name == ref_org_name)
    return TestData.core_org
Beispiel #29
0
 def another_org(self, context):
     step("Create another test organization")
     another_org = Organization.api_create(context)
     return another_org
 def another_org(self, context):
     step("Create test organization")
     return Organization.create(context)