Skip to content

Commit

Permalink
azurerm_data_factory_pipeline: correctly handle empty headers for `…
Browse files Browse the repository at this point in the history
…WebActivity` (#25178)

* update workaround code

* adding test case
  • Loading branch information
ziyeqf authored Mar 12, 2024
1 parent bd64d39 commit 371703a
Showing 2 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/services/datafactory/azuresdkhacks/models.go
Original file line number Diff line number Diff line change
@@ -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"`
Original file line number Diff line number Diff line change
@@ -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 {

0 comments on commit 371703a

Please sign in to comment.