From 03ab43a258ab4ce09d870ac1469aefebb5349f1b Mon Sep 17 00:00:00 2001 From: magodo Date: Tue, 7 Feb 2023 05:01:46 +0800 Subject: [PATCH] `azurerm_sentinel_data_connector_threat_intelligence_taxii` - Fix date format for `lookback_date` (#20229) --- .../services/sentinel/azuresdkhacks/models.go | 2 +- ...onnector_threat_intelligence_taxii_test.go | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/internal/services/sentinel/azuresdkhacks/models.go b/internal/services/sentinel/azuresdkhacks/models.go index aa9b2ed59fa0..72a75be890ed 100644 --- a/internal/services/sentinel/azuresdkhacks/models.go +++ b/internal/services/sentinel/azuresdkhacks/models.go @@ -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 } diff --git a/internal/services/sentinel/sentinel_data_connector_threat_intelligence_taxii_test.go b/internal/services/sentinel/sentinel_data_connector_threat_intelligence_taxii_test.go index 3a7229d277a8..70a1078c5d04 100644 --- a/internal/services/sentinel/sentinel_data_connector_threat_intelligence_taxii_test.go +++ b/internal/services/sentinel/sentinel_data_connector_threat_intelligence_taxii_test.go @@ -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() @@ -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(`