Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DigitalTwins] Refactor tests to use Test Proxy #26545

Merged
merged 1 commit into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
142 changes: 0 additions & 142 deletions sdk/digitaltwins/azure-digitaltwins-core/tests/_preparer.py

This file was deleted.

46 changes: 41 additions & 5 deletions sdk/digitaltwins/azure-digitaltwins-core/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,45 @@
# Licensed under the MIT License. See LICENSE.txt in the project root for
# license information.
# -------------------------------------------------------------------------
import sys
import pytest

# Ignore collection of async tests for Python 2
collect_ignore_glob = []
if sys.version_info < (3, 5):
collect_ignore_glob.append("*_async.py")
from devtools_testutils.sanitizers import (
add_body_key_sanitizer,
add_header_regex_sanitizer,
add_oauth_response_sanitizer,
add_remove_header_sanitizer
)

# Environment variable keys
ENV_URL = "AZURE_DIGITALTWINS_URL"
ENV_SUBSCRIPTION_ID = "AZURE_SUBSCRIPTION_ID"
ENV_TENANT_ID = "AZURE_TENANT_ID"
ENV_CLIENT_ID = "AZURE_CLIENT_ID"
ENV_CLIENT_SECRET = "AZURE_CLIENT_SECRET"

# Fake values
TEST_URL = "https://fake.api.wcus.digitaltwins.azure.net"
TEST_ID = "00000000-0000-0000-0000-000000000000"


@pytest.fixture(scope="session", autouse=True)
def add_sanitizers(test_proxy, environment_variables):
sanitization_mapping = {
ENV_URL: TEST_URL,
ENV_SUBSCRIPTION_ID: TEST_ID,
ENV_TENANT_ID: TEST_ID,
ENV_CLIENT_ID: TEST_ID,
ENV_CLIENT_SECRET: TEST_ID
}
environment_variables.sanitize_batch(sanitization_mapping)
add_remove_header_sanitizer(headers="Telemetry-Source-Time, Message-Id")
add_body_key_sanitizer(json_path="AccessToken", value="fake.eyJleHAiOjIxNDc0ODM2NDd9.fake")
add_oauth_response_sanitizer()
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")


@pytest.fixture(scope="session")
def digitaltwin(environment_variables):
yield {
"endpoint": environment_variables.get(ENV_URL),
}
Loading