Esempio n. 1
0
    def test_cannot_create_service_with_no_name(self, context, app_jar,
                                                manifest_json):
        """
        <b>Description:</b>
        Try to create service offering without a name.

        <b>Input data:</b>
        1. jar application
        2. manifest.json file

        <b>Expected results:</b>
        Test passes when platform returns a 402 http status with meaningful message.

        <b>Steps:</b>
        1. Try to create service offering without a name.
        """
        step("Prepare offering json")
        offering_file = ServiceOffering.create_offering_json(name="")
        step("Attempt to create service with empty name")
        assert_raises_http_exception(HttpStatus.CODE_BAD_REQUEST,
                                     HttpStatus.MSG_SERVICE_NAME_IS_EMPTY,
                                     ServiceOffering.create_from_binary,
                                     context,
                                     jar_path=app_jar,
                                     manifest_path=manifest_json,
                                     offering_path=offering_file)
Esempio n. 2
0
    def test_create_service_with_tag(self, context, app_jar, manifest_json):
        """
        <b>Description:</b>
        Create new service offering with tag.

        <b>Input data:</b>
        1. application jar file
        2. manifest.json file

        <b>Expected results:</b>
        Test passes when new offering is created with tags.

        <b>Steps:</b>
        1. Prepare offering json file with tags.
        2. Create service offering.
        3. Check that created offering is present on the offering list.
        4. Check that offering has custom tags.
        """
        step("Prepare offering json")
        tags = [generate_test_object_name(short=True)]
        offering_file = ServiceOffering.create_offering_json(tags=tags)
        step("Register in marketplace")
        service = ServiceOffering.create_from_binary(
            context,
            jar_path=app_jar,
            manifest_path=manifest_json,
            offering_path=offering_file)
        step("Check that service is in marketplace")
        assert_in_with_retry(service, ServiceOffering.get_list)
        step("Check that tags names are the same")
        assert tags == service.tags
Esempio n. 3
0
def sample_service(class_context, sample_app_jar):
    log_fixture("Prepare mainfest and offering json")
    offering_json = ServiceOffering.create_offering_json()
    manifest_json = ServiceOffering.create_manifest_json(app_type=TapApplicationType.JAVA)
    log_fixture("Create new example service from binary")
    sample_service = ServiceOffering.create_from_binary(class_context, jar_path=sample_app_jar,
                                                        manifest_path=manifest_json, offering_path=offering_json)
    log_fixture("Check the service is ready")
    sample_service.ensure_ready()
    return sample_service
 def test_create_offering_json_with_default_data(self):
     random_name = "test_name"
     file_name = "offering.json"
     default_plan = [{
         "name": ServicePlanNames.FREE,
         "description": ServicePlanNames.FREE,
         "cost": ServicePlanNames.FREE
     }]
     offering_dict = {
         "name": random_name,
         "description": random_name,
         "metadata": [],
         "bindable": True,
         "tags": [],
         "plans": default_plan
     }
     self.mock_generate_test_object_name.return_value = random_name
     self.mock_file_utils.save_text_file.return_value = OFFERING_PATH
     offering_json = ServiceOffering.create_offering_json()
     assert offering_json == OFFERING_PATH
     self.mock_file_utils.save_text_file.assert_called_with(data=json.dumps(offering_dict), file_name=file_name)
Esempio n. 5
0
    def test_create_service_with_display_name(self, context, app_jar,
                                              manifest_json):
        """
        <b>Description:</b>
        Create new service offering with display name.

        <b>Input data:</b>
        1. application jar file
        2. manifest.json file

        <b>Expected results:</b>
        Test passes when new offering is created with display name.

        <b>Steps:</b>
        1. Prepare offering json file with display name.
        2. Create service offering.
        3. Check that created offering is present on the offering list.
        4. Check that offering has custom display name.
        """
        step("Prepare offering json")
        display_name = generate_test_object_name()
        metadata = [
            {
                "key": "displayName",
                "value": display_name
            },
        ]
        offering_file = ServiceOffering.create_offering_json(metadata=metadata)
        step("Register in marketplace")
        service = ServiceOffering.create_from_binary(
            context,
            jar_path=app_jar,
            manifest_path=manifest_json,
            offering_path=offering_file)
        step("Check that service is in marketplace")
        assert_in_with_retry(service, ServiceOffering.get_list)
        step("Check that display names are the same")
        assert display_name == service.display_name
Esempio n. 6
0
    def test_create_service_with_icon(self, context, app_jar, manifest_json,
                                      example_image):
        """
        <b>Description:</b>
        Create new service offering with custom icon.

        <b>Input data:</b>
        1. application jar file
        2. manifest.json file
        3. example image

        <b>Expected results:</b>
        Test passes when new offering is created with custom icon.

        <b>Steps:</b>
        1. Prepare offering json file with custom icon.
        2. Create service offering.
        3. Check that created offering is present on the offering list.
        4. Check that offering has a custom icon.
        """
        step("Prepare offering json")
        metadata = [
            {
                "key": "imageUrl",
                "value": example_image.decode()
            },
        ]
        offering_file = ServiceOffering.create_offering_json(metadata=metadata)
        step("Register in marketplace")
        service = ServiceOffering.create_from_binary(
            context,
            jar_path=app_jar,
            manifest_path=manifest_json,
            offering_path=offering_file)
        step("Check that service is in marketplace")
        assert_in_with_retry(service, ServiceOffering.get_list)
        step("Check that images are the same")
        assert example_image == bytes(service.image, "utf8")
 def test_create_offering_json_witd_custom_data(self):
     custom_name = "test_name"
     file_name = "offering.json"
     metadata = [{"key": "test_key", "value": "test_value"}]
     tags = ["test_tag_a", "test_tag_b"]
     custom_plan = [{
         "name": ServicePlanNames.BARE,
         "description": ServicePlanNames.CLUSTERED,
         "cost": ServicePlanNames.ENCRYPTED
     }]
     offering_dict = {
         "name": custom_name,
         "description": custom_name,
         "metadata": metadata,
         "bindable": False,
         "tags": tags,
         "plans": custom_plan
     }
     self.mock_file_utils.save_text_file.return_value = OFFERING_PATH
     offering_json = ServiceOffering.create_offering_json(name=custom_name, description=custom_name,
                                                          metadata=metadata, bindable=False, tags=tags,
                                                          plans=custom_plan)
     assert offering_json == OFFERING_PATH
     self.mock_file_utils.save_text_file.assert_called_with(data=json.dumps(offering_dict), file_name=file_name)
Esempio n. 8
0
 def offering_json(self):
     return ServiceOffering.create_offering_json()