コード例 #1
0
        public void CanCreateNewSecurityProfile()
        {
            SetupConfirmation(commandRuntimeMock);

            var config = new AzureHDInsightConfig();
            var newconfigcmdlet = new AddAzureHDInsightSecurityProfile()
            {
                CommandRuntime = commandRuntimeMock.Object,
                HDInsightManagementClient = hdinsightManagementMock.Object,
                Config = config,
                Domain = "domain.com",
                DomainUserCredential = new PSCredential("username","pass".ConvertToSecureString()),
                OrganizationalUnitDN = "OUDN",
                LdapsUrls = new[]
                {
                    "ldapsUrl"
                },
                ClusterUsersGroupDNs = new []
                {
                    "usersGroupDn"
                }
            };

            newconfigcmdlet.ExecuteCmdlet();
            commandRuntimeMock.Verify(
                f =>
                    f.WriteObject(
                        It.Is<AzureHDInsightConfig>(
                            c =>
                                c.ClusterType == ClusterType &&
                                c.AdditionalStorageAccounts.Count == 0 &&
                                c.Configurations.Count == 0 &&
                                string.IsNullOrEmpty(c.WorkerNodeSize) &&
                                string.IsNullOrEmpty(c.DefaultStorageAccountKey) &&
                                string.IsNullOrEmpty(c.DefaultStorageAccountName) &&
                                string.IsNullOrEmpty(c.HeadNodeSize) &&
                                string.IsNullOrEmpty(c.ZookeeperNodeSize) &&
                                c.HiveMetastore == null &&
                                c.OozieMetastore == null &&
                                c.ScriptActions.Count == 0 &&
                                c.SecurityProfile.Domain.Equals(newconfigcmdlet.Domain) &&
                                c.SecurityProfile.DomainUserCredential.UserName.Equals(newconfigcmdlet.DomainUserCredential.UserName) &&
                                c.SecurityProfile.OrganizationalUnitDN.Equals(newconfigcmdlet.OrganizationalUnitDN) &&
                                c.SecurityProfile.LdapsUrls.ArrayToString("").Equals(newconfigcmdlet.LdapsUrls.ArrayToString("")) &&
                                c.SecurityProfile.ClusterUsersGroupDNs.ArrayToString("").Equals(newconfigcmdlet.ClusterUsersGroupDNs.ArrayToString("")))),
                Times.Once);
        }
 public NewAzureHDInsightClusterConfigCommand()
 {
     _config = new AzureHDInsightConfig();
 }