From e6c3bdcb3c3a1ad810bf8b70b216b31540f88a51 Mon Sep 17 00:00:00 2001 From: Amol Agarwal <57109831+amolagar5@users.noreply.github.com> Date: Mon, 16 Mar 2020 03:18:31 -0700 Subject: [PATCH] {SQL} fix az sql server ad-admin update , az sql server ad-admin create calls (#12541) * Fixing az sql server ad-admin update and az sql server ad-admin create. Adding test recording too. * update the comments * Revert update changes and fix it to have generic parameters. re-record test * change aad create from properties to parameters * remove spaces. * Removing comment for issue #6011 as tests are recorded now. * Fixing styling issues Co-authored-by: Amol Agarwal --- .../azure/cli/command_modules/sql/_params.py | 2 +- .../azure/cli/command_modules/sql/commands.py | 2 +- .../azure/cli/command_modules/sql/custom.py | 3 +- .../latest/recordings/test_aad_admin.yaml | 934 ++++++++++++++++++ .../sql/tests/latest/test_sql_commands.py | 66 +- 5 files changed, 973 insertions(+), 34 deletions(-) create mode 100644 src/azure-cli/azure/cli/command_modules/sql/tests/latest/recordings/test_aad_admin.yaml diff --git a/src/azure-cli/azure/cli/command_modules/sql/_params.py b/src/azure-cli/azure/cli/command_modules/sql/_params.py index f27a70d254d..453e8645f8d 100644 --- a/src/azure-cli/azure/cli/command_modules/sql/_params.py +++ b/src/azure-cli/azure/cli/command_modules/sql/_params.py @@ -1100,7 +1100,7 @@ def _configure_security_policy_storage_params(arg_ctx): with self.argument_context('sql server ad-admin create') as c: # Create args that will be used to build up the ServerAzureADAdministrator object create_args_for_complex_type( - c, 'properties', ServerAzureADAdministrator, [ + c, 'parameters', ServerAzureADAdministrator, [ 'login', 'sid', ]) diff --git a/src/azure-cli/azure/cli/command_modules/sql/commands.py b/src/azure-cli/azure/cli/command_modules/sql/commands.py index f01ba63c3c6..35eb947a699 100644 --- a/src/azure-cli/azure/cli/command_modules/sql/commands.py +++ b/src/azure-cli/azure/cli/command_modules/sql/commands.py @@ -420,7 +420,7 @@ def load_command_table(self, _): g.command('delete', 'delete') g.generic_update_command('update', custom_func_name='server_ad_admin_update', - setter_arg_name='properties') + setter_arg_name='parameters') server_keys_operations = CliCommandType( operations_tmpl='azure.mgmt.sql.operations#ServerKeysOperations.{}', diff --git a/src/azure-cli/azure/cli/command_modules/sql/custom.py b/src/azure-cli/azure/cli/command_modules/sql/custom.py index efff32a9591..eb38873d363 100644 --- a/src/azure-cli/azure/cli/command_modules/sql/custom.py +++ b/src/azure-cli/azure/cli/command_modules/sql/custom.py @@ -2071,7 +2071,7 @@ def server_ad_admin_set( return client.create_or_update( server_name=server_name, resource_group_name=resource_group_name, - properties=kwargs) + parameters=kwargs) def server_ad_admin_update( @@ -2090,7 +2090,6 @@ def server_ad_admin_update( return instance - ##### # sql server firewall-rule ##### diff --git a/src/azure-cli/azure/cli/command_modules/sql/tests/latest/recordings/test_aad_admin.yaml b/src/azure-cli/azure/cli/command_modules/sql/tests/latest/recordings/test_aad_admin.yaml new file mode 100644 index 00000000000..d63358b036e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/sql/tests/latest/recordings/test_aad_admin.yaml @@ -0,0 +1,934 @@ +interactions: +- request: + body: '{"location": "westeurope", "properties": {"administratorLogin": "admin123", + "administratorLoginPassword": "SecretPassword123"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server create + Connection: + - keep-alive + Content-Length: + - '127' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -l -g -n -u -p + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002?api-version=2019-06-01-preview + response: + body: + string: '{"operation":"UpsertLogicalServer","startTime":"2020-03-12T21:37:21.56Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAzureAsyncOperation/8b024440-74ae-4dab-bede-13dbb23a2bcd?api-version=2019-06-01-preview + cache-control: + - no-cache + content-length: + - '73' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:37:21 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverOperationResults/8b024440-74ae-4dab-bede-13dbb23a2bcd?api-version=2019-06-01-preview + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server create + Connection: + - keep-alive + ParameterSetName: + - -l -g -n -u -p + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAzureAsyncOperation/8b024440-74ae-4dab-bede-13dbb23a2bcd?api-version=2019-06-01-preview + response: + body: + string: '{"name":"8b024440-74ae-4dab-bede-13dbb23a2bcd","status":"InProgress","startTime":"2020-03-12T21:37:21.56Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:37:23 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server create + Connection: + - keep-alive + ParameterSetName: + - -l -g -n -u -p + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAzureAsyncOperation/8b024440-74ae-4dab-bede-13dbb23a2bcd?api-version=2019-06-01-preview + response: + body: + string: '{"name":"8b024440-74ae-4dab-bede-13dbb23a2bcd","status":"InProgress","startTime":"2020-03-12T21:37:21.56Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:37:24 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server create + Connection: + - keep-alive + ParameterSetName: + - -l -g -n -u -p + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAzureAsyncOperation/8b024440-74ae-4dab-bede-13dbb23a2bcd?api-version=2019-06-01-preview + response: + body: + string: '{"name":"8b024440-74ae-4dab-bede-13dbb23a2bcd","status":"InProgress","startTime":"2020-03-12T21:37:21.56Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:37:25 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server create + Connection: + - keep-alive + ParameterSetName: + - -l -g -n -u -p + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAzureAsyncOperation/8b024440-74ae-4dab-bede-13dbb23a2bcd?api-version=2019-06-01-preview + response: + body: + string: '{"name":"8b024440-74ae-4dab-bede-13dbb23a2bcd","status":"InProgress","startTime":"2020-03-12T21:37:21.56Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:37:26 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server create + Connection: + - keep-alive + ParameterSetName: + - -l -g -n -u -p + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAzureAsyncOperation/8b024440-74ae-4dab-bede-13dbb23a2bcd?api-version=2019-06-01-preview + response: + body: + string: '{"name":"8b024440-74ae-4dab-bede-13dbb23a2bcd","status":"InProgress","startTime":"2020-03-12T21:37:21.56Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:37:46 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server create + Connection: + - keep-alive + ParameterSetName: + - -l -g -n -u -p + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAzureAsyncOperation/8b024440-74ae-4dab-bede-13dbb23a2bcd?api-version=2019-06-01-preview + response: + body: + string: '{"name":"8b024440-74ae-4dab-bede-13dbb23a2bcd","status":"Succeeded","startTime":"2020-03-12T21:37:21.56Z"}' + headers: + cache-control: + - no-cache + content-length: + - '106' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:06 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server create + Connection: + - keep-alive + ParameterSetName: + - -l -g -n -u -p + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002?api-version=2019-06-01-preview + response: + body: + string: '{"kind":"v12.0","properties":{"administratorLogin":"admin123","version":"12.0","state":"Ready","fullyQualifiedDomainName":"clitestserver000002.database.windows.net","privateEndpointConnections":[],"publicNetworkAccess":"Enabled"},"location":"westeurope","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002","name":"clitestserver000002","type":"Microsoft.Sql/servers"}' + headers: + cache-control: + - no-cache + content-length: + - '645' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:06 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"properties": {"administratorType": "ActiveDirectory", "login": "DSEngAll", + "sid": "5e90ef3b-9b42-4777-819b-25c36961ea4d", "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server ad-admin create + Connection: + - keep-alive + Content-Length: + - '176' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -s -g -i -u + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators/ActiveDirectory?api-version=2019-06-01-preview + response: + body: + string: '{"operation":"CreateActiveDirectoryAdministrator","startTime":"2020-03-12T21:38:09.417Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAdministratorAzureAsyncOperation/d61fe634-184f-47f8-8215-b39013cd13c5?api-version=2019-06-01-preview + cache-control: + - no-cache + content-length: + - '89' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:09 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAdministratorOperationResults/d61fe634-184f-47f8-8215-b39013cd13c5?api-version=2019-06-01-preview + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server ad-admin create + Connection: + - keep-alive + ParameterSetName: + - -s -g -i -u + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAdministratorAzureAsyncOperation/d61fe634-184f-47f8-8215-b39013cd13c5?api-version=2019-06-01-preview + response: + body: + string: '{"name":"d61fe634-184f-47f8-8215-b39013cd13c5","status":"Succeeded","startTime":"2020-03-12T21:38:09.417Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:24 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server ad-admin create + Connection: + - keep-alive + ParameterSetName: + - -s -g -i -u + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators/ActiveDirectory?api-version=2019-06-01-preview + response: + body: + string: '{"properties":{"administratorType":"ActiveDirectory","login":"DSEngAll","sid":"5e90ef3b-9b42-4777-819b-25c36961ea4d","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators/ActiveDirectory","name":"ActiveDirectory","type":"Microsoft.Sql/servers"}' + headers: + cache-control: + - no-cache + content-length: + - '500' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:24 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server ad-admin list + Connection: + - keep-alive + ParameterSetName: + - -s -g + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators?api-version=2019-06-01-preview + response: + body: + string: '{"value":[{"properties":{"administratorType":"ActiveDirectory","login":"DSEngAll","sid":"5e90ef3b-9b42-4777-819b-25c36961ea4d","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators/ActiveDirectory","name":"ActiveDirectory","type":"Microsoft.Sql/servers"}]}' + headers: + cache-control: + - no-cache + content-length: + - '512' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:26 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server ad-admin update + Connection: + - keep-alive + ParameterSetName: + - -s -g -u -i + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators/ActiveDirectory?api-version=2019-06-01-preview + response: + body: + string: '{"properties":{"administratorType":"ActiveDirectory","login":"DSEngAll","sid":"5e90ef3b-9b42-4777-819b-25c36961ea4d","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators/ActiveDirectory","name":"ActiveDirectory","type":"Microsoft.Sql/servers"}' + headers: + cache-control: + - no-cache + content-length: + - '500' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:26 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"properties": {"administratorType": "ActiveDirectory", "login": "TestUser", + "sid": "e4d43337-d52c-4a0c-b581-09055e0359a0", "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server ad-admin update + Connection: + - keep-alive + Content-Length: + - '176' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -s -g -u -i + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators/ActiveDirectory?api-version=2019-06-01-preview + response: + body: + string: '{"operation":"UpdateActiveDirectoryAdministrator","startTime":"2020-03-12T21:38:27.773Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAdministratorAzureAsyncOperation/ccdf3476-04c2-485d-8f1e-f9aca6f3e99c?api-version=2019-06-01-preview + cache-control: + - no-cache + content-length: + - '89' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:27 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAdministratorOperationResults/ccdf3476-04c2-485d-8f1e-f9aca6f3e99c?api-version=2019-06-01-preview + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server ad-admin update + Connection: + - keep-alive + ParameterSetName: + - -s -g -u -i + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAdministratorAzureAsyncOperation/ccdf3476-04c2-485d-8f1e-f9aca6f3e99c?api-version=2019-06-01-preview + response: + body: + string: '{"name":"ccdf3476-04c2-485d-8f1e-f9aca6f3e99c","status":"Succeeded","startTime":"2020-03-12T21:38:27.773Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:42 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server ad-admin update + Connection: + - keep-alive + ParameterSetName: + - -s -g -u -i + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators/ActiveDirectory?api-version=2019-06-01-preview + response: + body: + string: '{"properties":{"administratorType":"ActiveDirectory","login":"TestUser","sid":"e4d43337-d52c-4a0c-b581-09055e0359a0","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators/ActiveDirectory","name":"ActiveDirectory","type":"Microsoft.Sql/servers"}' + headers: + cache-control: + - no-cache + content-length: + - '500' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:42 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server ad-admin delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -s -g + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + accept-language: + - en-US + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators/ActiveDirectory?api-version=2019-06-01-preview + response: + body: + string: '{"operation":"DropActiveDirectoryAdministrator","startTime":"2020-03-12T21:38:44.217Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAdministratorAzureAsyncOperation/c13d537d-d13f-42f8-be17-26ee179684ee?api-version=2019-06-01-preview + cache-control: + - no-cache + content-length: + - '87' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:43 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAdministratorOperationResults/c13d537d-d13f-42f8-be17-26ee179684ee?api-version=2019-06-01-preview + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server ad-admin delete + Connection: + - keep-alive + ParameterSetName: + - -s -g + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/locations/westeurope/serverAdministratorAzureAsyncOperation/c13d537d-d13f-42f8-be17-26ee179684ee?api-version=2019-06-01-preview + response: + body: + string: '{"name":"c13d537d-d13f-42f8-be17-26ee179684ee","status":"Succeeded","startTime":"2020-03-12T21:38:44.217Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:38:59 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - sql server ad-admin list + Connection: + - keep-alive + ParameterSetName: + - -s -g + User-Agent: + - python/3.8.1 (Windows-10-10.0.18362-SP0) msrest/0.6.11 msrest_azure/0.6.2 + azure-mgmt-sql/0.17.0 Azure-SDK-For-Python AZURECLI/2.2.0 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/administrators?api-version=2019-06-01-preview + response: + body: + string: '{"value":[]}' + headers: + cache-control: + - no-cache + content-length: + - '12' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 12 Mar 2020 21:39:00 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py b/src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py index a2bf5060433..e37df7ea035 100644 --- a/src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py +++ b/src/azure-cli/azure/cli/command_modules/sql/tests/latest/test_sql_commands.py @@ -727,37 +727,43 @@ def test_sql_server_connection_policy(self, resource_group, resource_group_locat checks=[JMESPathCheck('connectionType', type)]) -class AzureActiveDirectoryAdministratorScenarioTest(LiveScenarioTest): - # convert to ScenarioTest and re-record when ISSUE #6011 is fixed - @ResourceGroupPreparer() - @SqlServerPreparer() +class AzureActiveDirectoryAdministratorScenarioTest(ScenarioTest): + @ResourceGroupPreparer(location='westeurope') + @SqlServerPreparer(location='westeurope') def test_aad_admin(self, resource_group, server): - sn = server - oid = '5e90ef3b-9b42-4777-819b-25c36961ea4d' - oid2 = 'e4d43337-d52c-4a0c-b581-09055e0359a0' - user = 'DSEngAll' - user2 = 'TestUser' - - self.cmd('sql server ad-admin create -s {} -g {} -i {} -u {}' - .format(sn, resource_group, oid, user), - checks=[JMESPathCheck('login', user), - JMESPathCheck('sid', oid)]) - - self.cmd('sql server ad-admin list -s {} -g {}' - .format(sn, resource_group), - checks=[JMESPathCheck('[0].login', user)]) - - self.cmd('sql server ad-admin update -s {} -g {} -u {} -i {}' - .format(sn, resource_group, user2, oid2), - checks=[JMESPathCheck('login', user2), - JMESPathCheck('sid', oid2)]) - - self.cmd('sql server ad-admin delete -s {} -g {}' - .format(sn, resource_group)) - - self.cmd('sql server ad-admin list -s {} -g {}' - .format(sn, resource_group), - checks=[JMESPathCheck('login', None)]) + + self.kwargs.update({ + 'rg': resource_group, + 'sn': server, + 'oid': '5e90ef3b-9b42-4777-819b-25c36961ea4d', + 'oid2': 'e4d43337-d52c-4a0c-b581-09055e0359a0', + 'user': 'DSEngAll', + 'user2': 'TestUser' + }) + + print('Arguments are updated with login and sid data') + + self.cmd('sql server ad-admin create -s {sn} -g {rg} -i {oid} -u {user}', + checks=[ + self.check('login', '{user}'), + self.check('sid', '{oid}')]) + + self.cmd('sql server ad-admin list -s {sn} -g {rg}', + checks=[ + self.check('[0].login', '{user}'), + self.check('[0].sid', '{oid}')]) + + self.cmd('sql server ad-admin update -s {sn} -g {rg} -u {user2} -i {oid2}', + checks=[ + self.check('login', '{user2}'), + self.check('sid', '{oid2}')]) + + self.cmd('sql server ad-admin delete -s {sn} -g {rg}') + + self.cmd('sql server ad-admin list -s {sn} -g {rg}', + checks=[ + self.check('[0].login', None), + self.check('[0].sid', None)]) class SqlServerDbCopyScenarioTest(ScenarioTest):