diff --git a/.changes/unreleased/optimization-20260617-052412.yaml b/.changes/unreleased/optimization-20260617-052412.yaml new file mode 100644 index 000000000..a2d70c437 --- /dev/null +++ b/.changes/unreleased/optimization-20260617-052412.yaml @@ -0,0 +1,6 @@ +kind: optimization +body: Adds validation for backup retention days on SQL DB +time: 2026-06-17T05:24:12.568818136Z +custom: + Author: v-alexmoraru + AuthorLink: https://github.com/v-alexmoraru diff --git a/src/fabric_cli/commands/fs/set/fab_fs_set_item.py b/src/fabric_cli/commands/fs/set/fab_fs_set_item.py index 9d1c61008..704f876fd 100644 --- a/src/fabric_cli/commands/fs/set/fab_fs_set_item.py +++ b/src/fabric_cli/commands/fs/set/fab_fs_set_item.py @@ -8,7 +8,11 @@ from fabric_cli.core import fab_constant from fabric_cli.core.fab_commands import Command from fabric_cli.core.fab_exceptions import FabricCLIError -from fabric_cli.core.fab_types import definition_format_mapping, format_mapping +from fabric_cli.core.fab_types import ( + ItemType, + definition_format_mapping, + format_mapping, +) from fabric_cli.core.hiearchy.fab_hiearchy import Item from fabric_cli.errors.common import CommonErrors from fabric_cli.utils import fab_cmd_set_utils as utils_set @@ -24,6 +28,10 @@ def exec(item: Item, args: Namespace) -> None: utils_set.validate_item_query(query_value, item) + # Validate SQLDatabase-specific properties + if item.item_type == ItemType.SQL_DATABASE: + utils_set.validate_sql_database_property(query_value, args.input) + utils_set.print_set_warning() if force or utils_ui.prompt_confirm(): args.output = None diff --git a/src/fabric_cli/core/fab_constant.py b/src/fabric_cli/core/fab_constant.py index 4fd00e7b9..facb5fdf8 100644 --- a/src/fabric_cli/core/fab_constant.py +++ b/src/fabric_cli/core/fab_constant.py @@ -352,3 +352,9 @@ # Invalid query parameters for set command across all fabric resources SET_COMMAND_INVALID_QUERIES = ["id", "type", "workspaceId", "folderId"] +# SQLDatabase property validation +SQL_DATABASE_BACKUP_RETENTION = { + "property": "properties.backupRetentionDays", + "min_days": 1, + "max_days": 35, +} diff --git a/src/fabric_cli/errors/common.py b/src/fabric_cli/errors/common.py index 6fcfc0009..c8d62a199 100644 --- a/src/fabric_cli/errors/common.py +++ b/src/fabric_cli/errors/common.py @@ -264,3 +264,10 @@ def unsupported_parameter(key: str) -> str: @staticmethod def invalid_parameter_format(param: str) -> str: return f"Invalid parameter format: '{param}'. Use key=value or key!=value." + + @staticmethod + def invalid_backup_retention_days(value: str, min_days: int, max_days: int) -> str: + return ( + f"Invalid backup retention days value '{value}'. " + f"Must be an integer between {min_days} and {max_days} days." + ) diff --git a/src/fabric_cli/utils/fab_cmd_set_utils.py b/src/fabric_cli/utils/fab_cmd_set_utils.py index a947b0823..ebc94c1e3 100644 --- a/src/fabric_cli/utils/fab_cmd_set_utils.py +++ b/src/fabric_cli/utils/fab_cmd_set_utils.py @@ -92,6 +92,48 @@ def validate_query_not_in_blocklist( ) +def validate_sql_database_property(query: str, input_value: str) -> None: + """Validate SQLDatabase-specific property values. + + Args: + query: The property query path being set. + input_value: The input value to validate. + + Raises: + FabricCLIError: If the value is invalid for the property. + """ + if query == fab_constant.SQL_DATABASE_BACKUP_RETENTION["property"]: + min_days: int = fab_constant.SQL_DATABASE_BACKUP_RETENTION["min_days"] # type: ignore[assignment] + max_days: int = fab_constant.SQL_DATABASE_BACKUP_RETENTION["max_days"] # type: ignore[assignment] + + try: + try: + value = int(input_value) + except ValueError: + # Fall back to JSON for encoded values like '7' or '"7"' + parsed = json.loads(input_value) + if type(parsed) is int: + value = parsed + elif isinstance(parsed, str): + value = int(parsed) + else: + raise ValueError("Value must be an integer") + + # Validate range + if not min_days <= value <= max_days: + raise ValueError("Out of range") + + except (ValueError, TypeError, json.JSONDecodeError): + raise FabricCLIError( + CommonErrors.invalid_backup_retention_days( + str(input_value), + min_days, + max_days, + ), + fab_constant.ERROR_INVALID_INPUT, + ) + + def ensure_notebook_dependency(decoded_item_def: dict, query: str) -> dict: dependency_types = ["lakehouse", "warehouse", "environment"] diff --git a/tests/test_commands/recordings/test_commands/test_set/class_setup.yaml b/tests/test_commands/recordings/test_commands/test_set/class_setup.yaml index f3da5c436..891346f6f 100644 --- a/tests/test_commands/recordings/test_commands/test_set/class_setup.yaml +++ b/tests/test_commands/recordings/test_commands/test_set/class_setup.yaml @@ -11,7 +11,7 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.6.1 (set; Darwin/25.4.0; Python/3.12.13) + - ms-fabric-cli/1.6.1 (None; Darwin/25.5.0; Python/3.12.13) method: GET uri: https://api.fabric.microsoft.com/v1/workspaces response: @@ -26,15 +26,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '2561' + - '3271' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 13 May 2026 11:03:06 GMT + - Mon, 22 Jun 2026 10:24:15 GMT Pragma: - no-cache RequestId: - - 93630144-c10b-421b-9f61-b4c9e96e53ce + - 0ac62403-a6a3-4d41-9ba3-003c8602aba5 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -60,7 +60,7 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.6.1 (set; Darwin/25.4.0; Python/3.12.13) + - ms-fabric-cli/1.6.1 (None; Darwin/25.5.0; Python/3.12.13) method: GET uri: https://api.fabric.microsoft.com/v1/workspaces response: @@ -75,15 +75,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '2561' + - '3271' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 13 May 2026 11:03:08 GMT + - Mon, 22 Jun 2026 10:24:16 GMT Pragma: - no-cache RequestId: - - 222a5ebf-a440-4c9b-8a2c-0e1e46b6b6ba + - 99ad22cd-a211-49c1-a265-65387ef2f3a8 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -109,7 +109,7 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.6.1 (set; Darwin/25.4.0; Python/3.12.13) + - ms-fabric-cli/1.6.1 (None; Darwin/25.5.0; Python/3.12.13) method: GET uri: https://api.fabric.microsoft.com/v1/capacities response: @@ -125,15 +125,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '426' + - '467' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 13 May 2026 11:03:13 GMT + - Mon, 22 Jun 2026 10:24:20 GMT Pragma: - no-cache RequestId: - - dfb69fa0-b455-4808-ae5f-1a7ddef6e34b + - 4125973b-3677-4f49-b023-d3d1c7e54013 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -162,13 +162,14 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.6.1 (set; Darwin/25.4.0; Python/3.12.13) + - ms-fabric-cli/1.6.1 (None; Darwin/25.5.0; Python/3.12.13) method: POST uri: https://api.fabric.microsoft.com/v1/workspaces response: body: - string: '{"id": "81517fa4-30e3-42e6-b751-b36af1c8e99a", "displayName": "fabriccli_WorkspacePerTestclass_000001", - "description": "", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}' + string: '{"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", "displayName": "fabriccli_WorkspacePerTestclass_000001", + "description": "", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}' headers: Access-Control-Expose-Headers: - RequestId,Location @@ -177,17 +178,17 @@ interactions: Content-Encoding: - gzip Content-Length: - - '175' + - '196' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 13 May 2026 11:03:21 GMT + - Mon, 22 Jun 2026 10:24:27 GMT Location: - - https://api.fabric.microsoft.com/v1/workspaces/81517fa4-30e3-42e6-b751-b36af1c8e99a + - https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785 Pragma: - no-cache RequestId: - - 6f6fd3f9-2eeb-4e85-afe0-f530855a0a0f + - 7e828071-8289-4077-8d4d-e3457f16519e Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -213,15 +214,16 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.6.1 (set; Darwin/25.4.0; Python/3.12.13) + - ms-fabric-cli/1.6.1 (set; Darwin/25.5.0; Python/3.12.13) method: GET uri: https://api.fabric.microsoft.com/v1/workspaces response: body: string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": - "My workspace", "description": "", "type": "Personal"}, {"id": "81517fa4-30e3-42e6-b751-b36af1c8e99a", + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", - "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004"}]}' + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' headers: Access-Control-Expose-Headers: - RequestId @@ -230,15 +232,15 @@ interactions: Content-Encoding: - gzip Content-Length: - - '2595' + - '3305' Content-Type: - application/json; charset=utf-8 Date: - - Wed, 13 May 2026 11:03:33 GMT + - Mon, 22 Jun 2026 10:27:17 GMT Pragma: - no-cache RequestId: - - 5a815f03-74e2-4496-aae0-2364a02687cd + - 9e78df05-b2a2-4ce4-843a-bda0398b43cf Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -264,9 +266,9 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.6.1 (set; Darwin/25.4.0; Python/3.12.13) + - ms-fabric-cli/1.6.1 (set; Darwin/25.5.0; Python/3.12.13) method: GET - uri: https://api.fabric.microsoft.com/v1/workspaces/81517fa4-30e3-42e6-b751-b36af1c8e99a/items + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items response: body: string: '{"value": []}' @@ -282,11 +284,11 @@ interactions: Content-Type: - application/json; charset=utf-8 Date: - - Wed, 13 May 2026 11:03:34 GMT + - Mon, 22 Jun 2026 10:27:17 GMT Pragma: - no-cache RequestId: - - 1283e8eb-846f-49ab-b1e4-4438ef0df0f9 + - 6c9a0dc2-a403-4a19-b791-a85c6e9f0901 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: @@ -314,9 +316,9 @@ interactions: Content-Type: - application/json User-Agent: - - ms-fabric-cli/1.6.1 (set; Darwin/25.4.0; Python/3.12.13) + - ms-fabric-cli/1.6.1 (set; Darwin/25.5.0; Python/3.12.13) method: DELETE - uri: https://api.fabric.microsoft.com/v1/workspaces/81517fa4-30e3-42e6-b751-b36af1c8e99a + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785 response: body: string: '' @@ -332,11 +334,11 @@ interactions: Content-Type: - application/octet-stream Date: - - Wed, 13 May 2026 11:03:35 GMT + - Mon, 22 Jun 2026 10:27:18 GMT Pragma: - no-cache RequestId: - - b0ec7a9f-0f36-4321-9c58-823c5894cd4c + - 216a3d44-a475-48ff-88a9-7edcfacbac44 Strict-Transport-Security: - max-age=31536000; includeSubDomains X-Content-Type-Options: diff --git a/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_float_value_failure.yaml b/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_float_value_failure.yaml new file mode 100644 index 000000000..9f75b172b --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_float_value_failure.yaml @@ -0,0 +1,555 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:17 GMT + Pragma: + - no-cache + RequestId: + - df8f90be-0111-4a99-a682-9c752903cfb8 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:17 GMT + Pragma: + - no-cache + RequestId: + - 5964ced7-4198-470d-ba1f-9f75d1431489 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:18 GMT + Pragma: + - no-cache + RequestId: + - 9c877753-61b0-4891-a734-73b6211c32cf + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: '{"displayName": "fabcli000001", "type": "SQLDatabase", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '76' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/sqlDatabases + response: + body: + string: 'null' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,Retry-After,ETag,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '24' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:21 GMT + ETag: + - '""' + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/878b4c3a-e131-41a0-abe3-1c4ef58bc5c0 + Pragma: + - no-cache + RequestId: + - 547bdf9b-690c-47a2-8c99-f5313933bfd8 + Retry-After: + - '20' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + x-ms-operation-id: + - 878b4c3a-e131-41a0-abe3-1c4ef58bc5c0 + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/878b4c3a-e131-41a0-abe3-1c4ef58bc5c0 + response: + body: + string: '{"status": "Succeeded", "createdTimeUtc": "2026-06-22T10:26:19.9258538", + "lastUpdatedTimeUtc": "2026-06-22T10:26:33.856033", "percentComplete": 100, + "error": null}' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '130' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:41 GMT + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/878b4c3a-e131-41a0-abe3-1c4ef58bc5c0/result + Pragma: + - no-cache + RequestId: + - 48485768-827a-4d17-9bbe-69b482a325e4 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + x-ms-operation-id: + - 878b4c3a-e131-41a0-abe3-1c4ef58bc5c0 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/878b4c3a-e131-41a0-abe3-1c4ef58bc5c0/result + response: + body: + string: '{"id": "06fb3b23-a9f0-4196-893e-a4bf6a3f4200", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 22 Jun 2026 10:26:42 GMT + Pragma: + - no-cache + RequestId: + - 58db35c2-3750-4f05-867f-c5fa47b776f1 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:43 GMT + Pragma: + - no-cache + RequestId: + - 83f601e5-881e-48a9-ac10-0c69ada7067a + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": [{"id": "06fb3b23-a9f0-4196-893e-a4bf6a3f4200", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '171' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:43 GMT + Pragma: + - no-cache + RequestId: + - ee73a4ee-1cae-4dfb-a0e1-30e9ab4e74c3 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:44 GMT + Pragma: + - no-cache + RequestId: + - 2430b5c3-fd42-4ed0-8a07-4ecee85e9d2f + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": [{"id": "06fb3b23-a9f0-4196-893e-a4bf6a3f4200", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '171' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:45 GMT + Pragma: + - no-cache + RequestId: + - 06ac341a-7f93-4981-9773-666212e78084 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items/06fb3b23-a9f0-4196-893e-a4bf6a3f4200 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Mon, 22 Jun 2026 10:26:46 GMT + Pragma: + - no-cache + RequestId: + - 0245e37b-ef22-4509-bb1d-69c26f3758dc + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_invalid_value_failure.yaml b/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_invalid_value_failure.yaml new file mode 100644 index 000000000..e0ad2f5ac --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_invalid_value_failure.yaml @@ -0,0 +1,611 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:24:27 GMT + Pragma: + - no-cache + RequestId: + - 281b7d03-abfc-406b-91d4-569129bdacc8 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:24:29 GMT + Pragma: + - no-cache + RequestId: + - 474bd47a-f775-459a-b40c-1a76a6d239a4 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:24:29 GMT + Pragma: + - no-cache + RequestId: + - 24481788-4ac5-4d76-a8ef-39d332f8c686 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: '{"displayName": "fabcli000001", "type": "SQLDatabase", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '76' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/sqlDatabases + response: + body: + string: 'null' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,Retry-After,ETag,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '24' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:24:31 GMT + ETag: + - '""' + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/821c64d6-0c50-42b7-91ed-417c1d506a04 + Pragma: + - no-cache + RequestId: + - cfe1f20c-f14a-4ad6-b168-003efcd052d5 + Retry-After: + - '20' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + x-ms-operation-id: + - 821c64d6-0c50-42b7-91ed-417c1d506a04 + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/821c64d6-0c50-42b7-91ed-417c1d506a04 + response: + body: + string: '{"status": "Running", "createdTimeUtc": "2026-06-22T10:24:30.98695", + "lastUpdatedTimeUtc": "2026-06-22T10:24:30.98695", "percentComplete": null, + "error": null}' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,Retry-After,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '122' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:24:52 GMT + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/821c64d6-0c50-42b7-91ed-417c1d506a04 + Pragma: + - no-cache + RequestId: + - 14e2211c-0782-4c52-8c0e-1adb7c3be229 + Retry-After: + - '20' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + x-ms-operation-id: + - 821c64d6-0c50-42b7-91ed-417c1d506a04 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/821c64d6-0c50-42b7-91ed-417c1d506a04 + response: + body: + string: '{"status": "Succeeded", "createdTimeUtc": "2026-06-22T10:24:30.98695", + "lastUpdatedTimeUtc": "2026-06-22T10:24:54.6096087", "percentComplete": 100, + "error": null}' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '130' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:13 GMT + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/821c64d6-0c50-42b7-91ed-417c1d506a04/result + Pragma: + - no-cache + RequestId: + - c961ec81-59c2-4c8d-83ab-f2af261fda9e + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + x-ms-operation-id: + - 821c64d6-0c50-42b7-91ed-417c1d506a04 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/821c64d6-0c50-42b7-91ed-417c1d506a04/result + response: + body: + string: '{"id": "ca9f7e25-2bd9-458e-aeb1-484742dd2758", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 22 Jun 2026 10:25:13 GMT + Pragma: + - no-cache + RequestId: + - 96b8b80d-4fcc-4f70-af76-c3e1119fce75 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:14 GMT + Pragma: + - no-cache + RequestId: + - a05d90ed-9ded-4ccf-a744-753c32d15309 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": [{"id": "e0cbda9c-a9a2-4f06-bef0-1570eff0aae1", "type": "SQLEndpoint", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}, + {"id": "ca9f7e25-2bd9-458e-aeb1-484742dd2758", "type": "SQLDatabase", "displayName": + "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '211' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:15 GMT + Pragma: + - no-cache + RequestId: + - 5bdf565b-732e-438a-8044-db413a0f6327 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:16 GMT + Pragma: + - no-cache + RequestId: + - 9d68ae41-e34c-4ecc-b9d4-37ab9af836e5 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": [{"id": "e0cbda9c-a9a2-4f06-bef0-1570eff0aae1", "type": "SQLEndpoint", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}, + {"id": "ca9f7e25-2bd9-458e-aeb1-484742dd2758", "type": "SQLDatabase", "displayName": + "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '211' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:17 GMT + Pragma: + - no-cache + RequestId: + - bcc2f314-8122-42a1-a74b-4a2547d5f95f + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items/ca9f7e25-2bd9-458e-aeb1-484742dd2758 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Mon, 22 Jun 2026 10:25:18 GMT + Pragma: + - no-cache + RequestId: + - c32a042a-f398-42f1-9938-503982bbb0f9 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_negative_value_failure.yaml b/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_negative_value_failure.yaml new file mode 100644 index 000000000..a762f2b36 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_negative_value_failure.yaml @@ -0,0 +1,557 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:47 GMT + Pragma: + - no-cache + RequestId: + - 173d424f-0dd3-4f10-b38c-ddd6692105bc + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:48 GMT + Pragma: + - no-cache + RequestId: + - c6ea8a01-a470-4881-83e8-f197772eb22a + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:49 GMT + Pragma: + - no-cache + RequestId: + - 75cd1ab6-07bd-425d-aa55-2702e0ceebcf + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: '{"displayName": "fabcli000001", "type": "SQLDatabase", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '76' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/sqlDatabases + response: + body: + string: 'null' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,Retry-After,ETag,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '24' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:51 GMT + ETag: + - '""' + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/d3532b9e-9e37-4ff7-897c-4d77be44802b + Pragma: + - no-cache + RequestId: + - 54dcf807-3772-4eb2-ab41-55cffc1f675d + Retry-After: + - '20' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + x-ms-operation-id: + - d3532b9e-9e37-4ff7-897c-4d77be44802b + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/d3532b9e-9e37-4ff7-897c-4d77be44802b + response: + body: + string: '{"status": "Succeeded", "createdTimeUtc": "2026-06-22T10:25:50.7608466", + "lastUpdatedTimeUtc": "2026-06-22T10:26:10.1126261", "percentComplete": 100, + "error": null}' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '131' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:12 GMT + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/d3532b9e-9e37-4ff7-897c-4d77be44802b/result + Pragma: + - no-cache + RequestId: + - 50785f47-fbac-4c87-aa58-dbbb27ee3b1d + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + x-ms-operation-id: + - d3532b9e-9e37-4ff7-897c-4d77be44802b + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/d3532b9e-9e37-4ff7-897c-4d77be44802b/result + response: + body: + string: '{"id": "6ea15be2-38d5-4f3c-bff4-5f4f40d9a877", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 22 Jun 2026 10:26:12 GMT + Pragma: + - no-cache + RequestId: + - 9fe4b946-338c-43bb-b0be-9a42e12b0a02 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:13 GMT + Pragma: + - no-cache + RequestId: + - b0ddd7fb-93c7-483c-8d03-69adf0dc0ffb + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": [{"id": "6ea15be2-38d5-4f3c-bff4-5f4f40d9a877", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '170' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:14 GMT + Pragma: + - no-cache + RequestId: + - 2f5ee7d2-e65c-4d4b-a9e6-facdcf03e303 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:14 GMT + Pragma: + - no-cache + RequestId: + - 816619d3-179b-4f15-b842-355d29a6f658 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": [{"id": "566cd624-6aea-4f8d-919d-dc762370ec2d", "type": "SQLEndpoint", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}, + {"id": "6ea15be2-38d5-4f3c-bff4-5f4f40d9a877", "type": "SQLDatabase", "displayName": + "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '213' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:15 GMT + Pragma: + - no-cache + RequestId: + - 543eb9c0-f7a7-4daa-a8b9-dcf09c959e5b + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items/6ea15be2-38d5-4f3c-bff4-5f4f40d9a877 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Mon, 22 Jun 2026 10:26:16 GMT + Pragma: + - no-cache + RequestId: + - e949b6a7-acc5-4077-86ec-b10fc520212d + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_out_of_range_failure.yaml b/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_out_of_range_failure.yaml new file mode 100644 index 000000000..86f2fb9aa --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_out_of_range_failure.yaml @@ -0,0 +1,555 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:19 GMT + Pragma: + - no-cache + RequestId: + - 3b313220-01d9-4f10-b8e0-5c53b9cd2e70 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:19 GMT + Pragma: + - no-cache + RequestId: + - 8967598a-0877-4870-a9a0-0b99eb7903b8 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:20 GMT + Pragma: + - no-cache + RequestId: + - e1c5b100-76aa-4b99-97b1-06ef61a3268e + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: '{"displayName": "fabcli000001", "type": "SQLDatabase", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '76' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/sqlDatabases + response: + body: + string: 'null' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,Retry-After,ETag,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '24' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:22 GMT + ETag: + - '""' + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/6426aca4-61c1-4a0e-bf98-d79a3d19bace + Pragma: + - no-cache + RequestId: + - 3584ddde-ac07-4f9c-9bb8-4b668605e36e + Retry-After: + - '20' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + x-ms-operation-id: + - 6426aca4-61c1-4a0e-bf98-d79a3d19bace + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/6426aca4-61c1-4a0e-bf98-d79a3d19bace + response: + body: + string: '{"status": "Succeeded", "createdTimeUtc": "2026-06-22T10:25:22.0560649", + "lastUpdatedTimeUtc": "2026-06-22T10:25:38.4270342", "percentComplete": 100, + "error": null}' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '131' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:43 GMT + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/6426aca4-61c1-4a0e-bf98-d79a3d19bace/result + Pragma: + - no-cache + RequestId: + - 4d44bc91-4cf7-4b42-9a98-0f340773db0d + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + x-ms-operation-id: + - 6426aca4-61c1-4a0e-bf98-d79a3d19bace + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/6426aca4-61c1-4a0e-bf98-d79a3d19bace/result + response: + body: + string: '{"id": "9e74fbf2-a811-43a1-aa74-b82471a97970", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 22 Jun 2026 10:25:44 GMT + Pragma: + - no-cache + RequestId: + - 6f059883-1c58-4bc6-ac6e-2a68a59e171d + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:45 GMT + Pragma: + - no-cache + RequestId: + - 18dc2d84-5112-4c21-9fd5-eb6bb65bf39e + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": [{"id": "9e74fbf2-a811-43a1-aa74-b82471a97970", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '171' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:45 GMT + Pragma: + - no-cache + RequestId: + - 809f5e6a-6a37-403d-a7f1-4c650c037e19 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:46 GMT + Pragma: + - no-cache + RequestId: + - 3f5940e9-05c7-4e25-9628-fb1cdc345c2a + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": [{"id": "9e74fbf2-a811-43a1-aa74-b82471a97970", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '171' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:25:47 GMT + Pragma: + - no-cache + RequestId: + - 79c74621-d94b-483f-bf3b-4a31d92c6de1 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items/9e74fbf2-a811-43a1-aa74-b82471a97970 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Mon, 22 Jun 2026 10:25:46 GMT + Pragma: + - no-cache + RequestId: + - b4d39f05-9d9f-4594-ab21-71a9810ca8cb + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_zero_value_failure.yaml b/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_zero_value_failure.yaml new file mode 100644 index 000000000..da301e607 --- /dev/null +++ b/tests/test_commands/recordings/test_commands/test_set/test_set_sql_database_backup_retention_days_zero_value_failure.yaml @@ -0,0 +1,555 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:46 GMT + Pragma: + - no-cache + RequestId: + - 2a0a181c-d415-4537-abf2-6eecbd91caf9 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:47 GMT + Pragma: + - no-cache + RequestId: + - 868fcb51-8a7f-4940-8fa7-2a859b88c9bb + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": []}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '32' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:47 GMT + Pragma: + - no-cache + RequestId: + - a7518c3b-dcda-45d5-bc89-bd1f1bc868fe + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: '{"displayName": "fabcli000001", "type": "SQLDatabase", "folderId": null}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '76' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: POST + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/sqlDatabases + response: + body: + string: 'null' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,Retry-After,ETag,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '24' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:26:49 GMT + ETag: + - '""' + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/76572303-0488-47fe-9c00-654473163fea + Pragma: + - no-cache + RequestId: + - e42ff147-1d6d-47cd-bd30-7c0756a720fb + Retry-After: + - '20' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + x-ms-operation-id: + - 76572303-0488-47fe-9c00-654473163fea + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/76572303-0488-47fe-9c00-654473163fea + response: + body: + string: '{"status": "Succeeded", "createdTimeUtc": "2026-06-22T10:26:49.3589311", + "lastUpdatedTimeUtc": "2026-06-22T10:27:09.6260271", "percentComplete": 100, + "error": null}' + headers: + Access-Control-Expose-Headers: + - RequestId,Location,x-ms-operation-id + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '133' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:27:10 GMT + Location: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/76572303-0488-47fe-9c00-654473163fea/result + Pragma: + - no-cache + RequestId: + - aa412e91-9224-468e-966d-92878771dfc4 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + x-ms-operation-id: + - 76572303-0488-47fe-9c00-654473163fea + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://wabi-us-central-b-primary-redirect.analysis.windows.net/v1/operations/76572303-0488-47fe-9c00-654473163fea/result + response: + body: + string: '{"id": "5882b1b4-43e7-4300-aad7-a9b884aca7a7", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Mon, 22 Jun 2026 10:27:11 GMT + Pragma: + - no-cache + RequestId: + - b27d7ea9-626f-4d04-b2d1-e6ae19f55c0d + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:27:12 GMT + Pragma: + - no-cache + RequestId: + - bf800864-6313-4b1c-b457-1832d052eb5a + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": [{"id": "5882b1b4-43e7-4300-aad7-a9b884aca7a7", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '171' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:27:13 GMT + Pragma: + - no-cache + RequestId: + - 8a74eb80-2b91-4f2f-a3e9-99651fa0fd5c + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces + response: + body: + string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName": + "My workspace", "description": "", "type": "Personal"}, {"id": "01b1815a-ce26-4272-b8b1-5bb469afc785", + "displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "", + "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004", + "capacityRegion": "Central US"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '3305' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:27:13 GMT + Pragma: + - no-cache + RequestId: + - 15e699da-5f8d-4a1c-9244-876ac35d5ea6 + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: GET + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items + response: + body: + string: '{"value": [{"id": "5882b1b4-43e7-4300-aad7-a9b884aca7a7", "type": "SQLDatabase", + "displayName": "fabcli000001", "description": "", "workspaceId": "01b1815a-ce26-4272-b8b1-5bb469afc785"}]}' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '171' + Content-Type: + - application/json; charset=utf-8 + Date: + - Mon, 22 Jun 2026 10:27:15 GMT + Pragma: + - no-cache + RequestId: + - 6eb65d70-c1f4-4524-b600-371cb22eb35a + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - ms-fabric-cli-test/1.6.1 + method: DELETE + uri: https://api.fabric.microsoft.com/v1/workspaces/01b1815a-ce26-4272-b8b1-5bb469afc785/items/5882b1b4-43e7-4300-aad7-a9b884aca7a7 + response: + body: + string: '' + headers: + Access-Control-Expose-Headers: + - RequestId + Cache-Control: + - no-store, must-revalidate, no-cache + Content-Encoding: + - gzip + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Mon, 22 Jun 2026 10:27:16 GMT + Pragma: + - no-cache + RequestId: + - 4b7271aa-78a2-46ad-a8ea-921b4167442d + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - deny + home-cluster-uri: + - https://wabi-us-central-b-primary-redirect.analysis.windows.net/ + request-redirected: + - 'true' + status: + code: 200 + message: OK +version: 1 diff --git a/tests/test_commands/test_set.py b/tests/test_commands/test_set.py index 386c02041..3c730a04b 100644 --- a/tests/test_commands/test_set.py +++ b/tests/test_commands/test_set.py @@ -27,7 +27,6 @@ set_item_metadata_success_params, set_item_metadata_success_params_complete, set_item_metadata_for_all_types_success_item_params, - set_item_metadata_success_params, set_workspace_success_params, set_sparkpool_success_params, set_capacity_success_params, @@ -240,6 +239,156 @@ def test_set_item_variable_library_properties_success( assert "Default value set" in str( mock_questionary_print.call_args[0][0]) + def test_set_sql_database_backup_retention_days_invalid_value_failure( + self, + item_factory, + cli_executor, + assert_fabric_cli_error, + mock_questionary_print, + mock_print_done, + mock_upsert_item_to_cache, + ): + """Test that setting backupRetentionDays with non-integer value fails.""" + # Setup + sql_database = item_factory(ItemType.SQL_DATABASE) + + # Reset mocks + mock_questionary_print.reset_mock() + mock_print_done.reset_mock() + mock_upsert_item_to_cache.reset_mock() + + # Execute command with invalid (non-integer) value + cli_executor.exec_command( + f"set {sql_database.full_path} --query properties.backupRetentionDays --input seven --force" + ) + + # Assert + assert_fabric_cli_error( + constant.ERROR_INVALID_INPUT, + "backup retention days", + ) + mock_upsert_item_to_cache.assert_not_called() + + def test_set_sql_database_backup_retention_days_out_of_range_failure( + self, + item_factory, + cli_executor, + assert_fabric_cli_error, + mock_questionary_print, + mock_print_done, + mock_upsert_item_to_cache, + ): + """Test that setting backupRetentionDays with out-of-range value fails.""" + # Setup + sql_database = item_factory(ItemType.SQL_DATABASE) + + # Reset mocks + mock_questionary_print.reset_mock() + mock_print_done.reset_mock() + mock_upsert_item_to_cache.reset_mock() + + # Execute command with out-of-range value (above max of 35) + cli_executor.exec_command( + f"set {sql_database.full_path} --query properties.backupRetentionDays --input 100 --force" + ) + + # Assert + assert_fabric_cli_error( + constant.ERROR_INVALID_INPUT, + "backup retention days", + ) + mock_upsert_item_to_cache.assert_not_called() + + def test_set_sql_database_backup_retention_days_negative_value_failure( + self, + item_factory, + cli_executor, + assert_fabric_cli_error, + mock_questionary_print, + mock_print_done, + mock_upsert_item_to_cache, + ): + """Test that setting backupRetentionDays with negative value fails.""" + # Setup + sql_database = item_factory(ItemType.SQL_DATABASE) + + # Reset mocks + mock_questionary_print.reset_mock() + mock_print_done.reset_mock() + mock_upsert_item_to_cache.reset_mock() + + # Execute command with negative value + cli_executor.exec_command( + f"set {sql_database.full_path} --query properties.backupRetentionDays --input -5 --force" + ) + + # Assert + assert_fabric_cli_error( + constant.ERROR_INVALID_INPUT, + "backup retention days", + ) + mock_upsert_item_to_cache.assert_not_called() + + def test_set_sql_database_backup_retention_days_float_value_failure( + self, + item_factory, + cli_executor, + assert_fabric_cli_error, + mock_questionary_print, + mock_print_done, + mock_upsert_item_to_cache, + ): + """Test that setting backupRetentionDays with float value fails.""" + # Setup + sql_database = item_factory(ItemType.SQL_DATABASE) + + # Reset mocks + mock_questionary_print.reset_mock() + mock_print_done.reset_mock() + mock_upsert_item_to_cache.reset_mock() + + # Execute command with float value + cli_executor.exec_command( + f"set {sql_database.full_path} --query properties.backupRetentionDays --input 7.5 --force" + ) + + # Assert + assert_fabric_cli_error( + constant.ERROR_INVALID_INPUT, + "backup retention days", + ) + mock_upsert_item_to_cache.assert_not_called() + + def test_set_sql_database_backup_retention_days_zero_value_failure( + self, + item_factory, + cli_executor, + assert_fabric_cli_error, + mock_questionary_print, + mock_print_done, + mock_upsert_item_to_cache, + ): + """Test that setting backupRetentionDays with zero value fails.""" + # Setup + sql_database = item_factory(ItemType.SQL_DATABASE) + + # Reset mocks + mock_questionary_print.reset_mock() + mock_print_done.reset_mock() + mock_upsert_item_to_cache.reset_mock() + + # Execute command with zero value (below min of 1) + cli_executor.exec_command( + f"set {sql_database.full_path} --query properties.backupRetentionDays --input 0 --force" + ) + + # Assert + assert_fabric_cli_error( + constant.ERROR_INVALID_INPUT, + "backup retention days", + ) + mock_upsert_item_to_cache.assert_not_called() + # endregion def test_set_domain_contributors_scope_success( diff --git a/tests/test_utils/test_fab_cmd_set_utils.py b/tests/test_utils/test_fab_cmd_set_utils.py index f3fa6f8ca..8d8d231ce 100644 --- a/tests/test_utils/test_fab_cmd_set_utils.py +++ b/tests/test_utils/test_fab_cmd_set_utils.py @@ -205,3 +205,69 @@ def test_update_cache_with_custom_name_key_success(): assert mock_element._name == "New Spark Pool Name" mock_cache_update_func.assert_called_once_with(mock_element) + + +# SQLDatabase validation tests + + +def test_validate_sql_database_property_backup_retention_days_valid_int_success(): + from fabric_cli.utils.fab_cmd_set_utils import validate_sql_database_property + + # Valid integer within range should not raise + validate_sql_database_property("properties.backupRetentionDays", "7") + validate_sql_database_property("properties.backupRetentionDays", "14") + validate_sql_database_property("properties.backupRetentionDays", "21") + validate_sql_database_property("properties.backupRetentionDays", "35") + validate_sql_database_property("properties.backupRetentionDays", "1") + + +def test_validate_sql_database_property_backup_retention_days_out_of_range_failure(): + from fabric_cli.core import fab_constant + from fabric_cli.utils.fab_cmd_set_utils import validate_sql_database_property + + # Value below minimum + with pytest.raises(FabricCLIError) as exc_info: + validate_sql_database_property("properties.backupRetentionDays", "0") + assert exc_info.value.status_code == fab_constant.ERROR_INVALID_INPUT + assert "backup retention days" in str(exc_info.value) + assert "1" in str(exc_info.value) + assert "35" in str(exc_info.value) + + # Value above maximum + with pytest.raises(FabricCLIError) as exc_info: + validate_sql_database_property("properties.backupRetentionDays", "36") + assert exc_info.value.status_code == fab_constant.ERROR_INVALID_INPUT + + +def test_validate_sql_database_property_backup_retention_days_not_integer_failure(): + from fabric_cli.core import fab_constant + from fabric_cli.utils.fab_cmd_set_utils import validate_sql_database_property + + # Non-integer string + with pytest.raises(FabricCLIError) as exc_info: + validate_sql_database_property("properties.backupRetentionDays", "seven") + assert exc_info.value.status_code == fab_constant.ERROR_INVALID_INPUT + assert "backup retention days" in str(exc_info.value) + + # Float value + with pytest.raises(FabricCLIError) as exc_info: + validate_sql_database_property("properties.backupRetentionDays", "7.5") + assert exc_info.value.status_code == fab_constant.ERROR_INVALID_INPUT + + +def test_validate_sql_database_property_backup_retention_days_negative_failure(): + from fabric_cli.core import fab_constant + from fabric_cli.utils.fab_cmd_set_utils import validate_sql_database_property + + with pytest.raises(FabricCLIError) as exc_info: + validate_sql_database_property("properties.backupRetentionDays", "-5") + assert exc_info.value.status_code == fab_constant.ERROR_INVALID_INPUT + + +def test_validate_sql_database_property_other_property_no_validation_success(): + from fabric_cli.utils.fab_cmd_set_utils import validate_sql_database_property + + # Other properties should pass without validation + validate_sql_database_property("properties.description", "any value") + validate_sql_database_property("properties.other", "some value") + validate_sql_database_property("displayName", "new name")