def test_cannot_get_parsed_template_with_invalid_instance_id(
            self, sample_template):
        """
        <b>Description:</b>
        Checks if getting parsed template with invalid instance id fails.

        <b>Input data:</b>
        1. Sample template id.

        <b>Expected results:</b>
        It is not possible to get parsed template with invalid instance id.

        <b>Steps:</b>
        1. Create sample template.
        2. Try to get parsed template with invalid instance id.
        3. Verify that HTTP response status code is 400 with proper message.
        """
        step("Getting parsed template with invalid instanceId causes an error")
        instance_id = "1fef0d"
        assert_raises_http_exception(
            HttpStatus.CODE_BAD_REQUEST,
            TemplateRepositoryHttpStatus.MSG_TOO_SHORT_INSTANCE_ID,
            Template.get_parsed,
            template_id=sample_template.id,
            instance_id=instance_id)
Exemple #2
0
    def test_expose_service_without_hostname(self, catalog_instance_nats):
        """
        <b>Description:</b>
        Try to expose service instance without hostname

        <b>Input data:</b>
        - Container broker instance.
        - Port.

        <b>Expected results:</b>
        It is not possible to expose service without hostname.

        <b>Steps:</b>
        - Try to expose service instance.
        - Verify that HTTP response status code is 400 with proper message.
        """
        nats_instance = ContainerBrokerInstance(
            instance_id=catalog_instance_nats.id)
        body = {"ports": [self.PORT]}
        step("Try to expose service instance without hostname")
        expected_msg = ContainerBrokerHttpStatus.MSG_EMPTY_HOSTNAME.format(
            catalog_instance_nats.id, "-{}.{}".format(self.PORT,
                                                      config.tap_domain))
        assertions.assert_raises_http_exception(
            ContainerBrokerHttpStatus.CODE_BAD_REQUEST,
            expected_msg,
            nats_instance.expose_service_instance,
            hostname=None,
            ports=None,
            body=body)
Exemple #3
0
    def test_cannot_create_an_account_with_invalid_code(
            self, context, test_org):
        """
        <b>Description:</b>
        Checks if user account cannot be created with invalid registration code.

        <b>Input data:</b>
        1. Email address.
        2. User password.

        <b>Expected results:</b>
        Test passes when 403 Forbidden HTTP status is returned on attempt of registering a user without valid code.

        <b>Steps:</b>
        1. An error is returned when user registers with invalid code.
        """
        step("An error is returned when user registers with invalid code")
        username = generate_test_object_name(email=True)
        assert_raises_http_exception(
            HttpStatus.CODE_FORBIDDEN,
            HttpStatus.MSG_EMPTY,
            onboarding.register,
            context=context,
            org_guid=test_org.guid,
            code="FFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
            username=username)
    def test_cannot_create_service_instance_with_invalid_plan_id(
            self, etcd_offering, api_service_admin_client):
        """
        <b>Description:</b>
        Tries to create service instance with invalid plan id

        <b>Input data:</b>
        - Admin credentials

        <b>Expected results:</b>
        It's not possible to create service with invalid plan id

        <b>Steps:</b>
        Create a service instance with invalid plan id
        """
        valid_name = generate_test_object_name(separator="")
        step("Send create service instance request with invalid plan_id")
        assertions.assert_raises_http_exception(
            ApiServiceHttpStatus.CODE_BAD_REQUEST,
            ApiServiceHttpStatus.MSG_PLAN_CANNOT_BE_FOUND.format(
                Guid.INVALID_GUID),
            api.create_service,
            client=api_service_admin_client,
            name=valid_name,
            plan_id=Guid.INVALID_GUID,
            offering_id=etcd_offering.id,
            params=None)
    def test_2_cannot_create_service_instance_with_existing_name(
            self, class_context, instance, api_service_admin_client):
        """
        <b>Description:</b>
        Check if it's possible to create instance with the same name twice

        <b>Input data:</b>
        - service instance
        - Admin credentials

        <b>Expected results:</b>
        It's not possible to create two instances with the same name

        <b>Steps:</b>
        - Create another service instance with the same name
        """
        step("Try to create service instance with name that is already taken")
        assertions.assert_raises_http_exception(
            ApiServiceHttpStatus.CODE_CONFLICT,
            ApiServiceHttpStatus.MSG_SERVICE_INSTANCE_ALREADY_EXISTS.format(
                instance.name),
            ServiceInstance.create_with_name,
            context=class_context,
            offering_label=ServiceLabels.KAFKA,
            plan_name=ServicePlan.SHARED,
            name=instance.name,
            client=api_service_admin_client)
