Skip to content

Commit

Permalink
migrate tests (Azure#22095)
Browse files Browse the repository at this point in the history
  • Loading branch information
BigCat20196 authored Jan 11, 2022
1 parent 671d3c4 commit 6255c5e
Show file tree
Hide file tree
Showing 8 changed files with 766 additions and 295 deletions.
3 changes: 2 additions & 1 deletion sdk/advisor/azure-mgmt-advisor/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-e ../../../tools/azure-sdk-tools
-e ../../../tools/azure-devtools
-e ../../../tools/azure-devtools
../../identity/azure-identity
47 changes: 47 additions & 0 deletions sdk/advisor/azure-mgmt-advisor/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# --------------------------------------------------------------------------
#
# 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

# 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("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000")
tenant_id = os.environ.get("AZURE_TENANT_ID", "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")

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
{
"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.7.2 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, 09 Dec 2021 05:38:40 GMT",
"P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022",
"Set-Cookie": [
"fpc=AsDCUFcFnsBBiiNJjhB8iQeZHqKEAQAAAFuNQ9kOAAAA; expires=Sat, 08-Jan-2022 05:38:40 GMT; path=/; secure; HttpOnly; SameSite=None",
"x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly",
"stsservicecookie=estsfd; path=/; secure; samesite=none; httponly"
],
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"x-ms-ests-server": "2.1.12249.17 - NCUS ProdSlices",
"x-ms-request-id": "80ac9510-4e7f-497c-bc23-15c402080700"
},
"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": "fpc=AsDCUFcFnsBBiiNJjhB8iQeZHqKEAQAAAFuNQ9kOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd",
"User-Agent": "azsdk-python-identity/1.7.2 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, 09 Dec 2021 05:38:40 GMT",
"P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022",
"Set-Cookie": [
"fpc=AsDCUFcFnsBBiiNJjhB8iQeZHqKEAQAAAFuNQ9kOAAAA; expires=Sat, 08-Jan-2022 05:38:41 GMT; path=/; secure; HttpOnly; SameSite=None",
"x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly",
"stsservicecookie=estsfd; path=/; secure; samesite=none; httponly"
],
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"x-ms-ests-server": "2.1.12261.14 - SEASLR1 ProdSlices",
"x-ms-request-id": "1306231f-1899-4d48-aeca-9001d4030200"
},
"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": "d75450fe-9c36-4698-9961-af3675691d03",
"Connection": "keep-alive",
"Content-Length": "289",
"Content-Type": "application/x-www-form-urlencoded",
"Cookie": "fpc=AsDCUFcFnsBBiiNJjhB8iQeZHqKEAQAAAFuNQ9kOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd",
"User-Agent": "azsdk-python-identity/1.7.2 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=a2df54d5-ab03-4725-9b80-9a00b3b1967f\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=0vj7Q~IsFayrD0V_8oyOfygU-GE3ELOabq95a\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%2Fmanagement.azure.com%2F.default",
"StatusCode": 200,
"ResponseHeaders": {
"Cache-Control": "no-store, no-cache",
"client-request-id": "d75450fe-9c36-4698-9961-af3675691d03",
"Content-Length": "1391",
"Content-Type": "application/json; charset=utf-8",
"Date": "Thu, 09 Dec 2021 05:38:40 GMT",
"Expires": "-1",
"P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022",
"Pragma": "no-cache",
"Set-Cookie": [
"fpc=AsDCUFcFnsBBiiNJjhB8iQeZHqKEAgAAAFuNQ9kOAAAA; expires=Sat, 08-Jan-2022 05:38:41 GMT; path=/; secure; HttpOnly; SameSite=None",
"x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly",
"stsservicecookie=estsfd; path=/; secure; samesite=none; httponly"
],
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"x-ms-clitelem": "1,0,0,,",
"x-ms-ests-server": "2.1.12249.17 - SCUS ProdSlices",
"x-ms-request-id": "4fd8702f-08b9-4a15-8cb4-2ffac0271300"
},
"ResponseBody": {
"token_type": "Bearer",
"expires_in": 3599,
"ext_expires_in": 3599,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Imwzc1EtNTBjQ0g0eEJWWkxIVEd3blNSNzY4MCIsImtpZCI6Imwzc1EtNTBjQ0g0eEJWWkxIVEd3blNSNzY4MCJ9.eyJhdWQiOiJodHRwczovL21hbmFnZW1lbnQuYXp1cmUuY29tIiwiaXNzIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvNTQ4MjZiMjItMzhkNi00ZmIyLWJhZDktYjdiOTNhM2U5YzVhLyIsImlhdCI6MTYzOTAyODAyMSwibmJmIjoxNjM5MDI4MDIxLCJleHAiOjE2MzkwMzE5MjEsImFpbyI6IkUyWmdZTkRiS1gyUjkvSjJablZ0YzNuUFRMVjBBQT09IiwiYXBwaWQiOiJhMmRmNTRkNS1hYjAzLTQ3MjUtOWI4MC05YTAwYjNiMTk2N2YiLCJhcHBpZGFjciI6IjEiLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC81NDgyNmIyMi0zOGQ2LTRmYjItYmFkOS1iN2I5M2EzZTljNWEvIiwiaWR0eXAiOiJhcHAiLCJvaWQiOiI4ODdjNDJiMS03OTQ2LTRjMjItYmFhNi0xNTA0M2U0YjEzMjMiLCJyaCI6IjAuQVRjQUltdUNWTlk0c2stNjJiZTVPajZjV3RWVTM2SURxeVZIbTRDYUFMT3hsbjgzQUFBLiIsInN1YiI6Ijg4N2M0MmIxLTc5NDYtNGMyMi1iYWE2LTE1MDQzZTRiMTMyMyIsInRpZCI6IjU0ODI2YjIyLTM4ZDYtNGZiMi1iYWQ5LWI3YjkzYTNlOWM1YSIsInV0aSI6IkwzRFlUN2tJRlVxTXRDXzZ3Q2NUQUEiLCJ2ZXIiOiIxLjAiLCJ4bXNfY2MiOlsiQ1AxIl0sInhtc190Y2R0IjoxNDEyMjA2ODQwfQ.hzgsMAPXQ9Gv011QF3GeC517C59iwMSP1zB-PK-8jSabnaOUETGoIwQAUgBOMYsL9-MTwmIqjWOp67G08rgh-a-RMNLc2ll2KxmbjLduijAumYbSjBtS7KcAAbJoWrBWOdjbkuJLSv6jLKaqcjVVKAZ6yOlF4_gsLL-__ReDuVh__rxUsScnY5aKbe2OsSkUwj7VcvmP5fihZBmgma6poAF3ZmkRUMBvDN9bgj1oZzdXL-Rxn6C1Qqdek9n4hy6aR3Kly2FJLSoeNRNwe4pCRcFaUVwqyK1QcZG8ZEBXS1TdfZiz2ViKkD0mPpz1ZI0b2VDjevnWr4M47N_32SC3SA"
}
},
{
"RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/generateRecommendations?api-version=2020-01-01",
"RequestMethod": "POST",
"RequestHeaders": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Authorization": "Sanitized",
"Connection": "keep-alive",
"Content-Length": "0",
"User-Agent": "azsdk-python-mgmt-advisor/9.0.0 Python/3.8.8 (Windows-10-10.0.19041-SP0)",
"x-ms-client-request-id": "43e234d5-58b2-11ec-a623-70b5e82527ff"
},
"RequestBody": null,
"StatusCode": 202,
"ResponseHeaders": {
"Cache-Control": "no-cache",
"Content-Length": "0",
"Date": "Thu, 09 Dec 2021 05:38:41 GMT",
"Expires": "-1",
"Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/generateRecommendations/3af20fc7-78e8-408c-9391-8df23c3be462?api-version=2020-01-01",
"Pragma": "no-cache",
"Retry-After": "60",
"Server": "Microsoft-HTTPAPI/2.0",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"x-ms-correlation-request-id": "bdaf13c0-e27b-4e50-a601-515243895045",
"x-ms-ratelimit-remaining-subscription-writes": "1199",
"x-ms-request-id": "bdaf13c0-e27b-4e50-a601-515243895045",
"x-ms-routing-request-id": "JAPANEAST:20211209T053841Z:bdaf13c0-e27b-4e50-a601-515243895045"
},
"ResponseBody": null
},
{
"RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/generateRecommendations/00000000-0000-0000-0000-000000000000?api-version=2020-01-01",
"RequestMethod": "GET",
"RequestHeaders": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Authorization": "Sanitized",
"Connection": "keep-alive",
"User-Agent": "azsdk-python-mgmt-advisor/9.0.0 Python/3.8.8 (Windows-10-10.0.19041-SP0)",
"x-ms-client-request-id": "4491d0e3-58b2-11ec-ba0d-70b5e82527ff"
},
"RequestBody": null,
"StatusCode": 204,
"ResponseHeaders": {
"Cache-Control": "no-cache",
"Date": "Thu, 09 Dec 2021 05:38:41 GMT",
"Expires": "-1",
"Pragma": "no-cache",
"Server": "Microsoft-HTTPAPI/2.0",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"x-ms-correlation-request-id": "eb79da09-662e-4039-9be6-d3ddf3ad5cf5",
"x-ms-ratelimit-remaining-subscription-resource-requests": "359",
"x-ms-request-id": "eb79da09-662e-4039-9be6-d3ddf3ad5cf5",
"x-ms-routing-request-id": "JAPANEAST:20211209T053842Z:eb79da09-662e-4039-9be6-d3ddf3ad5cf5"
},
"ResponseBody": null
}
],
"Variables": {}
}
Loading

0 comments on commit 6255c5e

Please sign in to comment.