Skip to content

Commit

Permalink
Include rule ID in request body of all integration tests (#2511)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <[email protected]>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Jun 5, 2024
1 parent 0dd2600 commit c4e472c
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 44 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-06-04 15:12:26.067522",
"spec_repo_commit": "60183db6"
"regenerated": "2024-06-05 15:00:49.728492",
"spec_repo_commit": "8e7244ae"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-06-04 15:12:26.085902",
"spec_repo_commit": "60183db6"
"regenerated": "2024-06-05 15:00:49.746582",
"spec_repo_commit": "8e7244ae"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func main() {
Expression: datadog.PtrString(`exec.file.name == "sh"`),
},
Type: datadogV2.CLOUDWORKLOADSECURITYAGENTRULETYPE_AGENT_RULE,
Id: datadog.PtrString(AgentRuleDataID),
},
}
ctx := datadog.NewDefaultContext(context.Background())
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-23T17:57:50.511Z
2024-05-28T19:38:08.047Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: |
{"data":{"attributes":{"description":"My Agent rule","enabled":true,"expression":"exec.file.name == \"sh\"","name":"testupdateacsmthreatsagentrulereturnsbadrequestresponse1713895070"},"type":"agent_rule"}}
{"data":{"attributes":{"description":"My Agent rule","enabled":true,"expression":"exec.file.name == \"sh\"","name":"testupdateacsmthreatsagentrulereturnsbadrequestresponse1716925088"},"type":"agent_rule"}}
form: {}
headers:
Accept:
Expand All @@ -12,10 +12,11 @@ interactions:
method: POST
url: https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules
response:
body: '{"data":{"id":"rgf-aao-lo8","type":"agent_rule","attributes":{"category":"Process
Activity","creationDate":1713895070561,"creator":{"name":"","handle":"[email protected]"},"defaultRule":false,"description":"My
body: '{"data":{"id":"0wn-l36-875","type":"agent_rule","attributes":{"category":"Process
Activity","creationDate":1716925088306,"creator":{"name":"CI Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"defaultRule":false,"description":"My
Agent rule","enabled":true,"expression":"exec.file.name == \"sh\"","filters":["os
== \"linux\""],"name":"testupdateacsmthreatsagentrulereturnsbadrequestresponse1713895070","updateDate":1713895070561,"updater":{"name":"","handle":"[email protected]"}}}}'
== \"linux\""],"name":"testupdateacsmthreatsagentrulereturnsbadrequestresponse1716925088","updateDate":1716925088306,"updater":{"name":"CI
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}}}'
code: 200
duration: 0ms
headers:
Expand All @@ -24,7 +25,7 @@ interactions:
status: 200 OK
- request:
body: |
{"data":{"attributes":{"description":"Test Agent rule","enabled":true,"expression":"open.file.path = sh"},"id":"abc-123-xyz","type":"agent_rule"}}
{"data":{"attributes":{"description":"Test Agent rule","enabled":true,"expression":"open.file.path = sh"},"id":"0wn-l36-875","type":"agent_rule"}}
form: {}
headers:
Accept:
Expand All @@ -33,11 +34,11 @@ interactions:
- application/json
id: 1
method: PATCH
url: https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/rgf-aao-lo8
url: https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/0wn-l36-875
response:
body: '{"errors":[{"title":"failed to update rule"}]}
'
body: '{"errors":["input_validation_error(Field ''expression'' is invalid: rule
`testupdateacsmthreatsagentrulereturnsbadrequestresponse1716925088` error: syntax
error `1:18: unexpected token \"sh\" (expected \"~\")`)"]}'
code: 400
duration: 0ms
headers:
Expand All @@ -52,7 +53,7 @@ interactions:
- '*/*'
id: 2
method: DELETE
url: https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/rgf-aao-lo8
url: https://api.datadoghq.com/api/v2/remote_config/products/cws/agent_rules/0wn-l36-875
response:
body: ''
code: 204
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-23T17:57:52.935Z
2024-05-28T19:38:09.490Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: |
{"data":{"attributes":{"description":"My Agent rule","enabled":true,"expression":"exec.file.name == \"sh\"","name":"testupdateacloudworkloadsecurityagentrulereturnsbadrequestresponse1713895072"},"type":"agent_rule"}}
{"data":{"attributes":{"description":"My Agent rule","enabled":true,"expression":"exec.file.name == \"sh\"","name":"testupdateacloudworkloadsecurityagentrulereturnsbadrequestresponse1716925089"},"type":"agent_rule"}}
form: {}
headers:
Accept:
Expand All @@ -12,9 +12,11 @@ interactions:
method: POST
url: https://api.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_rules
response:
body: '{"data":{"id":"1su-fqy-sjj","attributes":{"version":1,"name":"testupdateacloudworkloadsecurityagentrulereturnsbadrequestresponse1713895072","description":"My
Agent rule","expression":"exec.file.name == \"sh\"","category":"Process Activity","creationAuthorUuId":"3ad549bf-eba0-11e9-a77a-0705486660d0","creationDate":1713895073105,"updateAuthorUuId":"3ad549bf-eba0-11e9-a77a-0705486660d0","updateDate":1713895073105,"filters":["os
== \"linux\""],"actions":[],"agentConstraint":"","enabled":true,"defaultRule":false,"creator":{"name":null,"handle":"[email protected]"},"updater":{"name":null,"handle":"[email protected]"}},"type":"agent_rule"}}
body: '{"data":{"id":"qdg-dfm-kku","attributes":{"version":1,"name":"testupdateacloudworkloadsecurityagentrulereturnsbadrequestresponse1716925089","description":"My
Agent rule","expression":"exec.file.name == \"sh\"","category":"Process Activity","creationAuthorUuId":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","creationDate":1716925089625,"updateAuthorUuId":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","updateDate":1716925089625,"filters":["os
== \"linux\""],"actions":[],"agentConstraint":"","defaultRule":false,"enabled":true,"creator":{"name":"CI
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"updater":{"name":"CI
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}},"type":"agent_rule"}}
'
code: 200
Expand All @@ -25,7 +27,7 @@ interactions:
status: 200 OK
- request:
body: |
{"data":{"attributes":{"description":"Test Agent rule","enabled":true,"expression":"open.file.path = sh"},"type":"agent_rule"}}
{"data":{"attributes":{"description":"Test Agent rule","enabled":true,"expression":"open.file.path = sh"},"id":"qdg-dfm-kku","type":"agent_rule"}}
form: {}
headers:
Accept:
Expand All @@ -34,10 +36,10 @@ interactions:
- application/json
id: 1
method: PATCH
url: https://api.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_rules/1su-fqy-sjj
url: https://api.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_rules/qdg-dfm-kku
response:
body: '{"errors":["input_validation_error(Field ''expression'' is invalid: rule
`testupdateacloudworkloadsecurityagentrulereturnsbadrequestresponse1713895072`
`testupdateacloudworkloadsecurityagentrulereturnsbadrequestresponse1716925089`
error: syntax error `1:18: unexpected token \"sh\" (expected \"~\")`)"]}
'
Expand All @@ -55,7 +57,7 @@ interactions:
- '*/*'
id: 2
method: DELETE
url: https://api.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_rules/1su-fqy-sjj
url: https://api.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_rules/qdg-dfm-kku
response:
body: ''
code: 204
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-23T17:57:53.479Z
2024-05-28T19:38:10.057Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: |
{"data":{"attributes":{"description":"Test Agent rule","enabled":true,"expression":"exec.file.name == \"sh\""},"type":"agent_rule"}}
{"data":{"attributes":{"description":"Test Agent rule","enabled":true,"expression":"exec.file.name == \"sh\""},"id":"abc-123-xyz","type":"agent_rule"}}
form: {}
headers:
Accept:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-04-23T17:57:53.638Z
2024-05-28T19:38:10.219Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: |
{"data":{"attributes":{"description":"My Agent rule","enabled":true,"expression":"exec.file.name == \"sh\"","name":"testupdateacloudworkloadsecurityagentrulereturnsokresponse1713895073"},"type":"agent_rule"}}
{"data":{"attributes":{"description":"My Agent rule","enabled":true,"expression":"exec.file.name == \"sh\"","name":"testupdateacloudworkloadsecurityagentrulereturnsokresponse1716925090"},"type":"agent_rule"}}
form: {}
headers:
Accept:
Expand All @@ -12,9 +12,11 @@ interactions:
method: POST
url: https://api.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_rules
response:
body: '{"data":{"id":"sir-mer-toj","attributes":{"version":1,"name":"testupdateacloudworkloadsecurityagentrulereturnsokresponse1713895073","description":"My
Agent rule","expression":"exec.file.name == \"sh\"","category":"Process Activity","creationAuthorUuId":"3ad549bf-eba0-11e9-a77a-0705486660d0","creationDate":1713895073761,"updateAuthorUuId":"3ad549bf-eba0-11e9-a77a-0705486660d0","updateDate":1713895073761,"filters":["os
== \"linux\""],"actions":[],"agentConstraint":"","enabled":true,"defaultRule":false,"creator":{"name":null,"handle":"[email protected]"},"updater":{"name":null,"handle":"[email protected]"}},"type":"agent_rule"}}
body: '{"data":{"id":"wmz-xld-san","attributes":{"version":1,"name":"testupdateacloudworkloadsecurityagentrulereturnsokresponse1716925090","description":"My
Agent rule","expression":"exec.file.name == \"sh\"","category":"Process Activity","creationAuthorUuId":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","creationDate":1716925090332,"updateAuthorUuId":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","updateDate":1716925090332,"filters":["os
== \"linux\""],"actions":[],"agentConstraint":"","enabled":true,"defaultRule":false,"creator":{"name":"CI
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"updater":{"name":"CI
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}},"type":"agent_rule"}}
'
code: 200
Expand All @@ -25,7 +27,7 @@ interactions:
status: 200 OK
- request:
body: |
{"data":{"attributes":{"description":"Test Agent rule","enabled":true,"expression":"exec.file.name == \"sh\""},"type":"agent_rule"}}
{"data":{"attributes":{"description":"Test Agent rule","enabled":true,"expression":"exec.file.name == \"sh\""},"id":"wmz-xld-san","type":"agent_rule"}}
form: {}
headers:
Accept:
Expand All @@ -34,11 +36,13 @@ interactions:
- application/json
id: 1
method: PATCH
url: https://api.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_rules/sir-mer-toj
url: https://api.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_rules/wmz-xld-san
response:
body: '{"data":{"id":"sir-mer-toj","attributes":{"version":2,"name":"testupdateacloudworkloadsecurityagentrulereturnsokresponse1713895073","description":"Test
Agent rule","expression":"exec.file.name == \"sh\"","category":"Process Activity","creationAuthorUuId":"3ad549bf-eba0-11e9-a77a-0705486660d0","creationDate":1713895073761,"updateAuthorUuId":"3ad549bf-eba0-11e9-a77a-0705486660d0","updateDate":1713895073928,"filters":["os
== \"linux\""],"actions":[],"agentConstraint":"","enabled":true,"defaultRule":false,"creator":{"name":null,"handle":"[email protected]"},"updater":{"name":null,"handle":"[email protected]"}},"type":"agent_rule"}}
body: '{"data":{"id":"wmz-xld-san","attributes":{"version":2,"name":"testupdateacloudworkloadsecurityagentrulereturnsokresponse1716925090","description":"Test
Agent rule","expression":"exec.file.name == \"sh\"","category":"Process Activity","creationAuthorUuId":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","creationDate":1716925090332,"updateAuthorUuId":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","updateDate":1716925090525,"filters":["os
== \"linux\""],"actions":[],"agentConstraint":"","enabled":true,"defaultRule":false,"creator":{"name":"CI
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"updater":{"name":"CI
Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}},"type":"agent_rule"}}
'
code: 200
Expand All @@ -55,7 +59,7 @@ interactions:
- '*/*'
id: 2
method: DELETE
url: https://api.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_rules/sir-mer-toj
url: https://api.datadoghq.com/api/v2/security_monitoring/cloud_workload_security/agent_rules/wmz-xld-san
response:
body: ''
code: 204
Expand Down
15 changes: 8 additions & 7 deletions tests/scenarios/features/v2/csm_threats.feature
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,16 @@ Feature: CSM Threats
Given there is a valid "agent_rule_rc" in the system
And new "UpdateCSMThreatsAgentRule" request
And request contains "agent_rule_id" parameter from "agent_rule.data.id"
And body with value {"data": {"attributes": {"description": "Test Agent rule", "enabled": true, "expression": "open.file.path = sh"}, "type": "agent_rule", "id":"abc-123-xyz"}}
And body with value {"data": {"attributes": {"description": "Test Agent rule", "enabled": true, "expression": "open.file.path = sh"}, "type": "agent_rule", "id":"{{ agent_rule.data.id }}"}}
When the request is sent
Then the response status is 400 Bad Request

