Skip to content

Commit

Permalink
azurerm_sentinel_data_connector_threat_intelligence_taxii - Fix dat…
Browse files Browse the repository at this point in the history
…e format for `lookback_date` (#20229)
  • Loading branch information
magodo authored Feb 6, 2023
1 parent a82c720 commit 03ab43a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/services/sentinel/azuresdkhacks/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func (t *Time) UnmarshalJSON(data []byte) (err error) {
}

// This is the format that the service returns at this moment, which is not the expected format (RFC3339).
t.Time, err = time.Parse(`"1/2/2006 15:04:05 PM -07:00"`, string(data))
t.Time, err = time.Parse(`"01/02/2006 15:04:05"`, string(data))
return err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ func TestAccDataConnectorThreatIntelligenceTAXII_basic(t *testing.T) {
})
}

func TestAccDataConnectorThreatIntelligenceTAXII_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_sentinel_data_connector_threat_intelligence_taxii", "test")
r := NewDataConnectorThreatIntelligenceTAXIIResource()
r.preCheck(t, false)

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("user_name", "password"),
})
}

func TestAccDataConnectorThreatIntelligenceTAXII_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_sentinel_data_connector_threat_intelligence_taxii", "test")
r := NewDataConnectorThreatIntelligenceTAXIIResource()
Expand Down Expand Up @@ -159,6 +175,26 @@ resource "azurerm_sentinel_data_connector_threat_intelligence_taxii" "test" {
`, template, data.RandomInteger, r.taxiiInfo.APIRootURL, r.taxiiInfo.CollectionID, r.taxiiInfo.UserName, r.taxiiInfo.Password)
}

func (r DataConnectorThreatIntelligenceTAXIIResource) complete(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%s
resource "azurerm_sentinel_data_connector_threat_intelligence_taxii" "test" {
name = "acctestDC-%d"
log_analytics_workspace_id = azurerm_log_analytics_workspace.test.id
display_name = "test_update"
api_root_url = "%s"
collection_id = "%s"
user_name = "%s"
password = "%s"
polling_frequency = "OnceADay"
lookback_date = "1990-01-01T00:00:00Z"
depends_on = [azurerm_log_analytics_solution.test]
}
`, template, data.RandomInteger, r.taxiiInfo.APIRootURL, r.taxiiInfo.CollectionID, r.taxiiInfo.UserName, r.taxiiInfo.Password)
}

func (r DataConnectorThreatIntelligenceTAXIIResource) update(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
Expand Down

0 comments on commit 03ab43a

Please sign in to comment.