Exemple #1
0
    def test_azure_odata(self):

        validSubscription = '1234-5678-9012-3456'
        cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
        config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
        config.log_level = log_level
        client = AutoRestAzureSpecialParametersTestClient(config)
        client.odata.get_with_filter(filter="id gt 5 and name eq 'foo'", top=10, orderby="id")
    def test_xms_request_client_id_in_client(self):
        validSubscription = '1234-5678-9012-3456'
        expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

        cred = BasicTokenAuthentication({"access_token":123})
        config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
        config.log_level = log_level
        config.generate_client_request_id = False
        client = AutoRestAzureSpecialParametersTestClient(config)
        client.xms_client_request_id.get()
    def test_xms_request_client_id_in_client(self):
        validSubscription = '1234-5678-9012-3456'
        expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

        cred = BasicTokenAuthentication({"access_token": 123})
        config = AutoRestAzureSpecialParametersTestClientConfiguration(
            cred, validSubscription, base_url="http://localhost:3000")
        config.log_level = log_level
        config.generate_client_request_id = False
        client = AutoRestAzureSpecialParametersTestClient(config)
        client.xms_client_request_id.get()
    def test_custom_named_request_id(self):

        validSubscription = '1234-5678-9012-3456'
        expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

        cred = BasicTokenAuthentication({"access_token":123})
        config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
        config.log_level = log_level
        client = AutoRestAzureSpecialParametersTestClient(config)

        response = client.header.custom_named_request_id(expectedRequestId, raw=True)
        self.assertEqual("123", response.response.headers.get("foo-request-id"))
    def test_custom_named_request_id(self):

        validSubscription = '1234-5678-9012-3456'
        expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

        cred = BasicTokenAuthentication({"access_token": 123})
        config = AutoRestAzureSpecialParametersTestClientConfiguration(
            cred, validSubscription, base_url="http://localhost:3000")
        config.log_level = log_level
        client = AutoRestAzureSpecialParametersTestClient(config)

        response = client.header.custom_named_request_id(expectedRequestId,
                                                         raw=True)
        self.assertEqual("123",
                         response.response.headers.get("foo-request-id"))
    def test_client_request_id_in_exception(self):
        validSubscription = '1234-5678-9012-3456'
        expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

        cred = BasicTokenAuthentication({"access_token":123})
        config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
        config.log_level = log_level
        client = AutoRestAzureSpecialParametersTestClient(config)

        try:
            client.xms_client_request_id.get()
            self.fail("CloudError wasn't raised as expected")

        except CloudError as err:
            self.assertEqual("123", err.request_id)
    def test_client_request_id_in_exception(self):
        validSubscription = '1234-5678-9012-3456'
        expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

        cred = BasicTokenAuthentication({"access_token": 123})
        config = AutoRestAzureSpecialParametersTestClientConfiguration(
            cred, validSubscription, base_url="http://localhost:3000")
        config.log_level = log_level
        client = AutoRestAzureSpecialParametersTestClient(config)

        try:
            client.xms_client_request_id.get()
            self.fail("CloudError wasn't raised as expected")

        except CloudError as err:
            self.assertEqual("123", err.request_id)
    def test_xms_request_client_id(self):

        validSubscription = '1234-5678-9012-3456'
        validClientId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

        cred = BasicTokenAuthentication({"access_token":123})
        config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
        config.log_level = log_level
        client = AutoRestAzureSpecialParametersTestClient(config)

        custom_headers = {"x-ms-client-request-id": validClientId }

        result1 = client.xms_client_request_id.get(custom_headers = custom_headers, raw=True)
        #TODO: should we put the x-ms-request-id into response header of swagger spec?
        self.assertEqual("123", result1.response.headers.get("x-ms-request-id"))

        result2 = client.xms_client_request_id.param_get(validClientId, raw=True)
        self.assertEqual("123", result2.response.headers.get("x-ms-request-id"))
