public AzureTestCredentials GetCredentials(string name) { AzureTestCredentials creds = null; this.credentialSets.TryGetValue(name, out creds); return(creds); }
public AlternativeEnvironmentIHDInsightSubscriptionCertificateCredentialsFactory() { creds = IntegrationTestBase.GetCredentialsForEnvironmentType(EnvironmentType.Current); }
private static AzureTestCredentials CloneForEnvironment(AzureTestCredentials orig, int index) { AzureTestCredentials retval = new AzureTestCredentials(); retval.AzurePassword = orig.AzurePassword; retval.AzureUserName = orig.AzureUserName; retval.Certificate = orig.Certificate; retval.CredentialsName = orig.CredentialsName; retval.HadoopUserName = orig.HadoopUserName; retval.InvalidCertificate = orig.InvalidCertificate; retval.SubscriptionId = orig.SubscriptionId; retval.ResourceProviderProperties = orig.ResourceProviderProperties; retval.WellKnownCluster = new KnownCluster() { Cluster = orig.WellKnownCluster.Cluster, DnsName = orig.WellKnownCluster.DnsName, Version = orig.WellKnownCluster.Version }; retval.Environments = new CreationDetails[0]; var env = retval.Environments[0] = new CreationDetails(); var origEnv = orig.Environments[index]; retval.CloudServiceName = orig.CloudServiceName; env.DefaultStorageAccount = new StorageAccountCredentials() { Container = origEnv.DefaultStorageAccount.Container, Key = origEnv.DefaultStorageAccount.Key, Name = origEnv.DefaultStorageAccount.Name }; retval.Endpoint = orig.Endpoint; env.Location = origEnv.Location; retval.EnvironmentType = orig.EnvironmentType; List<StorageAccountCredentials> storageAccounts = new List<StorageAccountCredentials>(); foreach (var storageAccountCredentials in origEnv.AdditionalStorageAccounts) { var account = new StorageAccountCredentials() { Container = storageAccountCredentials.Container, Key = storageAccountCredentials.Key, Name = storageAccountCredentials.Name }; storageAccounts.Add(account); } env.AdditionalStorageAccounts = storageAccounts.ToArray(); List<MetastoreCredentials> stores = new List<MetastoreCredentials>(); foreach (var metastoreCredentials in origEnv.HiveStores) { var metaStore = new MetastoreCredentials() { Database = metastoreCredentials.Database, Description = metastoreCredentials.Description, SqlServer = metastoreCredentials.SqlServer }; } env.HiveStores = stores.ToArray(); stores.Clear(); foreach (var metastoreCredentials in origEnv.OozieStores) { var metaStore = new MetastoreCredentials() { Database = metastoreCredentials.Database, Description = metastoreCredentials.Description, SqlServer = metastoreCredentials.SqlServer }; } env.OozieStores = stores.ToArray(); return retval; }
public static void TestRunSetup() { // Sets the simulator var runManager = ServiceLocator.Instance.Locate<IServiceLocationSimulationManager>(); ServiceLocator.Instance.Locate<ILogger>().AddWriter(new ConsoleLogWriter(Severity.None, Verbosity.Diagnostic)); runManager.RegisterType<IAsvValidatorClientFactory, AsvValidatorSimulatorClientFactory>(); runManager.RegisterType<IHDInsightManagementRestClientFactory, HDInsightManagementRestSimulatorClientFactory>(); runManager.RegisterType<IRdfeServiceRestClientFactory, RdfeServiceRestSimulatorClientFactory>(); runManager.RegisterType<IAzureHDInsightClusterConfigurationAccessorFactory, AzureHDInsightClusterConfigurationAccessorSimulatorFactory>(); runManager.RegisterInstance<IWabStorageAbstractionFactory>(StorageAccountSimulatorFactory.Instance); runManager.RegisterType<IRemoteHadoopJobSubmissionPocoClientFactory, HadoopJobSubmissionPocoSimulatorClientFactory>(); runManager.RegisterType<IHDInsightJobSubmissionPocoClientFactory, HadoopJobSubmissionPocoSimulatorClientFactory>(); runManager.RegisterType<ISubscriptionRegistrationClientFactory, SubscriptionRegistrationSimulatorClientFactory>(); var testManager = new IntegrationTestManager(); if (!testManager.RunAzureTests()) { Assert.Inconclusive("Azure tests are not configured on this machine."); } IntegrationTestBase.TestCredentials = testManager.GetCredentials("default"); if (IntegrationTestBase.TestCredentials == null) { Assert.Inconclusive("No entry was found in the credential config file for the specified test configuration."); } // Sets the certificate var defaultCertificate = new X509Certificate2(IntegrationTestBase.TestCredentials.Certificate); // Sets the test static properties IntegrationTestBase.ClusterPrefix = string.Format("CLITest-{0}", Environment.GetEnvironmentVariable("computername") ?? "unknown"); // Sets the credential objects var tempCredentials = new HDInsightCertificateCredential() { SubscriptionId = TestCredentials.SubscriptionId, Certificate = defaultCertificate, Endpoint = new Uri(TestCredentials.Endpoint) }; IntegrationTestBase.validCredentials = ServiceLocator.Instance .Locate<IHDInsightSubscriptionCredentialsFactory>() .Create(tempCredentials); tempCredentials = new HDInsightCertificateCredential() { SubscriptionId = Guid.NewGuid(), Certificate = defaultCertificate }; IntegrationTestBase.invalidSubscriptionId = ServiceLocator.Instance .Locate<IHDInsightSubscriptionCredentialsFactory>() .Create(tempCredentials); tempCredentials = new HDInsightCertificateCredential() { SubscriptionId = TestCredentials.SubscriptionId, Certificate = new X509Certificate2(TestCredentials.InvalidCertificate), Endpoint = new Uri(TestCredentials.Endpoint) }; IntegrationTestBase.invalidCertificate = ServiceLocator.Instance .Locate<IHDInsightSubscriptionCredentialsFactory>() .Create(tempCredentials); // Prepares the environment IntegrationTestBase.CleanUpClusters(); }
public void MakeFile(string filePath) { var def = new AzureTestCredentials(); def.CredentialsName = "example"; def.Certificate = @"C:\File\Path\To\Certificate\Uploaded\To\Azure\File.cer"; def.InvalidCertificate = @"C:\File\Path\To\Certificate\NOTUploaded\To\Azure\File.cer"; def.WellKnownCluster = new KnownCluster() { Cluster = "https://[dnsname].azurehdinsight.net:563", DnsName = "dnsname", Version = "1.2.0.0.LargeSKU-amd64-134231" }; def.AzureUserName = "******"; def.AzurePassword = "******"; def.HadoopUserName = "******"; def.Environments = new CreationDetails[1]; var env = new CreationDetails(); env.Location = "North Europe"; def.EnvironmentType = EnvironmentType.Production; def.Endpoint = "http://endpoint.url -- {this is only used for non production environments}"; def.CloudServiceName = "hdinsight -- {this is only used for non production environments}"; env.DefaultStorageAccount = new StorageAccountCredentials(); env.DefaultStorageAccount.Name = "blogStorageAccount"; env.DefaultStorageAccount.Key = "blobStorageKey"; env.DefaultStorageAccount.Container = "blogStorageContainer"; env.AdditionalStorageAccounts = new StorageAccountCredentials[1]; env.AdditionalStorageAccounts[0] = env.DefaultStorageAccount; env.HiveStores = new MetastoreCredentials[2]; env.HiveStores[0] = new MetastoreCredentials() { SqlServer = "SqlServerLocation", Database = "DatabaseName", Description = "HiveStore1", }; env.HiveStores[1] = new MetastoreCredentials() { SqlServer = "SqlServerLocation", Database = "DatabaseName", Description = "HiveStore2", }; env.OozieStores = new MetastoreCredentials[2]; env.OozieStores[0] = new MetastoreCredentials() { SqlServer = "SqlServerLocation", Database = "DatabaseName", Description = "OozieStore1", }; env.OozieStores[1] = new MetastoreCredentials() { SqlServer = "SqlServerLocation", Database = "DatabaseName", Description = "OozieStore2", }; List <AzureTestCredentials> data = new List <AzureTestCredentials>(); data.Add(def); XmlSerializer ser = new XmlSerializer(typeof(List <AzureTestCredentials>)); using (var stream = File.OpenWrite(filePath)) { ser.Serialize(stream, data); } }
public void MakeFile(string filePath) { var def = new AzureTestCredentials(); def.CredentialsName = "example"; def.Certificate = @"C:\File\Path\To\Certificate\Uploaded\To\Azure\File.cer"; def.InvalidCertificate = @"C:\File\Path\To\Certificate\NOTUploaded\To\Azure\File.cer"; def.WellKnownCluster = new KnownCluster() { Cluster = "https://[dnsname].azurehdinsight.net:563", DnsName = "dnsname", Version = "1.2.0.0.LargeSKU-amd64-134231" }; def.AzureUserName = "******"; def.AzurePassword = "******"; def.HadoopUserName = "******"; def.Environments = new CreationDetails[1]; var env = new CreationDetails(); env.Location = "North Europe"; def.EnvironmentType = EnvironmentType.Production; def.Endpoint = "http://endpoint.url -- {this is only used for non production environments}"; def.CloudServiceName = "hdinsight -- {this is only used for non production environments}"; env.DefaultStorageAccount = new StorageAccountCredentials(); env.DefaultStorageAccount.Name = "blogStorageAccount"; env.DefaultStorageAccount.Key = "blobStorageKey"; env.DefaultStorageAccount.Container = "blogStorageContainer"; env.AdditionalStorageAccounts = new StorageAccountCredentials[1]; env.AdditionalStorageAccounts[0] = env.DefaultStorageAccount; env.HiveStores = new MetastoreCredentials[2]; env.HiveStores[0] = new MetastoreCredentials() { SqlServer = "SqlServerLocation", Database = "DatabaseName", Description = "HiveStore1", }; env.HiveStores[1] = new MetastoreCredentials() { SqlServer = "SqlServerLocation", Database = "DatabaseName", Description = "HiveStore2", }; env.OozieStores = new MetastoreCredentials[2]; env.OozieStores[0] = new MetastoreCredentials() { SqlServer = "SqlServerLocation", Database = "DatabaseName", Description = "OozieStore1", }; env.OozieStores[1] = new MetastoreCredentials() { SqlServer = "SqlServerLocation", Database = "DatabaseName", Description = "OozieStore2", }; List<AzureTestCredentials> data = new List<AzureTestCredentials>(); data.Add(def); XmlSerializer ser = new XmlSerializer(typeof(List<AzureTestCredentials>)); using (var stream = File.OpenWrite(filePath)) { ser.Serialize(stream, data); } }
private static AzureTestCredentials CloneForEnvironment(AzureTestCredentials orig, int index) { AzureTestCredentials retval = new AzureTestCredentials(); retval.AzurePassword = orig.AzurePassword; retval.AzureUserName = orig.AzureUserName; retval.Certificate = orig.Certificate; retval.CredentialsName = orig.CredentialsName; retval.HadoopUserName = orig.HadoopUserName; retval.InvalidCertificate = orig.InvalidCertificate; retval.SubscriptionId = orig.SubscriptionId; retval.ResourceProviderProperties = orig.ResourceProviderProperties; retval.WellKnownCluster = new KnownCluster() { Cluster = orig.WellKnownCluster.Cluster, DnsName = orig.WellKnownCluster.DnsName, Version = orig.WellKnownCluster.Version }; retval.Environments = new CreationDetails[0]; var env = retval.Environments[0] = new CreationDetails(); var origEnv = orig.Environments[index]; retval.CloudServiceName = orig.CloudServiceName; env.DefaultStorageAccount = new StorageAccountCredentials() { Container = origEnv.DefaultStorageAccount.Container, Key = origEnv.DefaultStorageAccount.Key, Name = origEnv.DefaultStorageAccount.Name }; retval.Endpoint = orig.Endpoint; env.Location = origEnv.Location; retval.EnvironmentType = orig.EnvironmentType; List <StorageAccountCredentials> storageAccounts = new List <StorageAccountCredentials>(); foreach (var storageAccountCredentials in origEnv.AdditionalStorageAccounts) { var account = new StorageAccountCredentials() { Container = storageAccountCredentials.Container, Key = storageAccountCredentials.Key, Name = storageAccountCredentials.Name }; storageAccounts.Add(account); } env.AdditionalStorageAccounts = storageAccounts.ToArray(); List <MetastoreCredentials> stores = new List <MetastoreCredentials>(); foreach (var metastoreCredentials in origEnv.HiveStores) { var metaStore = new MetastoreCredentials() { Database = metastoreCredentials.Database, Description = metastoreCredentials.Description, SqlServer = metastoreCredentials.SqlServer }; } env.HiveStores = stores.ToArray(); stores.Clear(); foreach (var metastoreCredentials in origEnv.OozieStores) { var metaStore = new MetastoreCredentials() { Database = metastoreCredentials.Database, Description = metastoreCredentials.Description, SqlServer = metastoreCredentials.SqlServer }; } env.OozieStores = stores.ToArray(); return(retval); }
public static void TestRunSetup() { // Sets the simulator var runManager = ServiceLocator.Instance.Locate <IServiceLocationSimulationManager>(); ServiceLocator.Instance.Locate <ILogger>().AddWriter(new ConsoleLogWriter(Severity.None, Verbosity.Diagnostic)); runManager.RegisterType <IAsvValidatorClientFactory, AsvValidatorSimulatorClientFactory>(); runManager.RegisterType <IHDInsightManagementRestClientFactory, HDInsightManagementRestSimulatorClientFactory>(); runManager.RegisterType <IRdfeServiceRestClientFactory, RdfeServiceRestSimulatorClientFactory>(); runManager.RegisterType <IAzureHDInsightClusterConfigurationAccessorFactory, AzureHDInsightClusterConfigurationAccessorSimulatorFactory>(); runManager.RegisterInstance <IWabStorageAbstractionFactory>(StorageAccountSimulatorFactory.Instance); runManager.RegisterType <IRemoteHadoopJobSubmissionPocoClientFactory, HadoopJobSubmissionPocoSimulatorClientFactory>(); runManager.RegisterType <IHDInsightJobSubmissionPocoClientFactory, HadoopJobSubmissionPocoSimulatorClientFactory>(); runManager.RegisterType <ISubscriptionRegistrationClientFactory, SubscriptionRegistrationSimulatorClientFactory>(); var testManager = new IntegrationTestManager(); if (!testManager.RunAzureTests()) { Assert.Inconclusive("Azure tests are not configured on this machine."); } IntegrationTestBase.TestCredentials = testManager.GetCredentials("default"); if (IntegrationTestBase.TestCredentials == null) { Assert.Inconclusive("No entry was found in the credential config file for the specified test configuration."); } // Sets the certificate var defaultCertificate = new X509Certificate2(IntegrationTestBase.TestCredentials.Certificate); // Sets the test static properties IntegrationTestBase.ClusterPrefix = string.Format("CLITest-{0}", Environment.GetEnvironmentVariable("computername") ?? "unknown"); // Sets the credential objects var tempCredentials = new HDInsightCertificateCredential() { SubscriptionId = TestCredentials.SubscriptionId, Certificate = defaultCertificate, Endpoint = new Uri(TestCredentials.Endpoint) }; IntegrationTestBase.validCredentials = ServiceLocator.Instance .Locate <IHDInsightSubscriptionCredentialsFactory>() .Create(tempCredentials); tempCredentials = new HDInsightCertificateCredential() { SubscriptionId = Guid.NewGuid(), Certificate = defaultCertificate }; IntegrationTestBase.invalidSubscriptionId = ServiceLocator.Instance .Locate <IHDInsightSubscriptionCredentialsFactory>() .Create(tempCredentials); tempCredentials = new HDInsightCertificateCredential() { SubscriptionId = TestCredentials.SubscriptionId, Certificate = new X509Certificate2(TestCredentials.InvalidCertificate), Endpoint = new Uri(TestCredentials.Endpoint) }; IntegrationTestBase.invalidCertificate = ServiceLocator.Instance .Locate <IHDInsightSubscriptionCredentialsFactory>() .Create(tempCredentials); // Prepares the environment IntegrationTestBase.CleanUpClusters(); }