-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Contributing to the tests
This page is to help you writing tests for Azure Python SDK when these tests implies Azure HTTP requests. Our framework rests upon on a HTTP recording system (vcr.py). We will find here:
- How to authenticate to Azure, in order to be able to record/play HTTP requests
- How to write tests using our Python utilities classes
You have several ways to authenticate to Azure. To be able to use the tests framework, you must use an authentication which gives you a token:
- OAuth authentication using Azure Active Directory user/password
- OAuth authentication using Active Directory application and service principal
Certificate authentication does not allow you to record HTTP queries for testing.
For ARM tests, you can use any of the two authentication system. For ASM legacy tests, you have to authenticate using AAD user/password
-
Connect to the Azure Classic Portal with your admin account
-
Create a user in your default AAD https://azure.microsoft.com/en-us/documentation/articles/active-directory-create-users/
You must NOT activate Multi-Factor Authentication
-
Go to Settings - Administrators
-
Click on Add and enter the email of the new user. Check the checkbox of the subscription you want to test with this user.
-
Login to Azure Portal with this new user to change the temporary password to a new one. You will not be able to use the temporary password for OAuth login.
You are now able to log in Python using OAuth. You can test with this code using adal:
import adal
adal.acquire_token_with_username_password(
'https://login.microsoftonline.com/common/', # Do not change
'user@domain.com', # Your new user
'my_smart_password', # Your password
)
Follow this detailed link: https://azure.microsoft.com/en-us/documentation/articles/resource-group-create-service-principal-portal/
You are now able to log in Python using OAuth. You can test with this code using adal:
import adal
adal.acquire_token_with_client_credentials(
'https://login.microsoftonline.com/ABCDEFGH-1234-ABCD-1234-ABCDEFGHIJKL/', # Your OAuth 2.0 Token Endpoint for this app
'ABCDEFGH-1234-ABCD-1234-ABCDEFGHIJKL', # Your client id
'generatedkey', # Your authentication key
)
In progress...