From 371703adcfa0782761a03e2734b3dc5b26537e50 Mon Sep 17 00:00:00 2001 From: ziyeqf <51212351+ziyeqf@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:28:33 +0800 Subject: [PATCH] `azurerm_data_factory_pipeline`: correctly handle empty headers for `WebActivity` (#25178) * update workaround code * adding test case --- .../datafactory/azuresdkhacks/models.go | 2 +- .../data_factory_pipeline_resource_test.go | 34 +++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/internal/services/datafactory/azuresdkhacks/models.go b/internal/services/datafactory/azuresdkhacks/models.go index dade60224fe2..e56207b50673 100644 --- a/internal/services/datafactory/azuresdkhacks/models.go +++ b/internal/services/datafactory/azuresdkhacks/models.go @@ -18,7 +18,7 @@ import ( type WebActivityTypeProperties struct { Method datafactory.WebActivityMethod `json:"method,omitempty"` URL interface{} `json:"url,omitempty"` - Headers interface{} `json:"headers"` + Headers interface{} `json:"headers,omitempty"` Body interface{} `json:"body,omitempty"` Authentication *datafactory.WebActivityAuthentication `json:"authentication,omitempty"` DisableCertValidation *bool `json:"disableCertValidation,omitempty"` diff --git a/internal/services/datafactory/data_factory_pipeline_resource_test.go b/internal/services/datafactory/data_factory_pipeline_resource_test.go index d732bc652ba6..85badd7d242d 100644 --- a/internal/services/datafactory/data_factory_pipeline_resource_test.go +++ b/internal/services/datafactory/data_factory_pipeline_resource_test.go @@ -70,7 +70,14 @@ func TestAccDataFactoryPipeline_activities(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.webActivityHeaders(data), + Config: r.webActivityHeaders(data, false), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.webActivityHeaders(data, true), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -283,7 +290,20 @@ JSON `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) } -func (PipelineResource) webActivityHeaders(data acceptance.TestData) string { +func (PipelineResource) webActivityHeaders(data acceptance.TestData, withHeader bool) string { + headerBlock := ` + "headers": { + "authorization": { + "value": "foo", + "type": "Expression" + }, + "content_type": "application/x-www-form-urlencoded" + } + ` + if !withHeader { + headerBlock = `` + } + return fmt.Sprintf(` provider "azurerm" { features {} @@ -314,19 +334,13 @@ resource "azurerm_data_factory_pipeline" "test" { "dependsOn": [], "userProperties": [], "typeProperties": { - "headers": { - "authorization": { - "value": "foo", - "type": "Expression" - }, - "content_type": "application/x-www-form-urlencoded" - } + %s } } ] JSON } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, headerBlock) } func (PipelineResource) activitiesUpdated(data acceptance.TestData) string {