Skip to content

Commit

Permalink
Migrate azure-purview-administrator to testproxy(Do not merge) (Azure…
Browse files Browse the repository at this point in the history
…#25486)

* migrate

* update test recordings

* update
  • Loading branch information
BigCat20196 authored Aug 8, 2022
1 parent 122f89a commit 8feb9d1
Show file tree
Hide file tree
Showing 23 changed files with 2,274 additions and 350 deletions.
32 changes: 32 additions & 0 deletions sdk/purview/azure-purview-administration/tests/_aio_testcase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import asyncio
from unittest.mock import Mock

from azure.core.credentials import AccessToken
from devtools_testutils import AzureRecordedTestCase


class AzureRecordedAsyncTestCase(AzureRecordedTestCase):

@property
def event_loop(self):
return asyncio.get_event_loop()

def create_aio_client(self, client, **kwargs):
if self.is_live:
from azure.identity.aio import DefaultAzureCredential
credential = DefaultAzureCredential()
else:
credential = Mock(get_token=asyncio.coroutine(lambda _: AccessToken("fake-token", 0)))
return client(
credential=credential,
subscription_id=self.get_settings_value("SUBSCRIPTION_ID")
)

def to_list(self, ait):
async def lst():
result = []
async for item in ait:
result.append(item)
return result

return self.event_loop.run_until_complete(lst())
25 changes: 0 additions & 25 deletions sdk/purview/azure-purview-administration/tests/_util.py

This file was deleted.

57 changes: 57 additions & 0 deletions sdk/purview/azure-purview-administration/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# --------------------------------------------------------------------------
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the ""Software""), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------
import os
import platform
import pytest
import sys

from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer, add_body_key_sanitizer, add_header_regex_sanitizer

# Ignore async tests for Python < 3.5
collect_ignore_glob = []
if sys.version_info < (3, 5) or platform.python_implementation() == "PyPy":
collect_ignore_glob.append("*_async.py")

load_dotenv()