@skip @team:DataDog/k9-cloud-security-platform @team:DataDog/k9-cws-backend
Scenario: Update a CSM Threats Agent rule returns "Concurrent Modification" response
Given new "UpdateCSMThreatsAgentRule" request
And request contains "agent_rule_id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {"description": "My Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\""}, "type": "agent_rule"}}
And there is a valid "agent_rule" in the system
And request contains "agent_rule_id" parameter from "agent_rule.data.id"
And body with value {"data": {"attributes": {"description": "My Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\""}, "type": "agent_rule", "id":"{{ agent_rule.data.id }}"}}
When the request is sent
Then the response status is 409 Concurrent Modification

Expand Down Expand Up @@ -186,7 +187,7 @@ Feature: CSM Threats
Given there is a valid "agent_rule" in the system
And new "UpdateCloudWorkloadSecurityAgentRule" request
And request contains "agent_rule_id" parameter from "agent_rule.data.id"
And body with value {"data": {"attributes": {"description": "Test Agent rule", "enabled": true, "expression": "open.file.path = sh"}, "type": "agent_rule"}}
And body with value {"data": {"attributes": {"description": "Test Agent rule", "enabled": true, "expression": "open.file.path = sh"}, "type": "agent_rule", "id":"{{ agent_rule.data.id }}"}}
When the request is sent
Then the response status is 400 Bad Request

