Skip to content

Commit 8777135

Browse files
xiangyan99mccoyp
authored andcommitted
clean up tests/docs (Azure#22480)
* clean up tests/docs * update * Update sdk/identity/azure-identity/tests/managed-identity-live/azure_arc.md Co-authored-by: McCoy Patiño <[email protected]> * Update sdk/identity/azure-identity/tests/managed-identity-live/service-fabric/service_fabric.md Co-authored-by: McCoy Patiño <[email protected]> Co-authored-by: McCoy Patiño <[email protected]>
1 parent e7439c5 commit 8777135

File tree

13 files changed

+29
-65
lines changed

13 files changed

+29
-65
lines changed

sdk/identity/azure-identity/Troubleshoot.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ then you can retrieve the client/app id by following the instructions [here](htt
100100

101101
#### Client Secret Argument
102102

103-
The client secret is the secret string that the application uses to prove its identity when requesting a token; this can also can be referred to as an application password.
103+
The client secret is the secret string that the application uses to prove its identity when requesting a token; this can also be referred to as an application password.
104104
If you have already created a service principal you can follow the instructions [here](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal#option-2-create-a-new-application-secret) to create a client secret for your application.
105105

106106
### Client Certificate Credential Issues
@@ -138,7 +138,7 @@ Azure Service | Managed Identity Configuration
138138

139139
#### Failed To Read VS Code Credentials / Authenticate via Azure Tools plugin in VS Code
140140

141-
THe `VS Code Credential` failed to read the credential details from the cache.
141+
The `VS Code Credential` failed to read the credential details from the cache.
142142

143143
The Visual Studio Code authentication is handled by an integration with the Azure Account extension.
144144
To use this form of authentication, ensure that you have installed the Azure Account extension,

sdk/identity/azure-identity/conftest.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
import six
1010
from azure.identity._constants import DEVELOPER_SIGN_ON_CLIENT_ID, EnvironmentVariables
1111

12-
if sys.version_info < (3, 5, 3):
13-
collect_ignore_glob = ["*_async.py"]
14-
15-
1612
RECORD_IMDS = "--record-imds"
1713

1814

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
../../core/azure-core
2-
aiohttp>=3.0; python_version >= '3.5'
3-
mock;python_version<"3.3"
2+
aiohttp>=3.0
43
typing_extensions>=3.7.2
54
-e ../../../tools/azure-sdk-tools
65
-e ../../../tools/azure-devtools

sdk/identity/azure-identity/tests/managed-identity-live/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright (c) Microsoft Corporation.
33
# Licensed under the MIT License.
44
# ------------------------------------
5-
ARG PYTHON_VERSION=2.7
5+
ARG PYTHON_VERSION=3.9
66

77
# docker can't tell when the repo has changed and will therefore cache this layer
88
FROM alpine/git as repo

sdk/identity/azure-identity/tests/managed-identity-live/appservice.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Use the Azure Portal to attached the managed identity created above to the Web A
130130
The test are deployed as a container. The following command lines assume this working directory:
131131
> `azure-sdk-for-python/sdk/identity/azure-identity/tests`
132132
133-
Two images are needed because the test must run on Python 2 and 3.
133+
We only need to test on Python 3.x
134134

135135
### Authenticate to ACR
136136

@@ -142,7 +142,7 @@ az acr login -n $ACR_NAME
142142

143143
```sh
144144
export IMAGE_NAME=$(az acr show -n $ACR_NAME --query loginServer -o tsv)/webapp-managed-id-test \
145-
PYTHON_VERSION=2.7
145+
PYTHON_VERSION=3.x
146146
```
147147

148148
### Build the image
@@ -157,14 +157,8 @@ docker build --no-cache --build-arg PYTHON_TAG=$PYTHON_VERSION -t $IMAGE_NAME:$P
157157
docker push $IMAGE_NAME:$PYTHON_VERSION
158158
```
159159

160-
Then set `PYTHON_VERSION` to the latest 3.x and run the above `docker build`
161-
and `docker push` commands again. (It's safe--and faster--to omit
162-
`--no-cache` from `docker build` the second time.)
163-
164160
## Run tests
165161

166-
Run these commands twice, once with `PYTHON_VERSION=2.7` and again with the latest 3.x.
167-
168162
### Deploy test code
169163

170164
Configure the Web Apps to use the image. For example, for the app using system-assigned identity:

sdk/identity/azure-identity/tests/managed-identity-live/azure_arc.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
1. A non-Azure Windows or Linux VM.
66
2. Administrator privileges on the VM.
77
3. An Azure Key Vault.
8-
4. Python 2.7 and 3.5+
8+
4. Python 3.6+
99

1010
### Install Azure Arc on the VM
1111

@@ -14,7 +14,7 @@
1414
1. Create an Azure Arc server resource on the [Azure Portal](https://portal.azure.com) (at the time of writing, the
1515
resource is named "Servers - Azure Arc").
1616
2. Choose to add an existing server using an interactive script.
17-
3. When creating the resource, fill in your desired subscription, resource group, and region for the VM. Choose the
17+
3. When creating the resource, fill in your desired subscription, resource group, and region for the VM. Choose the
1818
operating system of your existing VM.
1919
4. No other configuration is necessary. You can go to the "Download and run script" tab and download the script shown.
2020
5. Once the script has been downloaded, run the script on your machine with administrator privileges.
@@ -31,11 +31,11 @@ sudo setfacl -m "g::r-x" /var/opt/azcmagent/tokens/
3131

3232
## Give the Azure Arc VM access to the key vault
3333

34-
For the tests to pass, the VM will need secret management permissions in your key vault.
34+
For the tests to pass, the VM will need secret management permissions in your key vault.
3535

3636
1. Go to your key vault resource in the [Azure Portal](https://portal.azure.com).
37-
2. Go to the vault's "Access policies" page, and click "Add Access Policy".
38-
3. Using the secret management template, select your Arc VM resource as the principal.
37+
2. Go to the vault's "Access policies" page, and click "Add Access Policy".
38+
3. Using the secret management template, select your Arc VM resource as the principal.
3939
4. Click "Add".
4040
5. Don't forget to click "Save" at the top of the access policies page after the policy is added.
4141

@@ -54,7 +54,7 @@ Install `requirements.txt`:
5454
```
5555
pip install -r requirements.txt
5656
```
57-
Run the managed identity tests, using the below command once with Python 2.7 and once with Python 3.5+:
57+
Run the managed identity tests, using the below command with Python 3.6+:
5858
```
5959
pytest -k managed_identity_live
6060
```

sdk/identity/azure-identity/tests/managed-identity-live/cloudshell.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,11 @@ git clone https://github.com/azure/azure-sdk-for-python --single-branch --branch
4343
cd azure-sdk-for-python/sdk/identity/azure-identity
4444
```
4545

46-
4746
## Create virtual environments
48-
The Azure SDK supports Python 2.7 and 3.5.3+. Python 2 and 3 should be installed
49-
in your Cloud Shell. However, the Python 3 version may be less than 3.5.3. Check
50-
this with `python3 -V`. If the version is less than 3.5.3, run tests with Python
51-
2 only.
52-
53-
### Python 2.7
54-
```sh
55-
virtualenv -p python2 ~/venv2
56-
```
47+
The Azure SDK supports Python 3.6+. Python 3 should be installed in your Cloud Shell.
5748

5849
### Python 3
59-
If your shell has at least Python 3.5.3 available, create a virtual environment
50+
If your shell has at least Python 3.6 available, create a virtual environment
6051
for it:
6152
```sh
6253
virtualenv -p python3 ~/venv3

sdk/identity/azure-identity/tests/managed-identity-live/conftest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
from azure.identity._constants import EnvironmentVariables
99
import pytest
1010

11-
if sys.version_info < (3, 5, 3):
12-
collect_ignore_glob = ["*_async.py"]
13-
1411
AZURE_IDENTITY_TEST_VAULT_URL = "AZURE_IDENTITY_TEST_VAULT_URL"
1512
AZURE_IDENTITY_TEST_MANAGED_IDENTITY_CLIENT_ID = "AZURE_IDENTITY_TEST_MANAGED_IDENTITY_CLIENT_ID"
1613

sdk/identity/azure-identity/tests/managed-identity-live/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
../..
33
../../../../keyvault/azure-keyvault-secrets
44
pytest
5-
pytest-asyncio;python_version>="3.5"
6-
aiohttp>=3.0; python_version >= '3.5'
5+
pytest-asyncio
6+
aiohttp>=3.0

sdk/identity/azure-identity/tests/managed-identity-live/service-fabric/service_fabric.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ From your command prompt window, run:
6868
az acr create -g $RESOURCE_GROUP -n $ACR_NAME --admin-enabled --sku basic
6969
```
7070

71+
_Warning: ACR accounts with uppercase letters in their name may have authentication issues._
72+
7173
### Deploy a managed identity-enabled cluster
7274

7375
At the time of writing, Service Fabric clusters must be deployed using the Azure Resource Manager in order to enable managed identity. Provided is a cluster ARM template that can be used to create a managed identity-enabled cluster once some required fields are completed. The template uses the cluster certificate provided by your key vault, creates a system-assigned identity, and enables the managed identity token service so deployed applications can access their identities.
@@ -159,7 +161,7 @@ az deployment group create --resource-group $RESOURCE_GROUP --template-file arm-
159161

160162
### Give the applications access to your key vault
161163

162-
If the applications were accessed now, they would report an error. This is because their managed identities don't have permission to access secrets in the key vault you created.
164+
If the applications were accessed now, they would report an error. This is because their managed identities don't have permission to access secrets in the key vault you created.
163165

164166
To grant them access:
165167

@@ -190,16 +192,16 @@ Verify in a browser:
190192
2. In the Explorer, you should see the applications running under the Applications tab. Otherwise, you may need to double check your deployment process.
191193
3. Under the Nodes tab, expand each node tab to see if it hosts an application ("fabric:/sfmitestsystem" or "fabric:/sfmitestuser").
192194
4. When you find an application entry, click the "+" sign by the name to expand it. There should be a "code" entry -- click on that to bring up a page that has a "Container Logs" tab.
193-
5. Go to the "Container Logs" tab to see the test output. The tests will re-run every so often, so you may have to watch the page for a short while to see the output. Verify that `test_managed_identity_live` shows `PASSED`.
195+
5. Go to the "Container Logs" tab to see the test output. The tests will re-run every so often, so you may have to watch the page for a short while to see the output. Verify that `test_managed_identity_live` and `test_managed_identity_live_async` show `PASSED`.
194196

195-
This shows that the `ManagedIdentityCredential` works for Python 2.7. To test on Python 3.5, you'll need to re-build the Docker images and re-deploy the applications so they can target the new images.
197+
This shows that the `ManagedIdentityCredential` works for Python 2.7. To test on Python 3.9, you'll need to re-build the Docker images and re-deploy the applications so they can target the new images.
196198

197199
1. Remove each application from the cluster. In the Service Fabric Explorer, expand the Applications tab and sfmitestsystemType tab. Click on "fabric:/sfmitestsystem", and in the application page, use the "Actions" tab at the top right to delete the application.
198200
2. Now, remove the other application. Click on "fabric:/sfmitestuser" and use the "Actions" tab to delete the application.
199-
3. Re-build the docker images, targeting Python 3.5 with `--build-arg`. In your command prompt, run:
201+
3. Re-build the docker images, targeting Python 3.9 with `--build-arg`. In your command prompt, run:
200202
```
201-
docker build --no-cache --build-arg PYTHON_VERSION=3.5 -t $ACR_NAME.azurecr.io/sfmitestsystem ..
202-
docker build --no-cache --build-arg PYTHON_VERSION=3.5 -t $ACR_NAME.azurecr.io/sfmitestuser ..
203+
docker build --no-cache --build-arg PYTHON_VERSION=3.9 -t $ACR_NAME.azurecr.io/sfmitestsystem ..
204+
docker build --no-cache --build-arg PYTHON_VERSION=3.9 -t $ACR_NAME.azurecr.io/sfmitestuser ..
203205
```
204206
4. Publish the new images to your ACR:
205207
```

sdk/identity/azure-identity/tests/managed-identity-live/vm.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,6 @@ echo -e `az vm run-command invoke \
117117
Do this for each VM, that is to say, once passing `--ids $VM_ID_SYSTEM_ASSIGNED` and again
118118
passing `--ids $VM_ID_USER_ASSIGNED`:
119119

120-
## Python 2
121-
```sh
122-
echo -e `az vm run-command invoke \
123-
--ids $VM_ID_SYSTEM_ASSIGNED \
124-
--command-id RunShellScript \
125-
--scripts "cd /sdk/sdk/identity/azure-identity/tests/managed-identity-live && \
126-
export AZURE_IDENTITY_TEST_VAULT_URL=https://$KEY_VAULT_NAME.vault.azure.net && \
127-
python2 -m pytest -v --log-level=DEBUG"`
128-
```
129-
130120
## Python 3
131121
```sh
132122
echo -e `az vm run-command invoke \

sdk/identity/azure-identity/tests/pod-identity/readme.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ az role assignment create --role "Managed Identity Operator" \
9393

9494
# build images
9595
The test application must be packaged as a Docker image before deployment.
96-
Test runs must include Python 2 and 3, so two images are required.
96+
Test runs must include Python 3.6+.
9797

9898
### authenticate to ACR
9999
```sh
@@ -113,7 +113,7 @@ cd azure-sdk-for-python/sdk/identity/azure-identity/tests
113113
### build images and push them to the container registry
114114
Set environment variables:
115115
```sh
116-
export REPOSITORY=$ACR_NAME.azurecr.io IMAGE_NAME=test-pod-identity PYTHON_VERSION=2.7
116+
export REPOSITORY=$ACR_NAME.azurecr.io IMAGE_NAME=test-pod-identity PYTHON_VERSION=3.9
117117
```
118118

119119
Build an image:
@@ -126,11 +126,6 @@ Push it to ACR:
126126
docker push $REPOSITORY/$IMAGE_NAME:$PYTHON_VERSION
127127
```
128128

129-
Then set `PYTHON_VERSION` to the latest 3.x (3.8 at time of writing) and run the
130-
above `docker build` and `docker push` commands again. (It's safe--and faster--
131-
to omit `--no-cache` from `docker build` the second time.)
132-
133-
134129
# run the test
135130

136131
### install kubectl
@@ -149,7 +144,7 @@ helm init --wait
149144
```
150145

151146
### run the test script
152-
Twice. Once with `PYTHON_VERSION=2.7`, once with `PYTHON_VERSION=3.x`
147+
With `PYTHON_VERSION=3.x`
153148
(replacing x with the latest Python 3 minor version):
154149
```sh
155150
python ./pod-identity/run-test.py \

sdk/identity/azure-identity/tests/vscode-live/vscode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Test matrix
44

5-
- Python 2.7, 3.5.3, 3.8
5+
- Python 3.7, 3.9
66
- Windows, Ubuntu 18.04, Redhat Enterprise Linux 8.1, Debian 10, Mac OS
77

88
## Test steps
@@ -22,4 +22,4 @@ pip install azure-identity -i https://pkgs.dev.azure.com/azure-sdk/public/_packa
2222

2323
- Run run-test.py
2424

25-
Expect: an access token is printed out.
25+
Expect: an access token is printed out.

0 commit comments

Comments
 (0)