@pytest.fixture(scope="session", autouse=True)
def add_sanitizers(test_proxy):
subscription_id = os.environ.get("PURVIEWACCOUNT_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000")
tenant_id = os.environ.get("PURVIEWACCOUNT_TENANT_ID", "00000000-0000-0000-0000-000000000000")
client_id = os.environ.get("PURVIEWACCOUNT_CLIENT_ID", "00000000-0000-0000-0000-000000000000")
client_secret = os.environ.get("PURVIEWACCOUNT_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=subscription_id, value="00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=tenant_id, value="00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=client_id, value="00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=client_secret, value="00000000-0000-0000-0000-000000000000")
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
add_header_regex_sanitizer(key="Cookie", value="cookie;")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
add_body_key_sanitizer(json_path="$..atlasKafkaPrimaryEndpoint", value="000")
add_body_key_sanitizer(json_path="$..atlasKafkaSecondaryEndpoint", value="000")
add_body_key_sanitizer(json_path="$..systemData.createdBy", value="000")
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
{
"Entries": [
{
"RequestUri": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/v2.0/.well-known/openid-configuration",
"RequestMethod": "GET",
"RequestHeaders": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"User-Agent": "azsdk-python-identity/1.11.0b3 Python/3.8.8 (Windows-10-10.0.19041-SP0)"
},
"RequestBody": null,
"StatusCode": 200,
"ResponseHeaders": {
"Access-Control-Allow-Methods": "GET, OPTIONS",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "max-age=86400, private",
"Content-Length": "1753",
"Content-Type": "application/json; charset=utf-8",
"Date": "Thu, 04 Aug 2022 03:09:53 GMT",
"P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022",
"Set-Cookie": "[set-cookie;]",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"x-ms-ests-server": "2.1.13418.9 - WUS2 ProdSlices",
"X-XSS-Protection": "0"
},
"ResponseBody": {
"token_endpoint": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token",
"token_endpoint_auth_methods_supported": [
"client_secret_post",
"private_key_jwt",
"client_secret_basic"
],
"jwks_uri": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/discovery/v2.0/keys",
"response_modes_supported": [
"query",
"fragment",
"form_post"
],
"subject_types_supported": [
"pairwise"
],
"id_token_signing_alg_values_supported": [
"RS256"
],
"response_types_supported": [
"code",
"id_token",
"code id_token",
"id_token token"
],
"scopes_supported": [
"openid",
"profile",
"email",
"offline_access"
],
"issuer": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/v2.0",
"request_uri_parameter_supported": false,
"userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo",
"authorization_endpoint": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/authorize",
"device_authorization_endpoint": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/devicecode",
"http_logout_supported": true,
"frontchannel_logout_supported": true,
"end_session_endpoint": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/logout",
"claims_supported": [
"sub",
"iss",
"cloud_instance_name",
"cloud_instance_host_name",
"cloud_graph_host_name",
"msgraph_host",
"aud",
"exp",
"iat",
"auth_time",
"acr",
"nonce",
"preferred_username",
"name",
"tid",
"ver",
"at_hash",
"c_hash",
"email"
],
"kerberos_endpoint": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/kerberos",
"tenant_region_scope": "NA",
"cloud_instance_name": "microsoftonline.com",
"cloud_graph_host_name": "graph.windows.net",
"msgraph_host": "graph.microsoft.com",
"rbac_url": "https://pas.windows.net"
}
},
{
"RequestUri": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1\u0026authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize",
"RequestMethod": "GET",
"RequestHeaders": {
"Accept": "application/json",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Cookie": "cookie;",
"User-Agent": "azsdk-python-identity/1.11.0b3 Python/3.8.8 (Windows-10-10.0.19041-SP0)"
},
"RequestBody": null,
"StatusCode": 200,
"ResponseHeaders": {
"Access-Control-Allow-Methods": "GET, OPTIONS",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "max-age=86400, private",
"Content-Length": "945",
"Content-Type": "application/json; charset=utf-8",
"Date": "Thu, 04 Aug 2022 03:09:53 GMT",
"P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022",
"Set-Cookie": "[set-cookie;]",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"x-ms-ests-server": "2.1.13418.9 - KRC ProdSlices",
"X-XSS-Protection": "0"
},
"ResponseBody": {
"tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration",
"api-version": "1.1",
"metadata": [
{
"preferred_network": "login.microsoftonline.com",
"preferred_cache": "login.windows.net",
"aliases": [
"login.microsoftonline.com",
"login.windows.net",
"login.microsoft.com",
"sts.windows.net"
]
},
{
"preferred_network": "login.partner.microsoftonline.cn",
"preferred_cache": "login.partner.microsoftonline.cn",
"aliases": [
"login.partner.microsoftonline.cn",
"login.chinacloudapi.cn"
]
},
{
"preferred_network": "login.microsoftonline.de",
"preferred_cache": "login.microsoftonline.de",
"aliases": [
"login.microsoftonline.de"
]
},
{
"preferred_network": "login.microsoftonline.us",
"preferred_cache": "login.microsoftonline.us",
"aliases": [
"login.microsoftonline.us",
"login.usgovcloudapi.net"
]
},
{
"preferred_network": "login-us.microsoftonline.com",
"preferred_cache": "login-us.microsoftonline.com",
"aliases": [
"login-us.microsoftonline.com"
]
}
]
}
},
{
"RequestUri": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token",
"RequestMethod": "POST",
"RequestHeaders": {
"Accept": "application/json",
"Accept-Encoding": "gzip, deflate",
"client-request-id": "408c37d7-b5f9-4097-a953-298c1f2cca7c",
"Connection": "keep-alive",
"Content-Length": "285",
"Content-Type": "application/x-www-form-urlencoded",
"Cookie": "cookie;",
"User-Agent": "azsdk-python-identity/1.11.0b3 Python/3.8.8 (Windows-10-10.0.19041-SP0)",
"x-client-cpu": "x64",
"x-client-current-telemetry": "4|730,0|",
"x-client-last-telemetry": "4|0|||",
"x-client-os": "win32",
"x-client-sku": "MSAL.Python",
"x-client-ver": "1.16.0",
"x-ms-lib-capability": "retry-after, h429"
},
"RequestBody": "client_id=00000000-0000-0000-0000-000000000000\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=00000000-0000-0000-0000-000000000000\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fpurview.azure.net%2F.default",
"StatusCode": 200,
"ResponseHeaders": {
"Cache-Control": "no-store, no-cache",
"client-request-id": "408c37d7-b5f9-4097-a953-298c1f2cca7c",
"Content-Length": "93",
"Content-Type": "application/json; charset=utf-8",
"Date": "Thu, 04 Aug 2022 03:09:54 GMT",
"Expires": "-1",
"P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022",
"Pragma": "no-cache",
"Set-Cookie": "[set-cookie;]",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"x-ms-clitelem": "1,0,0,,",
"x-ms-ests-server": "2.1.13418.9 - SCUS ProdSlices",
"X-XSS-Protection": "0"
},
"ResponseBody": {
"token_type": "Bearer",
"expires_in": 3599,
"ext_expires_in": 3599,
"access_token": "access_token"
}
},
{
"RequestUri": "https://fake_account.account.purview.azure.com/listkeys?api-version=2019-11-01-preview",
"RequestMethod": "POST",
"RequestHeaders": {
"Accept": "application/json",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Content-Length": "0",
"User-Agent": "azsdk-python-purview-administration/1.0.0b1 Python/3.8.8 (Windows-10-10.0.19041-SP0)"
},
"RequestBody": null,
"StatusCode": 200,
"ResponseHeaders": {
"api-supported-versions": "2019-11-01-preview",
"Content-Length": "71",
"Content-Type": "application/json; charset=utf-8",
"Date": "Thu, 04 Aug 2022 03:09:55 GMT",
"Server": "Kestrel",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"x-ms-correlation-request-id": "27d38066-70c8-4207-9aad-288a17f2ebd5"
},
"ResponseBody": {
"atlasKafkaPrimaryEndpoint": "000",
"atlasKafkaSecondaryEndpoint": "000"
}
}
],
"Variables": {}
}
Loading

0 comments on commit 8feb9d1

Please sign in to comment.