Exemple #6
0
    def test_cannot_update_not_existing_service_instance(
            self, catalog_service_instance):
        """
        <b>Description:</b>
        Checks if there is no possibility of updating service instance giving not-existing service instance id.

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service
        3. sample catalog service instance
        4. new classId value
        5. invalid id: 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'

        <b>Expected results:</b>
        Test passes when service instance is not updated and status code 404 with error message: '100: Key not found'
        is returned.

        <b>Steps:</b>
        1. Update service instance giving not-existing service instance id.
        """
        step(
            "Check that it's not possible to update not-existing service instance"
        )
        assert_raises_http_exception(
            CatalogHttpStatus.CODE_NOT_FOUND,
            CatalogHttpStatus.MSG_KEY_NOT_FOUND,
            catalog_api.update_service_instance,
            service_id=catalog_service_instance.class_id,
            instance_id=Guid.NON_EXISTING_GUID,
            field_name="classId",
            value=self.NEW_CLASS_ID)
Exemple #7
0
    def test_app_register_as_offering_as_user(self, context, app_jar, offering_json,
                                              manifest_json, test_user_clients):
        """
        <b>Description:</b>
        Checks if an offering can be created from an application.

        <b>Input data:</b>
        1. Sample application.
        2. Organization id

        <b>Expected results:</b>
        An offering CAN'T be created from an application as user

        <b>Steps:</b>
        1. Try to create offering and fail.
        """
        client = test_user_clients["user"]
        step("Register in marketplace as user")
        assertions.assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN,
                                                HttpStatus.MSG_FORBIDDEN,
                                                ServiceOffering.create_from_binary,
                                                context, jar_path=app_jar,
                                                manifest_path=manifest_json,
                                                offering_path=offering_json,
                                                client=client)
Exemple #8
0
 def test_cannot_delete_data_set_twice(self, dataset):
     step("Delete data set")
     dataset.api_delete()
     step("Try to delete the dataset again")
     assertions.assert_raises_http_exception(HttpStatus.CODE_NOT_FOUND,
                                             HttpStatus.MSG_EMPTY,
                                             dataset.api_delete)
