@@ -110,7 +110,6 @@ public TestEnvironment(string connectionString)
110110
111111 InitTokenDictionary ( ) ;
112112 SetupHttpRecorderMode ( ) ;
113- RecorderModeSettings ( ) ;
114113 }
115114
116115 private void InitTestEndPoints ( )
@@ -186,31 +185,6 @@ private void SetupHttpRecorderMode()
186185 }
187186 }
188187
189- private void RecorderModeSettings ( )
190- {
191- if ( HttpMockServer . Mode == HttpRecorderMode . Record )
192- {
193- //Restore/Add Subscription Id in MockServer from supplied connection string
194- if ( HttpMockServer . Variables . ContainsCaseInsensitiveKey ( ConnectionStringKeys . SubscriptionIdKey ) )
195- {
196- HttpMockServer . Variables . UpdateDictionary ( ConnectionStringKeys . SubscriptionIdKey , SubscriptionId ) ;
197- }
198- else
199- {
200- HttpMockServer . Variables . Add ( ConnectionStringKeys . SubscriptionIdKey , SubscriptionId ) ;
201- }
202-
203- // If User has provided Access Token in RawToken/GraphToken Key-Value, we don't need to authenticate
204- // We currently only check for RawToken and do not check if GraphToken is provided
205- if ( string . IsNullOrEmpty ( ConnectionString . GetValue ( ConnectionStringKeys . RawTokenKey ) ) )
206- {
207- Login ( ) ;
208- }
209-
210- VerifyAuthTokens ( ) ;
211- }
212- }
213-
214188 private void Login ( )
215189 {
216190 string userPassword = ConnectionString . GetValue ( ConnectionStringKeys . PasswordKey ) ;
@@ -413,9 +387,30 @@ private void VerifyGraphToken()
413387 }
414388 }
415389
416- internal void SetRecordedEnvironmentVariables ( )
390+ internal void SetEnvironmentVariables ( )
417391 {
418- if ( HttpMockServer . Mode == HttpRecorderMode . Playback )
392+ if ( HttpMockServer . Mode == HttpRecorderMode . Record )
393+ {
394+ //Restore/Add Subscription Id in MockServer from supplied connection string
395+ if ( HttpMockServer . Variables . ContainsCaseInsensitiveKey ( ConnectionStringKeys . SubscriptionIdKey ) )
396+ {
397+ HttpMockServer . Variables . UpdateDictionary ( ConnectionStringKeys . SubscriptionIdKey , SubscriptionId ) ;
398+ }
399+ else
400+ {
401+ HttpMockServer . Variables . Add ( ConnectionStringKeys . SubscriptionIdKey , SubscriptionId ) ;
402+ }
403+
404+ // If User has provided Access Token in RawToken/GraphToken Key-Value, we don't need to authenticate
405+ // We currently only check for RawToken and do not check if GraphToken is provided
406+ if ( string . IsNullOrEmpty ( ConnectionString . GetValue ( ConnectionStringKeys . RawTokenKey ) ) )
407+ {
408+ Login ( ) ;
409+ }
410+
411+ VerifyAuthTokens ( ) ;
412+ }
413+ else if ( HttpMockServer . Mode == HttpRecorderMode . Playback )
419414 {
420415 //Get Subscription Id from MockServer. Otherwise, assign zero guid
421416 if ( HttpMockServer . Variables . ContainsCaseInsensitiveKey ( ConnectionStringKeys . SubscriptionIdKey ) )
0 commit comments