public void CanGetJobSubmissionAccessTokenCredentialFromCurrentSubscription()
        {
            var getClustersCommand = new GetAzureHDInsightJobCommand();
            var waSubscription     = new AzureSubscription()
            {
                Id      = IntegrationTestBase.TestCredentials.SubscriptionId,
                Account = "test"
            };
            ProfileClient profileClient = new ProfileClient(new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));

            profileClient.Profile.Accounts["test"] = new AzureAccount
            {
                Id         = "test",
                Type       = AzureAccount.AccountType.User,
                Properties =
                    new Dictionary <AzureAccount.Property, string>
                {
                    { AzureAccount.Property.Subscriptions, IntegrationTestBase.TestCredentials.SubscriptionId.ToString() }
                }
            };
            profileClient.Profile.Save();
            var accessTokenCreds = getClustersCommand.GetJobSubmissionClientCredentials(
                waSubscription,
                profileClient.Profile.Context.Environment,
                IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName,
                profileClient.Profile);

            Assert.IsInstanceOfType(accessTokenCreds, typeof(HDInsightAccessTokenCredential));
            var asTokenCreds = accessTokenCreds as HDInsightAccessTokenCredential;

            Assert.IsNotNull(asTokenCreds);
            Assert.AreEqual("abc", asTokenCreds.AccessToken);
        }
        public void CanGetBasicAuthCredentialFromCredentials()
        {
            var getClustersCommand = new GetAzureHDInsightJobCommand();

            getClustersCommand.Credential = GetPSCredential(TestCredentials.AzureUserName, TestCredentials.AzurePassword);
            var waSubscription = new AzureSubscription()
            {
                Id = IntegrationTestBase.TestCredentials.SubscriptionId,
            };

            waSubscription.Account = "test";
            var           profile          = new AzureSMProfile();
            ProfileClient profileClient    = new ProfileClient(new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
            var           accessTokenCreds = getClustersCommand.GetJobSubmissionClientCredentials(
                waSubscription,
                profileClient.Profile.Context.Environment,
                IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName, profile);

            Assert.IsInstanceOfType(accessTokenCreds, typeof(BasicAuthCredential));
            var asBasicAuthCredentials = accessTokenCreds as BasicAuthCredential;

            Assert.IsNotNull(asBasicAuthCredentials);
            Assert.AreEqual(IntegrationTestBase.TestCredentials.AzureUserName, asBasicAuthCredentials.UserName);
            Assert.AreEqual(IntegrationTestBase.TestCredentials.AzurePassword, asBasicAuthCredentials.Password);
        }
Beispiel #3
0
        public void GetClientWithoutCredentialsorSubscriptionCertificateThrows()
        {
            ClusterDetails cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();

            using (var cmd = new GetAzureHDInsightJobCommand())
            {
                cmd.Cluster = cluster.Name;

                cmd.GetClient(cmd.Cluster);
            }
        }
Beispiel #4
0
        public GetAzureHDInsightJobCommand GetJobCommandDefinition()
        {
            var cmdlet = new GetAzureHDInsightJobCommand
            {
                CommandRuntime            = commandRuntimeMock.Object,
                HDInsightJobClient        = hdinsightJobManagementMock.Object,
                HDInsightManagementClient = hdinsightManagementMock.Object,
                HttpCredential            = new PSCredential("httpuser", string.Format("Password1!").ConvertToSecureString()),
                ClusterName = ClusterName
            };

            return(cmdlet);
        }
Beispiel #5
0
        public void CanGetJobSubmissionCertificateCredentialFromCurrentSubscription()
        {
            var getClustersCommand = new GetAzureHDInsightJobCommand();
            var waSubscription     = GetCurrentSubscription();
            var subscriptionCreds  = getClustersCommand.GetJobSubmissionClientCredentials(waSubscription, IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName);

            Assert.IsInstanceOfType(subscriptionCreds, typeof(JobSubmissionCertificateCredential));
            var asCertificateCreds = subscriptionCreds as JobSubmissionCertificateCredential;

            Assert.AreEqual(waSubscription.SubscriptionId, asCertificateCreds.SubscriptionId.ToString());
            Assert.AreEqual(waSubscription.Certificate, asCertificateCreds.Certificate);
            Assert.AreEqual(IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName, asCertificateCreds.Cluster);
        }
        public void GetJobSubmissionCredentialsThrowsInvalidOperationException()
        {
            string invalidClusterName = Guid.NewGuid().ToString("N");
            var    getClustersCommand = new GetAzureHDInsightJobCommand();

            try
            {
                getClustersCommand.GetClient(invalidClusterName);
                Assert.Fail("Should have failed.");
            }
            catch (InvalidOperationException invalidOperationException)
            {
                Assert.AreEqual("Expected either a Subscription or Credential parameter.", invalidOperationException.Message);
            }
        }
        public void CanGetJobSubmissionCertificateCredentialFromCurrentSubscription()
        {
            var           getClustersCommand = new GetAzureHDInsightJobCommand();
            var           waSubscription     = GetCurrentSubscription();
            ProfileClient profileClient      = new ProfileClient(new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));

            var subscriptionCreds = getClustersCommand.GetJobSubmissionClientCredentials(
                waSubscription,
                profileClient.Profile.Context.Environment,
                IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName,
                profileClient.Profile);

            Assert.IsInstanceOfType(subscriptionCreds, typeof(JobSubmissionCertificateCredential));
            var asCertificateCreds = subscriptionCreds as JobSubmissionCertificateCredential;

            Assert.AreEqual(waSubscription.Id, asCertificateCreds.SubscriptionId);
            Assert.AreEqual(IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName, asCertificateCreds.Cluster);
        }
