protected MarketplaceTestRunner(ITestOutputHelper output)
 {
     TestRunner = TestManager.CreateInstance(output)
                  .WithNewPsScriptFilename($"{GetType().Name}.ps1")
                  .WithProjectSubfolderForTests("ScenarioTests")
                  .WithCommonPsScripts(new[]
     {
         @"Common.ps1"
     })
                  .WithNewRmModules(helper => new[]
     {
         helper.RMProfileModule,
         helper.GetRMModulePath("Az.Marketplace.psd1")
     })
                  .WithNewRecordMatcherArguments(
         userAgentsToIgnore: new Dictionary <string, string>(),
         resourceProviders: new Dictionary <string, string>
     {
         { "Microsoft.Resources", null },
         { "Microsoft.Features", null },
         { "Microsoft.Authorization", null }
     }
         )
                  .Build();
 }
 protected RecoveryServicesTestRunner(ITestOutputHelper output)
 {
     TestRunner = TestManager.CreateInstance(output)
                  .WithNewPsScriptFilename($"{GetType().Name}.ps1")
                  .WithProjectSubfolderForTests("ScenarioTests")
                  .WithCommonPsScripts(new[]
     {
         @"../AzureRM.Resources.ps1"
     })
                  .WithNewRmModules(helper => new[]
     {
         helper.RMProfileModule,
         helper.GetRMModulePath("Az.RecoveryServices.psd1")
     })
                  .WithNewRecordMatcherArguments(
         userAgentsToIgnore: new Dictionary <string, string>
     {
         { "Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01" },
         { "Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient", "2016-02-01" }
     },
         resourceProviders: new Dictionary <string, string>
     {
         { "Microsoft.Resources", null },
         { "Microsoft.Features", null },
         { "Microsoft.Authorization", null },
         { "Microsoft.Compute", null }
     }
         )
                  .Build();
 }
 protected MonitorTestRunner(ITestOutputHelper output)
 {
     TestRunner = TestManager.CreateInstance(output)
                  .WithNewPsScriptFilename($"{GetType().Name}.ps1")
                  .WithProjectSubfolderForTests("ScenarioTests")
                  .WithCommonPsScripts(new[]
     {
         @"Common.ps1",
         @"../AzureRM.Storage.ps1",
         @"../AzureRM.Resources.ps1"
     })
                  .WithNewRmModules(helper => new[]
     {
         helper.RMProfileModule,
         helper.GetRMModulePath("Az.Monitor.psd1"),
         helper.GetRMModulePath("Az.ApplicationInsights.psd1"),
         helper.GetRMModulePath("Az.OperationalInsights.psd1"),
         helper.GetRMModulePath("Az.Network.psd1")
     })
                  .WithNewRecordMatcherArguments(
         userAgentsToIgnore: new Dictionary <string, string>
     {
         { "Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01" }
     },
         resourceProviders: new Dictionary <string, string>
     {
         { "Microsoft.Insights", null },
         { "Microsoft.Network", null },
         { "Microsoft.OperationalInsights", null }
     }
         )
                  .Build();
 }
示例#4
0
        protected ResourceTestRunner(ITestOutputHelper output)
        {
            TestRunner = TestManager.CreateInstance(output)
                         .WithNewPsScriptFilename($"{GetType().Name}.ps1")
                         .WithProjectSubfolderForTests("ScenarioTests")
                         .WithCommonPsScripts(new[]
            {
                @"Common.ps1",
            })
                         .WithExtraRmModules(helper => new[]
            {
                helper.RMResourceModule,
                helper.GetRMModulePath("AzureRM.Monitor.psd1")
            })
                         .WithRecordMatcher(
                (ignoreResourcesClient, resourceProviders, userAgentsToIgnore) =>
                new ResourcesRecordMatcher(ignoreResourcesClient, resourceProviders, userAgentsToIgnore))
                         .WithExtraUserAgentsToIgnore(new Dictionary <string, string>
            {
                { "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient", "2016-07-01" },
            })
                         .WithMockContextAction(() =>
            {
                var credentials = HttpMockServer.Mode != HttpRecorderMode.Playback
                        ? new Func <ServiceClientCredentials>(() =>
                {
                    var testEnvironment = TestEnvironmentFactory.GetTestEnvironment();
                    return(testEnvironment.TokenInfo[TokenAudience.Management]);
                })()
                        : new TokenCredentials("foo");

                HttpClientHelperFactory.Instance = new TestHttpClientHelperFactory(credentials);
            })
                         .Build();
        }