Exemple #9
0
    def test_cannot_update_service_instance_class_id(self,
                                                     catalog_service_instance):
        """
        <b>Description:</b>
        Checks if there is no possibility of updating service instance field classId.

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service
        4. sample catalog service instance
        5. new classId value

        <b>Expected results:</b>
        Test passes when field classId of service instance is not updated and status code 400 with error message:
        'ClassID fields can not be changed!' is returned.

        <b>Steps:</b>
        1. Update service instance field classId
        """
        step("Check that it's not possible to update instance class id")
        assert_raises_http_exception(
            CatalogHttpStatus.CODE_BAD_REQUEST,
            CatalogHttpStatus.MSG_CLASS_ID_CANNOT_BE_CHANGED,
            catalog_service_instance.update,
            field_name="classId",
            value=self.SAMPLE_CLASS_ID)
    def test_cannot_update_catalog_template_state_to_non_existent_state(
            self, catalog_template):
        """
        <b>Description:</b>
        Checks if there is no possibility of updating template state to not-existing state.

        <b>Input data:</b>
        1. sample catalog template
        2. state: 'WRONG_STATE'

        <b>Expected results:</b>
        Test passes when template is not updated and status code 400 with error message: 'event WRONG_STATE does not
        exist' is returned.

        <b>Steps:</b>
        1. Update template state to not-existing state.
        """
        step("Update the template state to nonexistent state")
        wrong_state = "WRONG_STATE"
        expected_message = CatalogHttpStatus.MSG_EVENT_DOES_NOT_EXIST.format(
            wrong_state)
        assert_raises_http_exception(CatalogHttpStatus.CODE_BAD_REQUEST,
                                     expected_message,
                                     catalog_template.update,
                                     field_name="state",
                                     value=wrong_state)
    def test_cannot_create_the_same_offering_twice(self, context,
                                                   api_service_admin_client):
        """
        <b>Description:</b>
        Attempts to create offering twice via api service

        <b>Input data:</b>
        - Admin credentials

        <b>Expected results:</b>
        - It's not possible to create the same offering twice

        <b>Steps:</b>
        - Create the offering via api service and verify it's on the list
        - Try to create that offering again
        - Verify that catalog has not changed
        """
        step("Create new offering")
        test_offering = ServiceOffering.create(context,
                                               client=api_service_admin_client)
        step("Check that the offering exists")
        catalog = ServiceOffering.get_list(client=api_service_admin_client)
        assert test_offering in catalog
        step("Try creating offering with name of an already existing offering")
        assert_raises_http_exception(
            ApiServiceHttpStatus.CODE_CONFLICT,
            ApiServiceHttpStatus.MSG_SERVICE_ALREADY_EXISTS.format(
                test_offering.label),
            ServiceOffering.create,
            context,
            label=test_offering.label,
            client=api_service_admin_client)
        step("Check that catalog has not changed")
        assert sorted(ServiceOffering.get_list(
            client=api_service_admin_client)) == sorted(catalog)
    def test_cannot_update_catalog_template_with_wrong_prev_state_value(
            self, catalog_template):
        """
        <b>Description:</b>
        Checks if there is no possibility of updating template field state giving value state and wrong prev_value
        of state.

        <b>Input data:</b>
        1. sample catalog template in state 'READY'
        2. new value of state: 'READY'
        3. wrong prev_value of state: 'UNAVAILABLE'

        <b>Expected results:</b>
        Test passes when template is not updated and status code 400 with error message:
        '101: Compare failed ([\\\"UNAVAILABLE\\\" != \\\"IN_PROGRESS\\\"]' is returned.

        <b>Steps:</b>
        1. Update template field state giving values: state and wrong prev_value of state.
        """
        step("Update the template with incorrect prev_value of state")
        expected_message = CatalogHttpStatus.MSG_COMPARE_FAILED.format(
            TapEntityState.UNAVAILABLE, TapEntityState.IN_PROGRESS)
        assert_raises_http_exception(CatalogHttpStatus.CODE_BAD_REQUEST,
                                     expected_message,
                                     catalog_template.update,
                                     field_name="state",
                                     value=TapEntityState.READY,
                                     prev_value=TapEntityState.UNAVAILABLE)
    def test_cannot_remove_generic_service_template(
            self, generic_service_template_id, other_params):
        """
        <b>Description:</b>
        Checks if removing generic service template fails.

        <b>Input data:</b>
        1. Generic service template id.
        2. Parameters.

        <b>Expected results:</b>
        It is not possible to remove generic service template.

        <b>Steps:</b>
        1. Try to delete generic service template.
        2. Verify that HTTP response status code is 403 with proper message.
        3. Verify that generic service template was not deleted.
        """
        step("Removing generic service template should cause an error")
        assert_raises_http_exception(
            TemplateRepositoryHttpStatus.CODE_FORBIDDEN,
            TemplateRepositoryHttpStatus.MSG_REMOVE_TEMPLATE_FORBIDDEN.format(
                generic_service_template_id),
            template_repository_api.delete_template,
            template_id=generic_service_template_id)
        step("Check if template was not deleted")
        template = Template.get_parsed(template_id=generic_service_template_id,
                                       instance_id=self.INSTANCE_ID,
                                       optional_params=other_params)
        assert generic_service_template_id == template.id
    def test_cannot_get_parsed_template_without_instance_id(
            self, sample_template):
        """
        <b>Description:</b>
        Checks if getting parsed template without instance id fails.

        <b>Input data:</b>
        1. Sample template id.

        <b>Expected results:</b>
        It is not possible to get parsed template without instance id.

        <b>Steps:</b>
        1. Create sample template.
        2. Try to get parsed template without instance id.
        3. Verify that HTTP response status code is 400 with proper message.
        """
        step(
            "Getting parsed template without instanceId parameter should cause an error"
        )
        assert_raises_http_exception(
            TemplateRepositoryHttpStatus.CODE_BAD_REQUEST,
            TemplateRepositoryHttpStatus.MSG_UUID_CANNOT_BE_EMPTY,
            template_repository_api.get_parsed_template,
            template_id=sample_template.id,
            params={})
