File: test_azure_vms.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (50 lines) | stat: -rw-r--r-- 1,656 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
import os

import pytest

from utils import run_command


class TestAzureVirtualMachinesIntegration:
    @pytest.mark.live_test_only
    @pytest.mark.skipif(
        not os.environ.get("IDENTITY_LIVE_RESOURCES_PROVISIONED"), reason="Integration resources not provisioned."
    )
    def test_azure_virtual_machine(self):

        resource_group = os.environ.get("IDENTITY_RESOURCE_GROUP")

        user_assigned_client_id = os.environ.get("IDENTITY_USER_DEFINED_IDENTITY_CLIENT_ID")
        storage_1 = os.environ.get("IDENTITY_STORAGE_NAME_1")
        storage_2 = os.environ.get("IDENTITY_STORAGE_NAME_2")
        vm_name = os.environ.get("IDENTITY_VM_NAME", "python-test-app")

        az_path = run_command(["which", "az"])

        script_string = (
            f"export IDENTITY_USER_DEFINED_IDENTITY_CLIENT_ID={user_assigned_client_id} && "
            f"export IDENTITY_STORAGE_NAME_1={storage_1} && "
            f"export IDENTITY_STORAGE_NAME_2={storage_2} && "
            "python3 /sdk/sdk/identity/azure-identity/tests/integration/azure-vms/app.py"
        )
        output = run_command(
            [
                az_path,
                "vm",
                "run-command",
                "invoke",
                "-n",
                vm_name,
                "-g",
                resource_group,
                "--command-id",
                "RunShellScript",
                "--scripts",
                script_string,
            ]
        )
        assert "Passed!" in output