Skip to content

Commit ca6dcd3

Browse files
DET-728: Added back removed blocks for override tests
1 parent 9c8417f commit ca6dcd3

6 files changed

+100
-29
lines changed

sumologic/resource_sumologic_cse_aggregation_rule_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,25 @@ func TestAccSumologicCSEAggregationRule_Override(t *testing.T) {
9393
testCheckAggregationRuleOverrideValues(&aggregationRule, descriptionExpression),
9494
resource.TestCheckResourceAttrSet(resourceName, "id"),
9595
resource.TestCheckResourceAttr(resourceName, "id", "AGGREGATION-S00009"),
96-
removeState("sumologic_cse_aggregation_rule.sumo_aggregation_rule_test"),
9796
),
9897
},
98+
{
99+
Config: getAggregationRuleRemovedBlock(),
100+
},
99101
},
100102
})
101103
}
102104

105+
func getAggregationRuleRemovedBlock() string {
106+
return fmt.Sprintf(`
107+
removed {
108+
from = sumologic_cse_aggregation_rule.sumo_aggregation_rule_test
109+
lifecycle {
110+
destroy = false
111+
}
112+
}`)
113+
}
114+
103115
func TestAccSumologicCSEAggregationRule_createAndUpdateToCustomWindowSize(t *testing.T) {
104116
SkipCseTest(t)
105117

sumologic/resource_sumologic_cse_chain_rule_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,26 @@ func TestAccSumologicCSEChainRule_Override(t *testing.T) {
9393
testCheckChainRuleOverrideValues(&ChainRule, descriptionExpression),
9494
resource.TestCheckResourceAttrSet(resourceName, "id"),
9595
resource.TestCheckResourceAttr(resourceName, "id", "CHAIN-S00016"),
96-
removeState("sumologic_cse_chain_rule.sumo_chain_rule_test"),
9796
),
9897
},
98+
{
99+
Config: getChainRuleRemovedBlock(),
100+
},
99101
},
100102
})
101103
}
102104

105+
func getChainRuleRemovedBlock() string {
106+
return fmt.Sprintf(`
107+
removed {
108+
from = sumologic_cse_chain_rule.sumo_chain_rule_test
109+
lifecycle {
110+
destroy = false
111+
}
112+
}
113+
`)
114+
}
115+
103116
func TestAccSumologicCSEChainRule_createAndUpdateToCustomWindowSize(t *testing.T) {
104117
SkipCseTest(t)
105118

sumologic/resource_sumologic_cse_first_seen_rule_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,26 @@ func TestAccSumologicCSEFirstSeenRule_Override(t *testing.T) {
108108
testCheckFirstSeenRuleOverrideValues(&FirstSeenRule, fmt.Sprintf(descriptionExpression)),
109109
resource.TestCheckResourceAttrSet(resourceName, "id"),
110110
resource.TestCheckResourceAttr(resourceName, "id", "FIRST-S00009"),
111-
removeState("sumologic_cse_first_seen_rule.sumo_first_seen_rule_test"),
112111
),
113112
},
113+
{
114+
Config: getFirstSeenRuleRemovedBlock(),
115+
},
114116
},
115117
})
116118
}
117119