Exemple #15
0
    def test_cannot_update_service_instance_with_wrong_prev_class_id_value(
            self, catalog_service_instance):
        """
        <b>Description:</b>
        Checks if there is no possibility of updating service instance field classId giving value classID and
        wrong prev_value of classId.

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service
        3. sample catalog service instance
        4. new classId value
        5. wrong prev_value of classId

        <b>Expected results:</b>
        Test passes when field classId of service instance is not updated and status code 400 with error message:
        'ClassID fields can not be changed!' is returned.

        <b>Steps:</b>
        1. Update service instance field classId giving values: classId and wrong prev_value of classId.
        """
        step(
            "Check that is't not possible to update service instance with incorrect prev_value of class id"
        )
        assert_raises_http_exception(
            CatalogHttpStatus.CODE_BAD_REQUEST,
            CatalogHttpStatus.MSG_CLASS_ID_CANNOT_BE_CHANGED,
            catalog_service_instance.update,
            field_name="classId",
            value=self.NEW_CLASS_ID,
            prev_value=self.WRONG_PREV_CLASS_ID)
Exemple #16
0
    def test_cannot_create_service_instance_with_existing_name(
            self, context, catalog_service, catalog_service_instance):
        """
        <b>Description:</b>
        Checks if there is no possibility of creating service instance with name which already exists.

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service
        3. sample catalog service instance

        <b>Expected results:</b>
        Test passes when service instance with name which already exists is not created and status code 409 with
        error message: 'instance with name: {sample_service_instance_name} already exists!' is returned.

        <b>Steps:</b>
        1. Create service instance with name which already exists on platform.
        """
        step(
            "Check that it's not possible to create instance with existing name"
        )
        expected_message = CatalogHttpStatus.MSG_INSTANCE_EXISTS.format(
            catalog_service_instance.name)
        assert_raises_http_exception(CatalogHttpStatus.CODE_CONFLICT,
                                     expected_message,
                                     CatalogServiceInstance.create,
                                     context,
                                     service_id=catalog_service.id,
                                     plan_id=catalog_service.plans[0].id,
                                     name=catalog_service_instance.name)
Exemple #17
0
    def test_cannot_update_service_without_value(self,
                                                 catalog_service_instance):
        """
        <b>Description:</b>
        Checks if there is no possibility of updating service instance omitting argument: value.

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service
        3. sample catalog service instance

        <b>Expected results:</b>
        Test passes when service instance is not updated and status code 400 with error message: 'field value is
        empty!' is returned.

        <b>Steps:</b>
        1. Update service instance omitting argument: value.
        """
        step(
            "Check that it's not possible to update service instance without value"
        )
        expected_message = CatalogHttpStatus.MSG_FIELD_IS_EMPTY.format("value")
        assert_raises_http_exception(CatalogHttpStatus.CODE_BAD_REQUEST,
                                     expected_message,
                                     catalog_service_instance.update,
                                     field_name="classId",
                                     value=None)