示例#5
0
 protected NetworkTestRunner(ITestOutputHelper output)
 {
     TestRunner = TestManager.CreateInstance(output)
                  .WithNewPsScriptFilename($"{GetType().Name}.ps1")
                  .WithProjectSubfolderForTests("ScenarioTests")
                  .WithCommonPsScripts(new[]
     {
         @"Common.ps1",
         @"../AzureRM.Resources.ps1",
     })
                  .WithNewRmModules(helper => new[]
     {
         helper.RMProfileModule,
         helper.GetRMModulePath("AzureRM.Monitor.psd1"),
         helper.GetRMModulePath("AzureRM.Network.psd1"),
         helper.GetRMModulePath("AzureRM.Compute.psd1"),
         helper.GetRMModulePath("AzureRM.Storage.psd1"),
         helper.GetRMModulePath("AzureRM.Sql.psd1"),
         helper.GetRMModulePath("AzureRM.ContainerInstance.psd1"),
         helper.GetRMModulePath("AzureRM.OperationalInsights.psd1"),
         helper.GetRMModulePath("AzureRM.KeyVault.psd1"),
         helper.GetRMModulePath("AzureRM.ManagedServiceIdentity.psd1"),
         helper.GetRMModulePath("AzureRM.PrivateDns.psd1"),
     })
                  .WithNewRecordMatcherArguments(
         userAgentsToIgnore: new Dictionary <string, string>
     {
         { "Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01" },
     },
         resourceProviders: new Dictionary <string, string>
     {
         { "Microsoft.Resources", null },
         { "Microsoft.Compute", null },
         { "Microsoft.Features", null },
         { "Microsoft.Authorization", null },
         { "Microsoft.Network", null },
         { "Microsoft.Storage", null },
         { "Microsoft.Sql", null },
         { "Microsoft.KeyVault", null },
         { "Microsoft.ManagedServiceIdentity", null },
         { "Microsoft.PrivateDns", null },
     }
         ).WithManagementClients(
         GetResourceManagementClient,
         GetManagedServiceIdentityClient,
         GetKeyVaultManagementClient,
         GetNetworkManagementClient,
         GetComputeManagementClient,
         GetStorageManagementClient,
         GetKeyVaultClient,
         GetAzureRestClient,
         GetPrivateDnsManagementClient
         )
                  .Build();
 }
 protected AccountsTestRunner(ITestOutputHelper output)
 {
     TestRunner = TestManager.CreateInstance(output)
                  .WithNewPsScriptFilename($"{GetType().Name}.ps1")
                  .WithCommonPsScripts(new[]
     {
         @"Common.ps1", @"AzureRM.Resources.ps1"
     })
                  .WithNewRmModules(helper => new[]
     {
         helper.RMProfileModule
     })
                  .Build();
 }
示例#7
0
 protected AutomationTestRunner(ITestOutputHelper output)
 {
     TestRunner = TestManager.CreateInstance(output)
                  .WithNewPsScriptFilename($"{GetType().Name}.ps1")
                  .WithProjectSubfolderForTests("ScenarioTests")
                  .WithCommonPsScripts(new[]
     {
         @"../AzureRM.Resources.ps1",
     })
                  .WithNewRmModules(helper => new[]
     {
         helper.RMProfileModule,
         helper.GetRMModulePath(@"AzureRM.Automation.psd1")
     })
                  .Build();
 }
示例#8
0
 protected ApiManagementTestRunner(ITestOutputHelper output)
 {
     TestRunner = TestManager.CreateInstance(output)
                  .WithNewPsScriptFilename($"{GetType().Name}.ps1")
                  .WithProjectSubfolderForTests("ScenarioTests")
                  .WithCommonPsScripts(new[]
     {
         @"Common.ps1"
     })
                  .WithNewRmModules(helper => new[]
     {
         helper.RMProfileModule,
         helper.GetRMModulePath("Az.ApiManagement.psd1")
     })
                  .Build();
 }
示例#9
0
 protected DeviceProvisioningServicesTestRunner(ITestOutputHelper output)
 {
     TestRunner = TestManager.CreateInstance(output)
                  .WithNewPsScriptFilename($"{GetType().Name}.ps1")
                  .WithProjectSubfolderForTests("ScenarioTests")
                  .WithCommonPsScripts(new[]
     {
         "../AzureRM.Resources.ps1"
     })
                  .WithNewRmModules(helper => new[]
     {
         helper.RMProfileModule,
         helper.GetRMModulePath("Az.DeviceProvisioningServices.psd1"),
         helper.GetRMModulePath("Az.IotHub.psd1")
     })
                  .Build();
 }