120+
func getFirstSeenRuleRemovedBlock() string {
121+
return fmt.Sprintf(`
122+
removed {
123+
from = sumologic_cse_first_seen_rule.sumo_first_seen_rule_test
124+
lifecycle {
125+
destroy = false
126+
}
127+
}
128+
`)
129+
}
130+
118131
func testAccCSEFirstSeenRuleDestroy(s *terraform.State) error {
119132
client := testAccProvider.Meta().(*Client)
120133

sumologic/resource_sumologic_cse_match_rule_test.go

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ func TestAccSumologicCSEMatchRule_createAndUpdate(t *testing.T) {
7878
func TestAccSumologicCSEMatchRule_Override(t *testing.T) {
7979
SkipCseTest(t)
8080

81+
descriptionExpression := "Observes for possible exploitation of CVE-2017-8759"
8182
var matchRule CSEMatchRule
82-
descriptionExpression := "Detects email addresses associated with known malicious actor(s) or campaign(s) as designated by a threat intelligence provider."
83-
8483
resourceName := "sumologic_cse_match_rule.sumo_match_rule_test"
8584
resource.Test(t, resource.TestCase{
8685
PreCheck: func() { testAccPreCheck(t) },
@@ -91,7 +90,7 @@ func TestAccSumologicCSEMatchRule_Override(t *testing.T) {
9190
Config: testOverrideCSEMatchRuleConfig(descriptionExpression),
9291
ResourceName: resourceName,
9392
ImportState: true,
94-
ImportStateId: "MATCH-S01020",
93+
ImportStateId: "MATCH-S00574",
9594
ImportStateVerify: false,
9695
ImportStateVerifyIgnore: []string{"name"}, // Ignore fields that might differ
9796
ImportStatePersist: true,
@@ -102,7 +101,7 @@ func TestAccSumologicCSEMatchRule_Override(t *testing.T) {
102101
testCheckCSEMatchRuleExists(resourceName, &matchRule),
103102
testCheckMatchRuleOverrideValues(&matchRule, fmt.Sprintf("Updated %s", descriptionExpression)),
104103
resource.TestCheckResourceAttrSet(resourceName, "id"),
105-
resource.TestCheckResourceAttr(resourceName, "id", "MATCH-S01020"),
104+
resource.TestCheckResourceAttr(resourceName, "id", "MATCH-S00574"),
106105
),
107106
},
108107
{
@@ -111,14 +110,27 @@ func TestAccSumologicCSEMatchRule_Override(t *testing.T) {
111110
testCheckCSEMatchRuleExists(resourceName, &matchRule),
112111
testCheckMatchRuleOverrideValues(&matchRule, descriptionExpression),
113112
resource.TestCheckResourceAttrSet(resourceName, "id"),
114-
resource.TestCheckResourceAttr(resourceName, "id", "MATCH-S01020"),
115-
removeState("sumologic_cse_match_rule.sumo_match_rule_test"),
113+
resource.TestCheckResourceAttr(resourceName, "id", "MATCH-S00574"),
116114
),
117115
},
116+
{
117+
Config: getMatchRuleRemovedBlock(),
118+
},
118119
},
119120
})
120121
}
121122

123+
func getMatchRuleRemovedBlock() string {
124+
return fmt.Sprintf(`
125+
removed {
126+
from = sumologic_cse_match_rule.sumo_match_rule_test
127+
lifecycle {
128+
destroy = false
129+
}
130+
}
131+
`)
132+
}
133+
122134
func TestAccSumologicCSEMatchRule_failSuppressionValidation(t *testing.T) {
123135
SkipCseTest(t)
124136

@@ -210,32 +222,28 @@ func testOverrideCSEMatchRuleConfig(descriptionExpression string) string {
210222
resource "sumologic_cse_match_rule" "sumo_match_rule_test" {
211223
description_expression = "%s"
212224
enabled = true
213-
expression = "hasThreatMatch([targetUser_email], confidence > 1 AND type='email-addr')"
214-
is_prototype = true
215-
name = "Threat Intel - Matched Target Email"
216-
name_expression = "Threat Intel - Matched Target Email"
217-
summary_expression = "The record contains a target email address associated with a threat intelligence feed: {{targetUser_email}}"
218-
tags = []
225+
is_prototype = false
226+
name = ".NET Framework Remote Code Execution Vulnerability"
227+
name_expression = ".NET Framework Remote Code Execution Vulnerability"
228+
summary_expression = "Observed possible CVE-2017-8759 exploit on {{device_hostname}}"
229+
tags = [
230+
"_mitreAttackTactic:TA0002",
231+
"_mitreAttackTactic:TA0001",
232+
"_mitreAttackTechnique:T1203",
233+
]
219234
220235
entity_selectors {
221-
entity_type = "_username"
222-
expression = "user_username"
223-
}
224-
entity_selectors {
225-
entity_type = "_email"
226-
expression = "user_email"
236+
entity_type = "_hostname"
237+
expression = "device_hostname"
227238
}
228239
entity_selectors {
229240
entity_type = "_username"
230-
expression = "targetUser_username"
231-
}
232-
entity_selectors {
233-
entity_type = "_email"
234-
expression = "targetUser_email"
241+
expression = "user_username"
235242
}
236243
237244
severity_mapping {
238-
default = 1
245+
default = 3
246+
field = null
239247
type = "constant"
240248
}
241249
}

sumologic/resource_sumologic_cse_outlier_rule_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,25 @@ func TestAccSumologicCSEOutlierRule_Override(t *testing.T) {
112112
testCheckOutlierRuleOverrideValues(&OutlierRule, descriptionExpression),
113113
resource.TestCheckResourceAttrSet(resourceName, "id"),
114114
resource.TestCheckResourceAttr(resourceName, "id", "OUTLIER-S00007"),
115-
removeState("sumologic_cse_outlier_rule.sumo_outlier_rule_test"),
116115
),
117116
},
117+
{
118+
Config: getOutlierRuleRemovedBlock(),
119+
},
118120
},
119121
})
120122
}
121123

124+
func getOutlierRuleRemovedBlock() string {
125+
return fmt.Sprintf(`
126+
removed {
127+
from = sumologic_cse_outlier_rule.sumo_outlier_rule_test
128+
lifecycle {
129+
destroy = false
130+
}
131+
}`)
132+
}
133+
122134
func testAccCSEOutlierRuleDestroy(s *terraform.State) error {
123135
client := testAccProvider.Meta().(*Client)
124136

sumologic/resource_sumologic_cse_threshold_rule_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,26 @@ func TestAccSumologicCSEThresholdRule_Override(t *testing.T) {
9494
testCheckThresholdRuleOverrideValues(&thresholdRule, descriptionExpression),
9595
resource.TestCheckResourceAttrSet(resourceName, "id"),
9696
resource.TestCheckResourceAttr(resourceName, "id", "THRESHOLD-S00059"),
97-
removeState("sumologic_cse_threshold_rule.sumo_threshold_rule_test"),
9897
),
9998
},
99+
{
100+
Config: getThresholdRuleRemovedBlock(),
101+
},
100102
},
101103
})
102104
}
103105

106+
func getThresholdRuleRemovedBlock() string {
107+
return fmt.Sprintf(`
108+
removed {
109+
from = sumologic_cse_threshold_rule.sumo_threshold_rule_test
110+
lifecycle {
111+
destroy = false
112+
}
113+
}
114+
`)
115+
}
116+
104117
func TestAccSumologicCSEThresholdRule_createAndUpdateToCustomWindowSize(t *testing.T) {
105118
SkipCseTest(t)
106119

0 commit comments

Comments
 (0)