Beispiel #8
0
        public void CanGetJobSubmissionAccessTokenCredentialFromCurrentSubscription()
        {
            string accessToken        = Guid.NewGuid().ToString("N");
            var    getClustersCommand = new GetAzureHDInsightJobCommand();
            var    waSubscription     = new WindowsAzureSubscription()
            {
                SubscriptionId        = IntegrationTestBase.TestCredentials.SubscriptionId.ToString(),
                ActiveDirectoryUserId = "BruceWayne",
                TokenProvider         = new FakeAccessTokenProvider(accessToken)
            };
            var accessTokenCreds = getClustersCommand.GetJobSubmissionClientCredentials(waSubscription, IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName);

            Assert.IsInstanceOfType(accessTokenCreds, typeof(HDInsightAccessTokenCredential));
            var asTokenCreds = accessTokenCreds as HDInsightAccessTokenCredential;

            Assert.IsNotNull(asTokenCreds);
            Assert.AreEqual(accessToken, asTokenCreds.AccessToken);
        }
 public void CanGetBasicAuthCredentialFromCredentials()
 {
     var getClustersCommand = new GetAzureHDInsightJobCommand();
     getClustersCommand.Credential = GetPSCredential(TestCredentials.AzureUserName, TestCredentials.AzurePassword);
     var waSubscription = new AzureSubscription()
     {
         Id = IntegrationTestBase.TestCredentials.SubscriptionId,
     };
     waSubscription.Account = "test";
     var profile = new AzureProfile();
     var accessTokenCreds = getClustersCommand.GetJobSubmissionClientCredentials(
         waSubscription,
         AzureSession.CurrentContext.Environment,
         IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName, profile);
     Assert.IsInstanceOfType(accessTokenCreds, typeof(BasicAuthCredential));
     var asBasicAuthCredentials = accessTokenCreds as BasicAuthCredential;
     Assert.IsNotNull(asBasicAuthCredentials);
     Assert.AreEqual(IntegrationTestBase.TestCredentials.AzureUserName, asBasicAuthCredentials.UserName);
     Assert.AreEqual(IntegrationTestBase.TestCredentials.AzurePassword, asBasicAuthCredentials.Password);
 }
        public void GetJobSubmissionCredentialsThrowsInvalidOperationException()
        {
            string invalidClusterName = Guid.NewGuid().ToString("N");
            var getClustersCommand = new GetAzureHDInsightJobCommand();

            try
            {
                getClustersCommand.GetClient(invalidClusterName);
                Assert.Fail("Should have failed.");
            }
            catch (InvalidOperationException invalidOperationException)
            {
                Assert.AreEqual("Expected either a Subscription or Credential parameter.", invalidOperationException.Message);
            }
        }
 public void CanGetJobSubmissionAccessTokenCredentialFromCurrentSubscription()
 {
     var getClustersCommand = new GetAzureHDInsightJobCommand();
     var waSubscription = new AzureSubscription()
     {
         Id = IntegrationTestBase.TestCredentials.SubscriptionId,
         Account = "test"
     };
     ProfileClient profileClient = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
     profileClient.Profile.Accounts["test"] = new AzureAccount
     {
         Id = "test",
         Type = AzureAccount.AccountType.User,
         Properties =
             new Dictionary<AzureAccount.Property, string>
             {
                 {AzureAccount.Property.Subscriptions, IntegrationTestBase.TestCredentials.SubscriptionId.ToString() }
             }
     };
     profileClient.Profile.Save();
     var accessTokenCreds = getClustersCommand.GetJobSubmissionClientCredentials(
         waSubscription,
         profileClient.Profile.Context.Environment,
         IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName,
         profileClient.Profile);
     Assert.IsInstanceOfType(accessTokenCreds, typeof(HDInsightAccessTokenCredential));
     var asTokenCreds = accessTokenCreds as HDInsightAccessTokenCredential;
     Assert.IsNotNull(asTokenCreds);
     Assert.AreEqual("abc", asTokenCreds.AccessToken);
 }
        public void CanGetJobSubmissionCertificateCredentialFromCurrentSubscription()
        {
            var getClustersCommand = new GetAzureHDInsightJobCommand();
            var waSubscription = GetCurrentSubscription();
            ProfileClient profileClient = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));

            var subscriptionCreds = getClustersCommand.GetJobSubmissionClientCredentials(
                waSubscription,
                profileClient.Profile.Context.Environment,
                IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName,
                profileClient.Profile);

            Assert.IsInstanceOfType(subscriptionCreds, typeof(JobSubmissionCertificateCredential));
            var asCertificateCreds = subscriptionCreds as JobSubmissionCertificateCredential;
            Assert.AreEqual(waSubscription.Id, asCertificateCreds.SubscriptionId);
            Assert.AreEqual(IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName, asCertificateCreds.Cluster);
        }
        public void CanGetBasicAuthCredentialFromCredentials()
        {
            string accessToken = Guid.NewGuid().ToString("N");
            var getClustersCommand = new GetAzureHDInsightJobCommand();
            getClustersCommand.Credential = GetPSCredential(TestCredentials.AzureUserName, TestCredentials.AzurePassword);
            var waSubscription = new WindowsAzureSubscription()
            {
                SubscriptionId = IntegrationTestBase.TestCredentials.SubscriptionId.ToString(),
                ActiveDirectoryUserId = "BruceWayne",
                TokenProvider = new FakeAccessTokenProvider(accessToken)
            };

            var accessTokenCreds = getClustersCommand.GetJobSubmissionClientCredentials(waSubscription, IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName);
            Assert.IsInstanceOfType(accessTokenCreds, typeof(BasicAuthCredential));
            var asBasicAuthCredentials = accessTokenCreds as BasicAuthCredential;
            Assert.IsNotNull(asBasicAuthCredentials);
            Assert.AreEqual(IntegrationTestBase.TestCredentials.AzureUserName, asBasicAuthCredentials.UserName);
            Assert.AreEqual(IntegrationTestBase.TestCredentials.AzurePassword, asBasicAuthCredentials.Password);
        }
        public void CanGetJobSubmissionCertificateCredentialFromCurrentSubscription()
        {
            var getClustersCommand = new GetAzureHDInsightJobCommand();
            var waSubscription = GetCurrentSubscription();
            var subscriptionCreds = getClustersCommand.GetJobSubmissionClientCredentials(waSubscription, IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName);

            Assert.IsInstanceOfType(subscriptionCreds, typeof(JobSubmissionCertificateCredential));
            var asCertificateCreds = subscriptionCreds as JobSubmissionCertificateCredential;
            Assert.AreEqual(waSubscription.SubscriptionId, asCertificateCreds.SubscriptionId.ToString());
            Assert.AreEqual(waSubscription.Certificate, asCertificateCreds.Certificate);
            Assert.AreEqual(IntegrationTestBase.TestCredentials.WellKnownCluster.DnsName, asCertificateCreds.Cluster);
        }
Beispiel #15
0
        public GetAzureHDInsightJobCommand GetJobCommandDefinition()
        {
            var cmdlet = new GetAzureHDInsightJobCommand
            {
                CommandRuntime = commandRuntimeMock.Object,
                HDInsightJobClient = hdinsightJobManagementMock.Object,
                HDInsightManagementClient = hdinsightManagementMock.Object,
                HttpCredential = new PSCredential("httpuser", string.Format("Password1!").ConvertToSecureString()),
                ClusterName = ClusterName
            };

            return cmdlet;
        }
        public void GetClientWithoutCredentialsorSubscriptionCertificateThrows()
        {
            ClusterDetails cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();
            using (var cmd = new GetAzureHDInsightJobCommand())
            {
                cmd.Cluster = cluster.Name;

                cmd.GetClient(cmd.Cluster);
            }
        }