Skip to content

Commit

Permalink
Added Azure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
terricain committed May 16, 2023
1 parent e3f4fac commit 7279fb7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
29 changes: 28 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release
on:
push:
branches:
- master
- "*"
tags:
- "*"

Expand All @@ -24,6 +24,33 @@ jobs:
- name: Test
run: pytest tests/

azure_test:
name: Azure Test
runs-on: ubuntu-latest
environment:
name: dev.azure
permissions:
id-token: write
contents: read
steps:
- name: 'Az CLI Login via OIDC'
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install setuptools and
run: |
python -m pip install --upgrade setuptools wheel
python -m pip install -r requirements-dev.txt
- name: Test
run: pytest azure_tests/

publish:
name: Publish
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
Expand Down
21 changes: 12 additions & 9 deletions tests/integration_test.py → azure_tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest
from azure.mgmt.dns import DnsManagementClient
from azure.identity import ClientSecretCredential
from azure.identity import ClientSecretCredential, AzureCliCredential

if TYPE_CHECKING:
import pathlib
Expand All @@ -14,8 +14,8 @@
EMAIL = os.getenv('EMAIL', 'NOT_AN_EMAIL')

azure_creds = pytest.mark.skipif(
any(env not in os.environ for env in ['AZURE_SP_ID', 'AZURE_SP_SECRET', 'AZURE_TENANT_ID', 'EMAIL']),
reason="Missing 'AZURE_SP_ID', 'AZURE_SP_SECRET', 'AZURE_TENANT_ID' environment variables"
any(env not in os.environ for env in ['AZURE_CLIENT_ID', 'AZURE_TENANT_ID', 'EMAIL']),
reason="Missing 'AZURE_CLIENT_ID'', 'AZURE_TENANT_ID' environment variables"
)

SUBSCRIPTION_ID = '90907259-f568-40c9-be09-768317e458ae'
Expand All @@ -36,12 +36,15 @@ def get_cert_names(count: int = 1) -> List[str]:

@pytest.fixture(scope='session')
def azure_dns_client() -> DnsManagementClient:
creds = ClientSecretCredential(
client_id=os.environ['AZURE_SP_ID'],
client_secret=os.environ['AZURE_SP_SECRET'],
tenant_id=os.environ['AZURE_TENANT_ID'],
authority='https://login.microsoftonline.com/'
)
if 'AZURE_SP_SECRET' in os.environ:
creds = ClientSecretCredential(
client_id=os.environ['AZURE_CLIENT_ID'],
client_secret=os.environ['AZURE_SP_SECRET'],
tenant_id=os.environ['AZURE_TENANT_ID'],
authority='https://login.microsoftonline.com/'
)
else:
creds = AzureCliCredential(tenant_id=os.environ['AZURE_TENANT_ID'])
return DnsManagementClient(creds, SUBSCRIPTION_ID, None, 'https://management.azure.com/', credential_scopes=['https://management.azure.com//.default'])


Expand Down

0 comments on commit 7279fb7

Please sign in to comment.