Exemple #18
0
    def test_cannot_create_service_instance_without_name(
            self, context, catalog_service):
        """
        <b>Description:</b>
        Checks if there is no possibility of creating service instance with empty name: "".

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service

        <b>Expected results:</b>
        Test passes when service instance with empty name "" is not created and status code 400 with error message:
        'Field: Name has incorrect value: ""' is returned.

        <b>Steps:</b>
        1. Create service instance with empty name: "".
        """
        step("Create service instance without name")
        assert_raises_http_exception(
            CatalogHttpStatus.CODE_BAD_REQUEST,
            CatalogHttpStatus.MSG_INSTANCE_FORBIDDEN_CHARACTERS.format(
                self.EMPTY_NAME, self.EMPTY_NAME),
            CatalogServiceInstance.create,
            context,
            service_id=catalog_service.id,
            plan_id=catalog_service.plans[0].id,
            name=self.EMPTY_NAME)
Exemple #19
0
    def test_cannot_delete_not_existing_service_instance(
            self, catalog_service):
        """
        <b>Description:</b>
        Checks if there is no possibility of deleting not-existing service instance.

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service
        3. id: 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'

        <b>Expected results:</b>
        Test passes when there is no possibility of deleting service instance and status code 404 with error message:
        '100: Key not found' is returned.

        <b>Steps:</b>
        1. Delete service instance giving not-existing service instance id.
        """
        step(
            "Check that it's not possible to delete not-existing service instance"
        )
        assert_raises_http_exception(CatalogHttpStatus.CODE_NOT_FOUND,
                                     CatalogHttpStatus.MSG_KEY_NOT_FOUND,
                                     catalog_api.delete_service_instance,
                                     service_id=catalog_service.id,
                                     instance_id=Guid.NON_EXISTING_GUID)
Exemple #20
0
    def test_cannot_update_service_instance_name(self,
                                                 catalog_service_instance):
        """
        <b>Description:</b>
        Checks if there is no possibility of updating service instance name.

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service
        3. sample catalog service instance

        <b>Expected results:</b>
        Test passes when field name of service instance is not updated and status code 400 with message: "ID and Name
        fields can not be changed!" is returned.

        <b>Steps:</b>
        1. Update service instance name.
        """
        step("Check that it's not possible to update name instance by service")
        assert_raises_http_exception(
            CatalogHttpStatus.CODE_BAD_REQUEST,
            CatalogHttpStatus.MSG_INSTANCE_UNCHANGED_FIELDS,
            catalog_service_instance.update,
            field_name="name",
            value="Simple3")
        step("Check that the instance was not updated")
        instance = CatalogServiceInstance.get(
            service_id=catalog_service_instance.class_id,
            instance_id=catalog_service_instance.id)
        assert catalog_service_instance == instance
    def test_cannot_create_service_instance_without_name(
            self, etcd_offering, api_service_admin_client):
        """
        <b>Description:</b>
        Tries to create service instance without a name

        <b>Input data:</b>
        - Admin credentials

        <b>Expected results:</b>
        It's not possible to create service instance without a name

        <b>Steps:</b>
        Create the service instance and don't provide a name
        """
        plan_id = etcd_offering.service_plans[0].id
        step("Send create service instance request without 'name' field")
        assertions.assert_raises_http_exception(
            ApiServiceHttpStatus.CODE_BAD_REQUEST,
            ApiServiceHttpStatus.MSG_FIELD_ZERO_VALUE.format("Name"),
            api.create_service,
            client=api_service_admin_client,
            name=None,
            plan_id=plan_id,
            offering_id=etcd_offering.id,
            params=None)
