Skip to content

Commit 032fb2b

Browse files
Nirjan Chapagainnchapagain001
authored andcommitted
Minor fix
1 parent c3a9d24 commit 032fb2b

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/VirtualClient/VirtualClient.Dependencies/CertificateInstallation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
148148
string certificatePath = this.Combine(this.CertificateDownloadDir, certificateFileName);
149149

150150
// Delete existing certificate file
151-
if (!this.fileSystem.File.Exists(certificatePath))
151+
if (this.fileSystem.File.Exists(certificatePath))
152152
{
153153
this.fileSystem.File.Delete(certificatePath);
154154
}

src/VirtualClient/VirtualClient.Main/BootstrapCommand.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,14 @@ protected void SetupCertificateInstallation()
147147
"The Key Vault URI must be provided (--key-vault) when installing certificates (--cert-name).");
148148
}
149149

150+
if (!string.IsNullOrWhiteSpace(this.CertificateDownloadDir))
151+
{
152+
this.Parameters["CertificateDownloadDir"] = this.CertificateDownloadDir;
153+
}
154+
150155
// Set certificate-related parameters
151156
this.Parameters["KeyVaultUri"] = this.KeyVault;
152157
this.Parameters["CertificateName"] = this.CertificateName;
153-
this.Parameters["CertificateDownloadDir"] = this.CertificateDownloadDir;
154158
}
155159

156160
protected void SetupPackageInstallation()

src/VirtualClient/VirtualClient.UnitTests/BootstrapCommandTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,27 @@ public void SetupCertificateInstallation_SetsUpOnlyExpectedParameters()
127127
Assert.IsFalse(command.Parameters.ContainsKey("TenantId"));
128128
}
129129

130+
[Test]
131+
public void SetupCertificateInstallation_AllowsCertificateDownloadDirectory()
132+
{
133+
var command = new TestBootstrapCommand
134+
{
135+
Parameters = new Dictionary<string, IConvertible>(StringComparer.OrdinalIgnoreCase),
136+
CertificateName = "mycert",
137+
KeyVault = "https://myvault.vault.azure.net/",
138+
AccessToken = "token123",
139+
TenantId = "00000000-0000-0000-0000-000000000001",
140+
CertificateDownloadDir = "C:\\certs"
141+
};
142+
143+
command.SetupCertificateInstallationPublic();
144+
145+
Assert.AreEqual(command.Parameters["KeyVaultUri"], command.KeyVault);
146+
Assert.AreEqual(command.Parameters["CertificateName"], command.CertificateName);
147+
Assert.AreEqual(command.Parameters["CertificateDownloadDir"], command.CertificateDownloadDir);
148+
Assert.AreEqual(command.Parameters.Count, 3);
149+
}
150+
130151
[Test]
131152
[TestCase(null)]
132153
[TestCase("")]

0 commit comments

Comments
 (0)