Skip to content

[HDINSIGHT] NullRef SShCreds bug #2744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ public class NewClusterTests : HDInsightTestBase
private const string StorageKey = "O9EQvp3A3AjXq/W27rst1GQfLllhp01qlJMJfSU1hVW2K42gUeiUUn2D8zX2lU3taiXSSfqkZlcPv+nQcYUxYw==";
private const int ClusterSize = 4;

private readonly PSCredential _httpCred;
private readonly PSCredential _httpCred, _sshCred;

public NewClusterTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
base.SetupTestsForManagement();
_httpCred = new PSCredential("hadoopuser", string.Format("Password1!").ConvertToSecureString());
_sshCred = new PSCredential("sshuser", string.Format("Password1!").ConvertToSecureString());
cmdlet = new NewAzureHDInsightClusterCommand
{
CommandRuntime = commandRuntimeMock.Object,
Expand Down Expand Up @@ -130,5 +131,95 @@ public void CanCreateNewHDInsightCluster()
clusterout.OperatingSystemType == OSType.Windows)),
Times.Once);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void CanCreateNewHDInsightCluster_Linux()
{
cmdlet.ClusterName = ClusterName;
cmdlet.ResourceGroupName = ResourceGroupName;
cmdlet.ClusterSizeInNodes = ClusterSize;
cmdlet.Location = Location;
cmdlet.HttpCredential = _httpCred;
cmdlet.DefaultStorageAccountName = StorageName;
cmdlet.DefaultStorageAccountKey = StorageKey;
cmdlet.ClusterType = ClusterType;
cmdlet.SshCredential = _sshCred;
cmdlet.OSType = OSType.Linux;

var cluster = new Cluster
{
Id = "id",
Name = ClusterName,
Location = Location,
Properties = new ClusterGetProperties
{
ClusterVersion = "3.1",
ClusterState = "Running",
ClusterDefinition = new ClusterDefinition
{
ClusterType = ClusterType
},
QuotaInfo = new QuotaInfo
{
CoresUsed = 24
},
OperatingSystemType = OSType.Linux
}
};
var coreConfigs = new Dictionary<string, string>
{
{"fs.defaultFS", "wasb://giyertestcsmv2@" + StorageName},
{
"fs.azure.account.key." + StorageName,
StorageKey
}
};
var gatewayConfigs = new Dictionary<string, string>
{
{"restAuthCredential.isEnabled", "true"},
{"restAuthCredential.username", _httpCred.UserName},
{"restAuthCredential.password", _httpCred.Password.ConvertToString()}
};

var configurations = new Dictionary<string, Dictionary<string, string>>
{
{"core-site", coreConfigs},
{"gateway", gatewayConfigs}
};
var serializedConfig = JsonConvert.SerializeObject(configurations);
cluster.Properties.ClusterDefinition.Configurations = serializedConfig;

var getresponse = new ClusterGetResponse { Cluster = cluster };

hdinsightManagementMock.Setup(c => c.CreateNewCluster(ResourceGroupName, ClusterName, It.Is<ClusterCreateParameters>(
parameters =>
parameters.ClusterSizeInNodes == ClusterSize &&
parameters.DefaultStorageAccountName == StorageName &&
parameters.DefaultStorageAccountKey == StorageKey &&
parameters.Location == Location &&
parameters.UserName == _httpCred.UserName &&
parameters.Password == _httpCred.Password.ConvertToString() &&
parameters.ClusterType == ClusterType &&
parameters.OSType == OSType.Linux &&
parameters.SshUserName == _sshCred.UserName &&
parameters.SshPassword == _sshCred.Password.ConvertToString())))
.Returns(getresponse)
.Verifiable();

cmdlet.ExecuteCmdlet();

commandRuntimeMock.VerifyAll();
commandRuntimeMock.Verify(f => f.WriteObject(It.Is<AzureHDInsightCluster>(
clusterout =>
clusterout.ClusterState == "Running" &&
clusterout.ClusterType == ClusterType &&
clusterout.ClusterVersion == "3.1" &&
clusterout.CoresUsed == 24 &&
clusterout.Location == Location &&
clusterout.Name == ClusterName &&
clusterout.OperatingSystemType == OSType.Linux)),
Times.Once);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public override void ExecuteCmdlet()
parameters.RdpPassword = RdpCredential.Password.ConvertToString();
}

if (OSType == OSType.Linux)
if (OSType == OSType.Linux && SshCredential != null)
{
parameters.SshUserName = SshCredential.UserName;
if (!string.IsNullOrEmpty(SshCredential.Password.ConvertToString()))
Expand Down