Exemple #22
0
    def test_cannot_create_instance_of_not_existing_service(self, context):
        """
        <b>Description:</b>
        Checks if there is no possibility of creating instance of not-existing service.

        <b>Input data:</b>
        1. not-existing service id: 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'.

        <b>Expected results:</b>
        Test passes when service instance is not created and status code 404 with error message: 'service with id:
        FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF does not exists!' is returned.

        <b>Steps:</b>
        1. Create instance of not-existing service.
        """
        step(
            "Check that it's not possible to create instance of not-existing service"
        )
        expected_message = CatalogHttpStatus.MSG_SERVICE_DOES_NOT_EXIST.format(
            Guid.NON_EXISTING_GUID)
        assert_raises_http_exception(CatalogHttpStatus.CODE_NOT_FOUND,
                                     expected_message,
                                     CatalogServiceInstance.create,
                                     context,
                                     service_id=Guid.NON_EXISTING_GUID)
    def test_cannot_create_service_instance_with_not_allowed_characters_in_name(
            self, class_context, api_service_admin_client):
        """
        <b>Description:</b>
        Create a service instance with bad characters in name

        <b>Input data:</b>
        - Admin credentials

        <b>Expected results:</b>
        It's not possible to create service instance with bad name

        <b>Steps:</b>
        Give service instance a bad name
        """
        step(
            "Try to create service instance with not allowed characters in name"
        )
        assertions.assert_raises_http_exception(
            ApiServiceHttpStatus.CODE_BAD_REQUEST,
            ApiServiceHttpStatus.MSG_FIELD_INCORRECT_VALUE.format("Name"),
            ServiceInstance.create_with_name,
            context=class_context,
            offering_label=ServiceLabels.KAFKA,
            plan_name=ServicePlan.SHARED,
            name="name with space",
            client=api_service_admin_client)
Exemple #24
0
    def test_cannot_get_instance_of_not_existing_service(
            self, catalog_service_instance):
        """
        <b>Description:</b>
        Checks if there is no possibility of getting service instance using not-existing service id.

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service
        3. sample catalog service instance
        4. not-existing service id: 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'

        <b>Expected results:</b>
        Test passes when service instance is not found on the list of service instances and status code: 404 with
        message: '100: Key not found' is returned.

        <b>Steps:</b>
        1. Get service instance using not-existing service id.
        """
        step(
            "Check that getting instance with incorrect service id causes an error"
        )
        assert_raises_http_exception(CatalogHttpStatus.CODE_NOT_FOUND,
                                     CatalogHttpStatus.MSG_KEY_NOT_FOUND,
                                     CatalogServiceInstance.get,
                                     service_id=Guid.NON_EXISTING_GUID,
                                     instance_id=catalog_service_instance.id)
Exemple #25
0
    def test_expose_service_invalid_port(self, catalog_instance_nats):
        """
        <b>Description:</b>
        Try to expose service instance with invalid port

        <b>Input data:</b>
        - Container broker instance.
        - Hostname
        - Invalid port.

        <b>Expected results:</b>
        It is not possible to expose service with invalid port.

        <b>Steps:</b>
        - Try to expose service instance.
        - Verify that HTTP response status code is 400 with proper message.
        """
        nats_instance = ContainerBrokerInstance(
            instance_id=catalog_instance_nats.id)
        step("Try to expose service instance with invalid port")
        expected_msg = ContainerBrokerHttpStatus.MSG_CANNOT_EXPOSE.format(
            catalog_instance_nats.id, self.INVALID_PORT)
        assertions.assert_raises_http_exception(
            ContainerBrokerHttpStatus.CODE_BAD_REQUEST,
            expected_msg,
            nats_instance.expose_service_instance,
            hostname=self.HOSTNAME,
            ports=[self.INVALID_PORT])
Exemple #26
0
    def test_cannot_create_instance_with_invalid_name(self, context,
                                                      catalog_service):
        """
        <b>Description:</b>
        Checks if there is no possibility of creating service instance with invalid name.

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service
        3. invalid name: 'instance!#'

        <b>Expected results:</b>
        Test passes when service instance is not created and status code 400 with error message: 'Field: Name has
        incorrect value: instance!#' is returned.

        <b>Steps:</b>
        1. Create service instance with incorrect name.
        """
        step("Try to create instance with name '{}'".format(
            self.INCORRECT_INSTANCE_NAME))
        expected_message = CatalogHttpStatus.MSG_INSTANCE_FORBIDDEN_CHARACTERS.format(
            self.INCORRECT_INSTANCE_NAME, self.INCORRECT_INSTANCE_NAME)
        assert_raises_http_exception(CatalogHttpStatus.CODE_BAD_REQUEST,
                                     expected_message,
                                     CatalogServiceInstance.create,
                                     context,
                                     service_id=catalog_service.id,
                                     name=self.INCORRECT_INSTANCE_NAME,
                                     plan_id=catalog_service.plans[0].id)
