Skip to content

Commit 3eba3f8

Browse files
authored
Merge pull request #627 from Azure/dev
huangpf PR: dev <- Azure:dev
2 parents 28c2115 + c25e837 commit 3eba3f8

File tree

1 file changed

+152
-0
lines changed

1 file changed

+152
-0
lines changed
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Using Microsoft.Rest.ClientRuntime.Azure.TestFramework #
2+
3+
1. Getting Started (Another PR that reflects these changes)
4+
2. Accquring TestFramework
5+
3. Setup prior to Record/Playback tests
6+
1. Environment Variables
7+
2. Connection string
8+
3. Defaults
9+
4. Record/Playback tests
10+
1. Playback Tests
11+
2. Record tests using interactive login (using orgId)
12+
3. Record tests using Service Principal
13+
5. Change Test Environment settings at run-time
14+
15+
16+
## 1. Getting Started (Another PR that reflects these changes)
17+
1. Launch .\tools\PS-VSPrompt shortcut
18+
1. This starts VS Dev command prompt in PowerShell
19+
2. Import module that helps in performing basic repository tasks
20+
1. Import-Module Repo-Tasks.psm1
21+
2. Type Get-Commands -Module Repo-Tasks to see list of cmdlets
22+
3. Get-Help <CommandName> to get help on individual commands.
23+
24+
## 2. Accquring TestFramework
25+
Current Version: [1.4.0-preview](https://www.nuget.org/packages/Microsoft.Rest.ClientRuntime.Azure.TestFramework/1.4.0-preview)
26+
27+
Nuget command to install current version
28+
29+
Install-Package Microsoft.Rest.ClientRuntime.Azure.TestFramework -v 1.4.0-preview -Pre
30+
31+
## 3. Setup prior to Record/Playback of tests
32+
In order to Record/Playback a test, you need to setup a connection string that consists various key/value pairs that provides information to the test environment.
33+
34+
#### 3.1 Environment Variables
35+
> TEST_CSM_ORGID_AUTHENTICATION
36+
37+
> AZURE_TEST_MODE
38+
39+
e.g.
40+
TEST_CSM_ORGID_AUTHENTICATION=SubscriptionId=<valid SubscriptionId>;ServicePrincipal=<ClientId>;ServicePrincipalSecret=<Client Secret>;AADTenant=<tenantId>;Environment=Prod;BaseUri=https://management.azure.com/;AADAuthEndpoint=https://login.windows.net/;GraphUri=https://graph.windows.net/
41+
42+
AZURE_TEST_MODE=Record
43+
44+
#### 3.2. Supported Keys in connection string
45+
* ManagementCertificate
46+
* SubscriptionId
47+
* AADTenant
48+
* UserId
49+
* Password
50+
* ServicePrincipal
51+
* ServicePrincipalSecret
52+
* Environment={Prod | DogFood | Next | Current}
53+
* RawToken
54+
* RawGraphToken
55+
* HttpRecorderMode={Record | Playback}
56+
* AADTokenAudienceUri
57+
* BaseUri
58+
* GraphUri
59+
* GalleryUri
60+
* IbizaProtalUri
61+
* DataLakeStoreServiceUri
62+
* DataLakeAnalyticsJobAndCatalogServiceUri
63+
* AADAuthEndpoint
64+
* GraphTokenAudienceUri
65+
66+
#### 3.3. Existing Defaults
67+
Environment.Prod
68+
AADAuthUri = "https://login.microsoftonline.com"
69+
GalleryUri = "https://gallery.azure.com/"
70+
GraphUri = "https://graph.windows.net/"
71+
IbizaPortalUri = "https://portal.azure.com/"
72+
RdfePortalUri = "http://go.microsoft.com/fwlink/?LinkId=254433"
73+
ResourceManagementUri = "https://management.azure.com/"
74+
ServiceManagementUri = "https://management.core.windows.net"
75+
AADTokenAudienceUri = "https://management.core.windows.net"
76+
GraphTokenAudienceUri = "https://graph.windows.net/"
77+
DataLakeStoreServiceUri = "https://azuredatalakestore.net"
78+
DataLakeAnalyticsJobAndCatalogServiceUri = "https://azuredatalakeanalytics.net"
79+
80+
----------
81+
82+
Environment.Dogfood
83+
AADAuthUri = "https://login.windows-ppe.net";
84+
GalleryUri = "https://df.gallery.azure-test.net/";
85+
GraphUri = "https://graph.ppe.windows.net/";
86+
IbizaPortalUri = "http://df.onecloud.azure-test.net";
87+
RdfePortalUri = "https://windows.azure-test.net";
88+
ResourceManagementUri = "https://api-dogfood.resources.windows-int.net/";
89+
ServiceManagementUri = "https://management-preview.core.windows-int.net";
90+
AADTokenAudienceUri = "https://management.core.windows.net";
91+
GraphTokenAudienceUri = "https://graph.ppe.windows.net/";
92+
DataLakeStoreServiceUri = "https://caboaccountdogfood.net";
93+
DataLakeAnalyticsJobAndCatalogServiceUri = "https://konaaccountdogfood.net";
94+
95+
----------
96+
97+
Environment.Next
98+
AADAuthUri = "https://login.windows-ppe.net"
99+
GalleryUri = "https://next.gallery.azure-test.net/"
100+
GraphUri = "https://graph.ppe.windows.net/"
101+
IbizaPortalUri = "http://next.onecloud.azure-test.net"
102+
RdfePortalUri = "https://auxnext.windows.azure-test.net"
103+
ResourceManagementUri = "https://api-next.resources.windows-int.net/"
104+
ServiceManagementUri = "https://managementnext.rdfetest.dnsdemo4.com"
105+
AADTokenAudienceUri = "https://management.core.windows.net"
106+
GraphTokenAudienceUri = "https://graph.ppe.windows.net/"
107+
DataLakeStoreServiceUri = "https://caboaccountdogfood.net"
108+
DataLakeAnalyticsJobAndCatalogServiceUri = "https://konaaccountdogfood.net"
109+
110+
----------
111+
112+
Environment.Current
113+
AADAuthUri = "https://login.windows-ppe.net"
114+
GalleryUri = "https://df.gallery.azure-test.net/"
115+
GraphUri = "https://graph.ppe.windows.net/"
116+
IbizaPortalUri = "http://df.onecloud.azure-test.net"
117+
RdfePortalUri = "https://windows.azure-test.net"
118+
ResourceManagementUri = "https://api-dogfood.resources.windows-int.net/"
119+
ServiceManagementUri = "https://management-preview.core.windows-int.net"
120+
AADTokenAudienceUri = "https://management.core.windows.net"
121+
GraphTokenAudienceUri = "https://graph.ppe.windows.net/"
122+
DataLakeStoreServiceUri = "https://caboaccountdogfood.net"
123+
DataLakeAnalyticsJoAbndCatalogServiceUri = "https://konaaccountdogfood.net"
124+
125+
## 4. Record/Playback Test
126+
#### Playback Test
127+
1. The default mode is Playback mode, so no setting up of connection string is required.
128+
129+
#### Record Test with Interactive login using OrgId
130+
TEST_CSM_ORGID_AUTHENTICATION=SubsctiptionId={SubId};UserId={orgId};AADTenant={tenantId};Environment={env};HttpRecorderMode=Record;
131+
132+
#### Record Test with ServicePrincipal
133+
TEST_CSM_ORGID_AUTHENTICATION=SubsctiptionId={SubId};ServicePrincipal={clientId};ServicePrincipalSecret={clientSecret};AADTenant={tenantId};Environment={env};HttpRecorderMode=Record;
134+
135+
2. Run the test and make sure that you got a generated .json file that matches the test name in the bin folder under *SessionRecords folder
136+
3. Copy SessionRecords folder inside the test project and add all *.json files in Visual Studio setting "Copy to Output Directory" property to "Copy if newer"
137+
4. To assure that the records work fine, delete the connection string (default mode is Playback mode) OR change HttpRecorderMode within the connection string to "Playback"
138+
139+
## 5. Change Test Environment settings at run-time
140+
#### 1. Once you set your connection string, you can add or update key/value settings
141+
142+
Add new key/value pair
143+
TestEnvironment.ConnectionString.KeyValuePairs.Add("Foo", "FooValue");
144+
145+
Update Existing key/value pair
146+
TestEnvironment.ConnectionString.KeyValuePairs["keyName"]="new value"
147+
148+
Accessing/Updating TestEndpoints
149+
TestEnvironment.Endpoints.GraphUri = new Uri("https://newGraphUri.windows.net");
150+
151+
###Note:###
152+
Changing the above properties at run-time has the potential to hard code few things in your tests. Best practice would be to use these properties to change values at run-time from immediate window at run-time and avoid hard-coding certain values.

0 commit comments

Comments
 (0)