示例#10
0
 protected DataLakeAnalyticsTestRunner(ITestOutputHelper output)
 {
     TestRunner = TestManager.CreateInstance(output)
                  .WithNewPsScriptFilename($"{GetType().Name}.ps1")
                  .WithProjectSubfolderForTests("ScenarioTests")
                  .WithCommonPsScripts(new[]
     {
         @"Common.ps1",
         @"../AzureRM.Resources.ps1"
     })
                  .WithNewRmModules(helper => new[]
     {
         helper.RMProfileModule,
         helper.GetRMModulePath("Az.DataLakeAnalytics.psd1"),
         helper.GetRMModulePath("Az.DataLakeStore.psd1")
     })
                  .WithNewRecordMatcherArguments(
         userAgentsToIgnore: new Dictionary <string, string>
     {
         { "Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01" }
     },
         resourceProviders: new Dictionary <string, string>
     {
         { "Microsoft.Resources", null },
         { "Microsoft.Features", null },
         { "Microsoft.Authorization", null }
     }
         ).WithManagementClients(
         GetNewResourceManagementClient,
         GetDataLakeStoreAccountManagementClient,
         GetDataLakeAnalyticsAccountManagementClient,
         GetDataLakeAnalyticsJobManagementClient,
         GetDataLakeAnalyticsCatalogManagementClient
         )
                  .Build();
 }
        protected RecoveryServicesSiteRecoveryTestRunner(ITestOutputHelper output)
        {
            TestRunner = TestManager.CreateInstance(output)
                         .WithProjectSubfolderForTests("ScenarioTests")
                         .WithCommonPsScripts(new[]
            {
                @"../AzureRM.Storage.ps1",
                @"../AzureRM.Resources.ps1"
            })
                         .WithNewRmModules(helper => new[]
            {
                helper.RMProfileModule,
                helper.GetRMModulePath("Az.Network.psd1"),
                helper.GetRMModulePath("Az.Compute.psd1"),
                helper.GetRMModulePath("Az.RecoveryServices.psd1"),
#if !NETSTANDARD
                helper.GetRMModulePath("Az.RecoveryServices.SiteRecovery.psd1"),
#endif
            })
                         .WithNewRecordMatcherArguments(
                userAgentsToIgnore: new Dictionary <string, string>
            {
                { "Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01" },
            },
                resourceProviders: new Dictionary <string, string>
            {
                { "Microsoft.Resources", null },
                { "Microsoft.Features", null },
                { "Microsoft.Authorization", null },
                { "Microsoft.Compute", null },
                { "Microsoft.Storage", null },
                { "Microsoft.Network", null }
            }
                )
                         .Build();
        }
示例#12
0
 protected AksTestRunner(ITestOutputHelper output)
 {
     TestRunner = TestManager.CreateInstance(output)
                  .WithNewPsScriptFilename($"{GetType().Name}.ps1")
                  .WithProjectSubfolderForTests("ScenarioTests")
                  .WithCommonPsScripts(new[]
     {
         @"Common.ps1",
         @"../AzureRM.Resources.ps1"
     })
                  .WithNewRmModules(helper => new[]
     {
         helper.RMProfileModule,
         helper.GetRMModulePath("Az.Aks.psd1")
     })
                  .WithNewRecordMatcherArguments(
         userAgentsToIgnore: new Dictionary <string, string>
     {
         { "Microsoft.Azure.Management.Resources.ResourceManagementClient", "2017-05-10" },
         { "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient", "2017-05-10" }
     },
         resourceProviders: new Dictionary <string, string>
     {
         { "Microsoft.Resources", null },
         { "Microsoft.Features", null },
         { "Microsoft.Authorization", null }
     }
         ).WithMockContextAction(() =>
     {
         if (HttpMockServer.GetCurrentMode() == HttpRecorderMode.Playback)
         {
             AzureSession.Instance.DataStore = new MemoryDataStore();
             var home         = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
             var dir          = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
             var subscription = HttpMockServer.Variables["SubscriptionId"];
             AzureSession.Instance.DataStore.WriteFile(Path.Combine(home, ".ssh", "id_rsa.pub"), File.ReadAllText(dir + "/Fixtures/id_rsa.pub"));
             var jsonOutput = @"{""" + subscription + @""":{ ""service_principal"":""foo"",""client_secret"":""bar""}}";
             AzureSession.Instance.DataStore.WriteFile(Path.Combine(home, ".azure", "acsServicePrincipal.json"), jsonOutput);
         }
         else if (HttpMockServer.GetCurrentMode() == HttpRecorderMode.Record)
         {
             AzureSession.Instance.DataStore = new MemoryDataStore();
             var home               = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
             var dir                = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
             var subscription       = HttpMockServer.Variables["SubscriptionId"];
             var currentEnvironment = TestEnvironmentFactory.GetTestEnvironment();
             string spn             = null;
             string spnSecret       = null;
             if (currentEnvironment.ConnectionString.KeyValuePairs.ContainsKey("ServicePrincipal"))
             {
                 spn = currentEnvironment.ConnectionString.KeyValuePairs["ServicePrincipal"];
             }
             if (currentEnvironment.ConnectionString.KeyValuePairs.ContainsKey("ServicePrincipalSecret"))
             {
                 spnSecret = currentEnvironment.ConnectionString.KeyValuePairs["ServicePrincipalSecret"];
             }
             AzureSession.Instance.DataStore.WriteFile(Path.Combine(home, ".ssh", "id_rsa.pub"), File.ReadAllText(dir + "/Fixtures/id_rsa.pub"));
             var jsonOutput = @"{""" + subscription + @""":{ ""service_principal"":""" + spn + @""",""client_secret"":""" + spnSecret + @"""}}";
             AzureSession.Instance.DataStore.WriteFile(Path.Combine(home, ".azure", "acsServicePrincipal.json"), jsonOutput);
         }
     }
                                 )
                  .Build();
 }