Exemple #9
0
    def test_azure_special_parameters(self):

        validSubscription = '1234-5678-9012-3456'
        validApiVersion = '2.0'
        unencodedPath = 'path1/path2/path3'
        unencodedQuery = 'value1&q2=value2&q3=value3'
        cred = BasicTokenAuthentication({"access_token": str(uuid4())})
        config = AutoRestAzureSpecialParametersTestClientConfiguration(
            cred, validSubscription, base_url="http://localhost:3000")
        config.log_level = log_level
        client = AutoRestAzureSpecialParametersTestClient(config)

        client.subscription_in_credentials.post_method_global_not_provided_valid(
        )
        client.subscription_in_credentials.post_method_global_valid()
        client.subscription_in_credentials.post_path_global_valid()
        client.subscription_in_credentials.post_swagger_global_valid()
        client.subscription_in_method.post_method_local_valid(
            validSubscription)
        client.subscription_in_method.post_path_local_valid(validSubscription)
        client.subscription_in_method.post_swagger_local_valid(
            validSubscription)
        with self.assertRaises(ValidationError):
            client.subscription_in_method.post_method_local_null(None)

        client.api_version_default.get_method_global_not_provided_valid()
        client.api_version_default.get_method_global_valid()
        client.api_version_default.get_path_global_valid()
        client.api_version_default.get_swagger_global_valid()
        client.api_version_local.get_method_local_valid(validApiVersion)
        client.api_version_local.get_method_local_null(None)
        client.api_version_local.get_path_local_valid(validApiVersion)
        client.api_version_local.get_swagger_local_valid(validApiVersion)

        client.skip_url_encoding.get_method_path_valid(unencodedPath)
        client.skip_url_encoding.get_path_path_valid(unencodedPath)
        client.skip_url_encoding.get_swagger_path_valid(unencodedPath)
        client.skip_url_encoding.get_method_query_valid(unencodedQuery)
        client.skip_url_encoding.get_path_query_valid(unencodedQuery)
        client.skip_url_encoding.get_swagger_query_valid(unencodedQuery)
        client.skip_url_encoding.get_method_query_null()
        client.skip_url_encoding.get_method_query_null(None)
Exemple #10
0
    def test_azure_special_parameters(self):

        validSubscription = '1234-5678-9012-3456'
        validApiVersion = '2.0'
        unencodedPath = 'path1/path2/path3'
        unencodedQuery = 'value1&q2=value2&q3=value3'
        cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
        config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
        config.log_level = log_level
        client = AutoRestAzureSpecialParametersTestClient(config)

        client.subscription_in_credentials.post_method_global_not_provided_valid()
        client.subscription_in_credentials.post_method_global_valid()
        client.subscription_in_credentials.post_path_global_valid()
        client.subscription_in_credentials.post_swagger_global_valid()
        client.subscription_in_method.post_method_local_valid(validSubscription)
        client.subscription_in_method.post_path_local_valid(validSubscription)
        client.subscription_in_method.post_swagger_local_valid(validSubscription)
        with self.assertRaises(ValueError):
            client.subscription_in_method.post_method_local_null(None)

        client.api_version_default.get_method_global_not_provided_valid()
        client.api_version_default.get_method_global_valid()
        client.api_version_default.get_path_global_valid()
        client.api_version_default.get_swagger_global_valid()
        client.api_version_local.get_method_local_valid(validApiVersion)
        client.api_version_local.get_method_local_null(None)
        client.api_version_local.get_path_local_valid(validApiVersion)
        client.api_version_local.get_swagger_local_valid(validApiVersion)

        client.skip_url_encoding.get_method_path_valid(unencodedPath)
        client.skip_url_encoding.get_path_path_valid(unencodedPath)
        client.skip_url_encoding.get_swagger_path_valid(unencodedPath)
        client.skip_url_encoding.get_method_query_valid(unencodedQuery)
        client.skip_url_encoding.get_path_query_valid(unencodedQuery)
        client.skip_url_encoding.get_swagger_query_valid(unencodedQuery)
        client.skip_url_encoding.get_method_query_null()
        client.skip_url_encoding.get_method_query_null(None)
    def test_xms_request_client_id(self):

        validSubscription = '1234-5678-9012-3456'
        validClientId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

        cred = BasicTokenAuthentication({"access_token": 123})
        config = AutoRestAzureSpecialParametersTestClientConfiguration(
            cred, validSubscription, base_url="http://localhost:3000")
        config.log_level = log_level
        client = AutoRestAzureSpecialParametersTestClient(config)

        custom_headers = {"x-ms-client-request-id": validClientId}

        result1 = client.xms_client_request_id.get(
            custom_headers=custom_headers, raw=True)
        #TODO: should we put the x-ms-request-id into response header of swagger spec?
        self.assertEqual("123",
                         result1.response.headers.get("x-ms-request-id"))

        result2 = client.xms_client_request_id.param_get(validClientId,
                                                         raw=True)
        self.assertEqual("123",
                         result2.response.headers.get("x-ms-request-id"))