Exemple #27
0
    def test_non_admin_user_cannot_invite_another_user(self, context,
                                                       test_org):
        """
        <b>Description:</b>
        Checks if non-admin user cannot invite other user.

        <b>Input data:</b>
        1. Email address.
        2. User password.

        <b>Expected results:</b>
        Test passes when non-admin user receives access denied reply on adding other user attempt and the user doesn't
        obtain an invitation.

        <b>Steps:</b>
        1. Create a test user.
        2. Check an error is returned when non-admin tries to onboard another user.
        """
        step("Create a test user")
        user = User.create_by_adding_to_organization(
            context=context,
            org_guid=test_org.guid,
            role=User.ORG_ROLE["user"])
        non_admin_user_client = user.login()
        step(
            "Check an error is returned when non-admin tries to onboard another user"
        )
        username = generate_test_object_name(email=True)
        assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN,
                                     HttpStatus.MSG_ACCESS_IS_DENIED,
                                     Invitation.api_send,
                                     context,
                                     username=username,
                                     inviting_client=non_admin_user_client)
        self._assert_user_received_messages(username, 0)
Exemple #28
0
    def test_cannot_create_instance_with_empty_body(self, catalog_service):
        """
        <b>Description:</b>
        Checks if there is no possibility of creating service instance with empty body {}.

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service

        <b>Expected results:</b>
        Test passes when service instance is not created and status code 400 with error message: 'key PLAN_ID not
        found!' is returned.

        <b>Steps:</b>
        1. Create service instance with empty body {}.
        """
        step("Check create instance with empty body")
        assert_raises_http_exception(
            CatalogHttpStatus.CODE_BAD_REQUEST,
            CatalogHttpStatus.MSG_KEY_PLAN_ID_NOT_FOUND,
            catalog_api.create_service_instance,
            service_id=catalog_service.id,
            name=None,
            instance_type=None,
            state=None)
Exemple #29
0
    def test_user_cannot_register_without_password(self, context, test_org):
        """
        <b>Description:</b>
        Checks if the user registration without password fails.

        <b>Input data:</b>
        1. Email address.

        <b>Expected results:</b>
        Test passes when 400 Bad request HTTP status is returned on attempt of user registration without password and
        the user is not created.

        <b>Steps:</b>
        1. Invite a user.
        2. Check that an error is returned when the user tries to register without a password.
        3. Check that the user was not created.
        """
        step("Invite a new user")
        invitation = Invitation.api_send(context)
        step(
            "Check that an error is returned when the user tries to register without a password"
        )
        assert_raises_http_exception(HttpStatus.CODE_BAD_REQUEST,
                                     HttpStatus.MSG_PASSWORD_CANNOT_BE_EMPTY,
                                     user_management.api_register_new_user,
                                     code=invitation.code,
                                     org_name=generate_test_object_name())
        step("Check that the user was not created")
        username_list = [
            user.username for user in User.get_all_users(test_org.guid)
        ]
        assert invitation.username not in username_list, "User was created"
    def test_cannot_create_template_with_generic_svc_body(
            self, context, generic_service_template_id, other_params):
        """
        <b>Description:</b>
        Checks if creating template with generic service template body fails.

        <b>Input data:</b>
        1. Generic service template id.
        2. Parameters.

        <b>Expected results:</b>
        It is not possible to create template with generic service template body.

        <b>Steps:</b>
        1. Get body of generic service template.
        2. Try to create generic service template.
        3. Verify that HTTP response status code is 409 with proper message.
        """
        step(
            "Attempt to create a template with generic service template body causes an error"
        )
        template = Template.get_parsed(template_id=generic_service_template_id,
                                       instance_id=self.INSTANCE_ID,
                                       optional_params=other_params)
        expected_msg = TemplateRepositoryHttpStatus.MSG_TEMPLATE_EXISTS.format(
            template.id)
        assert_raises_http_exception(HttpStatus.CODE_CONFLICT,
                                     expected_msg,
                                     Template.create,
                                     context,
                                     template_id=template.id,
                                     body=template.components)