Expand All @@ -195,15 +196,15 @@ Feature: CSM Threats
Given there is a valid "agent_rule" in the system
And new "UpdateCloudWorkloadSecurityAgentRule" request
And request contains "agent_rule_id" parameter from "agent_rule.data.id"
And body with value {"data": {"attributes": {"description": "Test Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\""}, "type": "agent_rule"}}
And body with value {"data": {"attributes": {"description": "Test Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\""}, "type": "agent_rule", "id":"{{ agent_rule.data.id }}"}}
When the request is sent
Then the response status is 409 Concurrent Modification

@team:DataDog/k9-cloud-security-platform @team:DataDog/k9-cws-backend
Scenario: Update a Cloud Workload Security Agent rule returns "Not Found" response
Given new "UpdateCloudWorkloadSecurityAgentRule" request
And request contains "agent_rule_id" parameter with value "abc-123-xyz"
And body with value {"data": {"attributes": {"description": "Test Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\""}, "type": "agent_rule"}}
And body with value {"data": {"attributes": {"description": "Test Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\""}, "type": "agent_rule", "id":"abc-123-xyz"}}
When the request is sent
Then the response status is 404 Not Found

Expand All @@ -212,7 +213,7 @@ Feature: CSM Threats
Given there is a valid "agent_rule" in the system
And new "UpdateCloudWorkloadSecurityAgentRule" request
And request contains "agent_rule_id" parameter from "agent_rule.data.id"
And body with value {"data": {"attributes": {"description": "Test Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\""}, "type": "agent_rule"}}
And body with value {"data": {"attributes": {"description": "Test Agent rule", "enabled": true, "expression": "exec.file.name == \"sh\""}, "type": "agent_rule", "id":"{{ agent_rule.data.id }}"}}
When the request is sent
Then the response status is 200 OK
And the response "data.type" is equal to "agent_rule"
Expand Down

0 comments on commit c4e472c

Please sign in to comment.