|
1 | | -using System.Collections.Generic; |
| 1 | +// ---------------------------------------------------------------------------------- |
| 2 | +// |
| 3 | +// Copyright Microsoft Corporation |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// Unless required by applicable law or agreed to in writing, software |
| 9 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +// See the License for the specific language governing permissions and |
| 12 | +// limitations under the License. |
| 13 | +// ---------------------------------------------------------------------------------- |
| 14 | + |
| 15 | +using System; |
| 16 | +using System.Collections.Generic; |
2 | 17 | using System.Linq; |
3 | 18 | using System.Net.Http; |
4 | 19 | using System.Net.Http.Headers; |
|
10 | 25 | using Microsoft.Azure.Test.HttpRecorder; |
11 | 26 | using Microsoft.Rest; |
12 | 27 | using Microsoft.Rest.ClientRuntime.Azure.TestFramework; |
13 | | -using Microsoft.WindowsAzure.Commands.ScenarioTest; |
14 | 28 | using Xunit.Abstractions; |
15 | 29 |
|
16 | 30 | namespace Microsoft.Azure.Commands.Resources.Test.ScenarioTests |
@@ -42,19 +56,25 @@ protected TestManagerBuilder(ITestOutputHelper output) |
42 | 56 | }) |
43 | 57 | .Build(); |
44 | 58 |
|
45 | | - var testEnvironment = TestEnvironmentFactory.GetTestEnvironment(); |
46 | | - |
47 | | - var credentials = new SubscriptionCloudCredentialsAdapter( |
48 | | - testEnvironment.TokenInfo[TokenAudience.Management], |
49 | | - testEnvironment.SubscriptionId); |
| 59 | + var credentials = HttpMockServer.Mode == HttpRecorderMode.Record |
| 60 | + ? new Func<SubscriptionCloudCredentialsAdapter>(() => |
| 61 | + { |
| 62 | + var testEnvironment = TestEnvironmentFactory.GetTestEnvironment(); |
| 63 | + return new SubscriptionCloudCredentialsAdapter( |
| 64 | + testEnvironment.TokenInfo[TokenAudience.Management], |
| 65 | + testEnvironment.SubscriptionId); |
| 66 | + }) () |
| 67 | + : new SubscriptionCloudCredentialsAdapter( |
| 68 | + new TokenCredentials("foo"), |
| 69 | + Guid.Empty.ToString()); |
50 | 70 |
|
51 | 71 | HttpClientHelperFactory.Instance = new TestHttpClientHelperFactory(credentials); |
52 | 72 | } |
53 | 73 | } |
54 | 74 |
|
55 | 75 | #region TestHttpClientHelperFactory |
56 | 76 |
|
57 | | - class TestHttpClientHelperFactory : HttpClientHelperFactory |
| 77 | + internal class TestHttpClientHelperFactory : HttpClientHelperFactory |
58 | 78 | { |
59 | 79 | /// <summary> |
60 | 80 | /// The subscription cloud credentials. |
@@ -107,7 +127,7 @@ public override HttpClient CreateHttpClient(params DelegatingHandler[] primaryHa |
107 | 127 | } |
108 | 128 |
|
109 | 129 | //https://gist.github.com/markcowl/4d907da7ce40f2e424e8d0625887b82e |
110 | | - class SubscriptionCloudCredentialsAdapter : SubscriptionCloudCredentials |
| 130 | + internal class SubscriptionCloudCredentialsAdapter : SubscriptionCloudCredentials |
111 | 131 | { |
112 | 132 | private readonly ServiceClientCredentials _wrappedCreds; |
113 | 133 |
|
|
0 commit comments