Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update-testcase
  • Loading branch information
ChenxiJiang333 committed Sep 25, 2024
commit e5f9589ebd2bdddb59137d0c0856f44a37f85713
6 changes: 0 additions & 6 deletions sdk/network/azure-mgmt-dns/assets.json

This file was deleted.

3 changes: 2 additions & 1 deletion sdk/network/azure-mgmt-dns/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-e ../../../tools/azure-sdk-tools
-e ../azure-mgmt-network
../../identity/azure-identity
azure-mgmt-resource<=21.1.0
azure-mgmt-resource<=21.1.0
aiohttp
66 changes: 21 additions & 45 deletions sdk/network/azure-mgmt-dns/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,35 @@
# coding=utf-8
# --------------------------------------------------------------------------
#
# 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.
#
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import os
import platform
import pytest
import sys

from dotenv import load_dotenv

from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers
from devtools_testutils import add_header_regex_sanitizer, add_body_key_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")
from devtools_testutils import (
test_proxy,
add_general_regex_sanitizer,
add_body_key_sanitizer,
add_header_regex_sanitizer,
)

load_dotenv()


# aovid record sensitive identity information in recordings
@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")
client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000")
client_secret = os.environ.get("AZURE_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")
dnsmanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000")
dnsmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000")
dnsmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000")
dnsmanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=dnsmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=dnsmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=dnsmanagement_client_id, value="00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=dnsmanagement_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")

# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
# - AZSDK3493: $..name
remove_batch_sanitizers(["AZSDK3493"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import pytest
from azure.mgmt.dns.aio import DnsManagementClient

from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer
from devtools_testutils.aio import recorded_by_proxy_async

AZURE_LOCATION = "eastus"


@pytest.mark.live_test_only
class TestDnsManagementZonesOperationsAsync(AzureMgmtRecordedTestCase):
def setup_method(self, method):
self.client = self.create_mgmt_client(DnsManagementClient, is_async=True)

@RandomNameResourceGroupPreparer(location=AZURE_LOCATION)
@recorded_by_proxy_async
async def test_list_by_resource_group(self, resource_group):
response = self.client.zones.list_by_resource_group(
resource_group_name=resource_group.name,
)
result = [r async for r in response]
assert result == []
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import pytest
from azure.mgmt.dns import DnsManagementClient

from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy

AZURE_LOCATION = "eastus"


@pytest.mark.live_test_only
class TestDnsManagementZonesOperations(AzureMgmtRecordedTestCase):
def setup_method(self, method):
self.client = self.create_mgmt_client(DnsManagementClient)

@RandomNameResourceGroupPreparer(location=AZURE_LOCATION)
@recorded_by_proxy
def test_list_by_resource_group(self, resource_group):
response = self.client.zones.list_by_resource_group(
resource_group_name=resource_group.name,
)
result = [r for r in response]
assert result == []

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding: utf-8
# coding: utf-8

#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
Expand All @@ -13,7 +13,9 @@
AzureMgmtRecordedTestCase, ResourceGroupPreparer, recorded_by_proxy,
AzureMgmtPreparer, FakeResource
)
import pytest

@pytest.mark.live_test_only
class VirtualNetworkPreparer(AzureMgmtPreparer):
def __init__(self, name_prefix='pvtzonevnet'):
super(VirtualNetworkPreparer, self).__init__(name_prefix, 24)
Expand Down