|
| 1 | +@endpoint(logs-restriction-queries) @endpoint(logs-restriction-queries-v2) |
| 2 | +Feature: Logs Restriction Queries |
| 3 | + **Note: This endpoint is in public beta. If you have any feedback, contact |
| 4 | + [Datadog support](https://docs.datadoghq.com/help/).** A Restriction |
| 5 | + Query is a logs query that restricts which logs the `logs_read_data` |
| 6 | + permission grants read access to. For users whose roles have Restriction |
| 7 | + Queries, any log query they make only returns those log events that also |
| 8 | + match one of their Restriction Queries. This is true whether the user |
| 9 | + queries log events from any log-related feature, including the log |
| 10 | + explorer, Live Tail, re-hydration, or a dashboard widget. Restriction |
| 11 | + Queries currently only support use of the following components of log |
| 12 | + events: - Reserved attributes - The log message - Tags To restrict read |
| 13 | + access on log data, add a team tag to log events to indicate which teams |
| 14 | + own them, and then scope Restriction Queries to the relevant values of the |
| 15 | + team tag. Tags can be applied to log events in many ways, and a log event |
| 16 | + can have multiple tags with the same key (like team) and different values. |
| 17 | + This means the same log event can be visible to roles whose restriction |
| 18 | + queries are scoped to different team values. See [How to Set Up RBAC for |
| 19 | + Logs](https://docs.datadoghq.com/logs/guide/logs-rbac/?tab=api#restrict- |
| 20 | + access-to-logs) for details on how to add restriction queries. |
| 21 | + |
| 22 | + Background: |
| 23 | + Given a valid "apiKeyAuth" key in the system |
| 24 | + And a valid "appKeyAuth" key in the system |
| 25 | + And an instance of "LogsRestrictionQueries" API |
| 26 | + |
| 27 | + @skip-go @skip-java @skip-python @skip-ruby @skip-rust @skip-terraform-config @skip-typescript @skip-validation @team:DataDog/logs-app |
| 28 | + Scenario: Create a restriction query returns "Bad Request" response |
| 29 | + Given operation "CreateRestrictionQuery" enabled |
| 30 | + And new "CreateRestrictionQuery" request |
| 31 | + And body with value {"test": "bad_request"} |
| 32 | + When the request is sent |
| 33 | + Then the response status is 400 Bad Request |
| 34 | + |
| 35 | + @team:DataDog/logs-app |
| 36 | + Scenario: Create a restriction query returns "OK" response |
| 37 | + Given operation "CreateRestrictionQuery" enabled |
| 38 | + And new "CreateRestrictionQuery" request |
| 39 | + And body with value {"data": {"attributes": {"restriction_query": "env:sandbox"}, "type": "logs_restriction_queries"}} |
| 40 | + When the request is sent |
| 41 | + Then the response status is 200 OK |
| 42 | + |
| 43 | + @skip-terraform-config @team:DataDog/logs-app |
| 44 | + Scenario: Delete a restriction query returns "Bad Request" response |
| 45 | + Given operation "DeleteRestrictionQuery" enabled |
| 46 | + And new "DeleteRestrictionQuery" request |
| 47 | + And request contains "restriction_query_id" parameter with value "malformed_id" |
| 48 | + When the request is sent |
| 49 | + Then the response status is 400 Bad Request |
| 50 | + |
| 51 | + @skip-terraform-config @team:DataDog/logs-app |
| 52 | + Scenario: Delete a restriction query returns "Not found" response |
| 53 | + Given operation "DeleteRestrictionQuery" enabled |
| 54 | + And new "DeleteRestrictionQuery" request |
| 55 | + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" |
| 56 | + When the request is sent |
| 57 | + Then the response status is 404 Not found |
| 58 | + |
| 59 | + @team:DataDog/logs-app |
| 60 | + Scenario: Delete a restriction query returns "OK" response |
| 61 | + Given operation "DeleteRestrictionQuery" enabled |
| 62 | + And there is a valid "restriction_query" in the system |
| 63 | + And new "DeleteRestrictionQuery" request |
| 64 | + And request contains "restriction_query_id" parameter from "restriction_query.data.id" |
| 65 | + When the request is sent |
| 66 | + Then the response status is 204 OK |
| 67 | + |
| 68 | + @skip-terraform-config @team:DataDog/logs-app |
| 69 | + Scenario: Get a restriction query returns "Bad Request" response |
| 70 | + Given operation "GetRestrictionQuery" enabled |
| 71 | + And new "GetRestrictionQuery" request |
| 72 | + And request contains "restriction_query_id" parameter with value "malformed_id" |
| 73 | + When the request is sent |
| 74 | + Then the response status is 400 Bad Request |
| 75 | + |
| 76 | + @skip-terraform-config @team:DataDog/logs-app |
| 77 | + Scenario: Get a restriction query returns "Not found" response |
| 78 | + Given operation "GetRestrictionQuery" enabled |
| 79 | + And new "GetRestrictionQuery" request |
| 80 | + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" |
| 81 | + When the request is sent |
| 82 | + Then the response status is 404 Not found |
| 83 | + |
| 84 | + @team:DataDog/logs-app |
| 85 | + Scenario: Get a restriction query returns "OK" response |
| 86 | + Given operation "GetRestrictionQuery" enabled |
| 87 | + And there is a valid "restriction_query" in the system |
| 88 | + And new "GetRestrictionQuery" request |
| 89 | + And request contains "restriction_query_id" parameter from "restriction_query.data.id" |
| 90 | + When the request is sent |
| 91 | + Then the response status is 200 OK |
| 92 | + |
| 93 | + @skip-terraform-config @team:DataDog/logs-app |
| 94 | + Scenario: Get all restriction queries for a given user returns "Bad Request" response |
| 95 | + Given operation "ListUserRestrictionQueries" enabled |
| 96 | + And new "ListUserRestrictionQueries" request |
| 97 | + And request contains "user_id" parameter with value "malformed_id" |
| 98 | + When the request is sent |
| 99 | + Then the response status is 400 Bad Request |
| 100 | + |
| 101 | + @team:DataDog/logs-app |
| 102 | + Scenario: Get all restriction queries for a given user returns "Not found" response |
| 103 | + Given operation "ListUserRestrictionQueries" enabled |
| 104 | + And new "ListUserRestrictionQueries" request |
| 105 | + And request contains "user_id" parameter with value "00000000-0000-0000-0000-000000000000" |
| 106 | + When the request is sent |
| 107 | + Then the response status is 400 Bad Request |
| 108 | + |
| 109 | + @team:DataDog/logs-app |
| 110 | + Scenario: Get all restriction queries for a given user returns "OK" response |
| 111 | + Given operation "ListUserRestrictionQueries" enabled |
| 112 | + And there is a valid "user" in the system |
| 113 | + And new "ListUserRestrictionQueries" request |
| 114 | + And request contains "user_id" parameter from "user.data.id" |
| 115 | + When the request is sent |
| 116 | + Then the response status is 200 OK |
| 117 | + |
| 118 | + @skip-terraform-config @team:DataDog/logs-app |
| 119 | + Scenario: Get restriction query for a given role returns "Bad Request" response |
| 120 | + Given operation "GetRoleRestrictionQuery" enabled |
| 121 | + And new "GetRoleRestrictionQuery" request |
| 122 | + And request contains "role_id" parameter with value "malformed_id" |
| 123 | + When the request is sent |
| 124 | + Then the response status is 400 Bad Request |
| 125 | + |
| 126 | + @team:DataDog/logs-app |
| 127 | + Scenario: Get restriction query for a given role returns "Not found" response |
| 128 | + Given operation "GetRoleRestrictionQuery" enabled |
| 129 | + And new "GetRoleRestrictionQuery" request |
| 130 | + And request contains "role_id" parameter with value "00000000-0000-0000-0000-000000000000" |
| 131 | + When the request is sent |
| 132 | + Then the response status is 400 Bad Request |
| 133 | + |
| 134 | + @team:DataDog/logs-app |
| 135 | + Scenario: Get restriction query for a given role returns "OK" response |
| 136 | + Given operation "GetRoleRestrictionQuery" enabled |
| 137 | + And there is a valid "role" in the system |
| 138 | + And new "GetRoleRestrictionQuery" request |
| 139 | + And request contains "role_id" parameter from "role.data.id" |
| 140 | + When the request is sent |
| 141 | + Then the response status is 200 OK |
| 142 | + |
| 143 | + @skip-terraform-config @team:DataDog/logs-app |
| 144 | + Scenario: Grant role to a restriction query returns "Bad Request" response |
| 145 | + Given operation "AddRoleToRestrictionQuery" enabled |
| 146 | + And new "AddRoleToRestrictionQuery" request |
| 147 | + And request contains "restriction_query_id" parameter with value "malformed_id" |
| 148 | + And body with value {"data": {"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d", "type": "roles"}} |
| 149 | + When the request is sent |
| 150 | + Then the response status is 404 Not found |
| 151 | + |
| 152 | + @skip-terraform-config @team:DataDog/logs-app |
| 153 | + Scenario: Grant role to a restriction query returns "Not found" response |
| 154 | + Given operation "AddRoleToRestrictionQuery" enabled |
| 155 | + And new "AddRoleToRestrictionQuery" request |
| 156 | + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" |
| 157 | + And body with value {"data": {"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d", "type": "roles"}} |
| 158 | + When the request is sent |
| 159 | + Then the response status is 404 Not found |
| 160 | + |
| 161 | + @team:DataDog/logs-app |
| 162 | + Scenario: Grant role to a restriction query returns "OK" response |
| 163 | + Given operation "AddRoleToRestrictionQuery" enabled |
| 164 | + And there is a valid "restriction_query" in the system |
| 165 | + And there is a valid "role" in the system |
| 166 | + And new "AddRoleToRestrictionQuery" request |
| 167 | + And request contains "restriction_query_id" parameter from "restriction_query.data.id" |
| 168 | + And body with value {"data": {"id": "{{ role.data.id }}", "type": "roles"}} |
| 169 | + When the request is sent |
| 170 | + Then the response status is 204 OK |
| 171 | + |
| 172 | + @skip-terraform-config @team:DataDog/logs-app |
| 173 | + Scenario: List restriction queries returns "OK" response |
| 174 | + Given operation "ListRestrictionQueries" enabled |
| 175 | + And new "ListRestrictionQueries" request |
| 176 | + When the request is sent |
| 177 | + Then the response status is 200 OK |
| 178 | + |
| 179 | + @skip-terraform-config @team:DataDog/logs-app |
| 180 | + Scenario: List roles for a restriction query returns "Bad Request" response |
| 181 | + Given operation "ListRestrictionQueryRoles" enabled |
| 182 | + And new "ListRestrictionQueryRoles" request |
| 183 | + And request contains "restriction_query_id" parameter with value "malformed_id" |
| 184 | + When the request is sent |
| 185 | + Then the response status is 400 Bad Request |
| 186 | + |
| 187 | + @skip-terraform-config @team:DataDog/logs-app |
| 188 | + Scenario: List roles for a restriction query returns "Not found" response |
| 189 | + Given operation "ListRestrictionQueryRoles" enabled |
| 190 | + And new "ListRestrictionQueryRoles" request |
| 191 | + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" |
| 192 | + When the request is sent |
| 193 | + Then the response status is 404 Not found |
| 194 | + |
| 195 | + @team:DataDog/logs-app |
| 196 | + Scenario: List roles for a restriction query returns "OK" response |
| 197 | + Given operation "ListRestrictionQueryRoles" enabled |
| 198 | + And there is a valid "restriction_query" in the system |
| 199 | + And new "ListRestrictionQueryRoles" request |
| 200 | + And request contains "restriction_query_id" parameter from "restriction_query.data.id" |
| 201 | + When the request is sent |
| 202 | + Then the response status is 200 OK |
| 203 | + |
| 204 | + @skip @team:DataDog/logs-app |
| 205 | + Scenario: Replace a restriction query returns "Bad Request" response |
| 206 | + Given operation "ReplaceRestrictionQuery" enabled |
| 207 | + And new "ReplaceRestrictionQuery" request |
| 208 | + And request contains "restriction_query_id" parameter with value "malformed_id" |
| 209 | + And body with value {"data": {"attributes": {"restriction_query": "env:sandbox"}, "type": "logs_restriction_queries"}} |
| 210 | + When the request is sent |
| 211 | + Then the response status is 400 Bad Request |
| 212 | + |
| 213 | + @skip @team:DataDog/logs-app |
| 214 | + Scenario: Replace a restriction query returns "Not found" response |
| 215 | + Given operation "ReplaceRestrictionQuery" enabled |
| 216 | + And new "ReplaceRestrictionQuery" request |
| 217 | + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" |
| 218 | + And body with value {"data": {"attributes": {"restriction_query": "env:sandbox"}, "type": "logs_restriction_queries"}} |
| 219 | + When the request is sent |
| 220 | + Then the response status is 404 Not found |
| 221 | + |
| 222 | + @skip @team:DataDog/logs-app |
| 223 | + Scenario: Replace a restriction query returns "OK" response |
| 224 | + Given operation "ReplaceRestrictionQuery" enabled |
| 225 | + And there is a valid "restriction_query" in the system |
| 226 | + And new "ReplaceRestrictionQuery" request |
| 227 | + And request contains "restriction_query_id" parameter from "restriction_query.data.id" |
| 228 | + And body with value {"data": {"attributes": {"restriction_query": "env:staging"}, "type": "logs_restriction_queries"}} |
| 229 | + When the request is sent |
| 230 | + Then the response status is 200 OK |
| 231 | + |
| 232 | + @skip @skip-terraform-config @team:DataDog/logs-app |
| 233 | + Scenario: Revoke role from a restriction query returns "Bad Request" response |
| 234 | + Given operation "RemoveRoleFromRestrictionQuery" enabled |
| 235 | + And new "RemoveRoleFromRestrictionQuery" request |
| 236 | + And request contains "restriction_query_id" parameter with value "malformed_id" |
| 237 | + And body with value {"data": {"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d", "type": "roles"}} |
| 238 | + When the request is sent |
| 239 | + Then the response status is 400 Bad Request |
| 240 | + |
| 241 | + @skip @skip-terraform-config @team:DataDog/logs-app |
| 242 | + Scenario: Revoke role from a restriction query returns "Not found" response |
| 243 | + Given operation "RemoveRoleFromRestrictionQuery" enabled |
| 244 | + And new "RemoveRoleFromRestrictionQuery" request |
| 245 | + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" |
| 246 | + And body with value {"data": {"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d", "type": "roles"}} |
| 247 | + When the request is sent |
| 248 | + Then the response status is 404 Not found |
| 249 | + |
| 250 | + @skip @team:DataDog/logs-app |
| 251 | + Scenario: Revoke role from a restriction query returns "OK" response |
| 252 | + Given operation "RemoveRoleFromRestrictionQuery" enabled |
| 253 | + And there is a valid "restriction_query" in the system |
| 254 | + And there is a valid "role" in the system |
| 255 | + And new "RemoveRoleFromRestrictionQuery" request |
| 256 | + And request contains "restriction_query_id" parameter from "restriction_query.data.id" |
| 257 | + And body with value {"data": {"id": "{{ role.data.id }}", "type": "roles"}} |
| 258 | + When the request is sent |
| 259 | + Then the response status is 204 OK |
| 260 | + |
| 261 | + @skip @skip-terraform-config @team:DataDog/logs-app |
| 262 | + Scenario: Update a restriction query returns "Bad Request" response |
| 263 | + Given operation "UpdateRestrictionQuery" enabled |
| 264 | + And new "UpdateRestrictionQuery" request |
| 265 | + And request contains "restriction_query_id" parameter with value "malformed_id" |
| 266 | + And body with value {"data": {"attributes": {"restriction_query": "env:sandbox"}, "type": "logs_restriction_queries"}} |
| 267 | + When the request is sent |
| 268 | + Then the response status is 400 Bad Request |
| 269 | + |
| 270 | + @skip @skip-terraform-config @team:DataDog/logs-app |
| 271 | + Scenario: Update a restriction query returns "Not found" response |
| 272 | + Given operation "UpdateRestrictionQuery" enabled |
| 273 | + And new "UpdateRestrictionQuery" request |
| 274 | + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" |
| 275 | + And body with value {"data": {"attributes": {"restriction_query": "env:sandbox"}, "type": "logs_restriction_queries"}} |
| 276 | + When the request is sent |
| 277 | + Then the response status is 404 Not found |
| 278 | + |
| 279 | + @skip @team:DataDog/logs-app |
| 280 | + Scenario: Update a restriction query returns "OK" response |
| 281 | + Given operation "UpdateRestrictionQuery" enabled |
| 282 | + And there is a valid "restriction_query" in the system |
| 283 | + And new "UpdateRestrictionQuery" request |
| 284 | + And request contains "restriction_query_id" parameter from "restriction_query.data.id" |
| 285 | + And body with value {"data": {"attributes": {"restriction_query": "env:production"}, "type": "logs_restriction_queries"}} |
| 286 | + When the request is sent |
| 287 | + Then the response status is 200 OK |
0 commit comments