diff --git a/src/VirtualClient/VirtualClient.Main/BootstrapCommand.cs b/src/VirtualClient/VirtualClient.Main/BootstrapCommand.cs index d86560b7c9..fbedca5ef4 100644 --- a/src/VirtualClient/VirtualClient.Main/BootstrapCommand.cs +++ b/src/VirtualClient/VirtualClient.Main/BootstrapCommand.cs @@ -136,9 +136,9 @@ protected void Validate() // // e.g. // --key-vault="https://any.vault.azure.net?cid=8cdebecc...&tid=42005d4d...&crti=ANY&crts=any.corp.azure.com" - if (string.IsNullOrWhiteSpace(this.AccessToken) + if (string.IsNullOrWhiteSpace(this.AccessToken) && string.IsNullOrWhiteSpace(this.TokenFilePath) - && string.IsNullOrWhiteSpace(this.TenantId) + && string.IsNullOrWhiteSpace(this.TenantId) && (this.KeyVaultStore as DependencyKeyVaultStore)?.Credentials == null) { throw new ArgumentException( @@ -153,4 +153,4 @@ protected void Validate() } } } -} +} \ No newline at end of file diff --git a/src/VirtualClient/VirtualClient.Main/CommandLineParser.cs b/src/VirtualClient/VirtualClient.Main/CommandLineParser.cs index b21f54fae9..6daf8791fe 100644 --- a/src/VirtualClient/VirtualClient.Main/CommandLineParser.cs +++ b/src/VirtualClient/VirtualClient.Main/CommandLineParser.cs @@ -642,4 +642,4 @@ private static string[] PreprocessArguments(params string[] args) return preprocessedArgs; } } -} +} \ No newline at end of file diff --git a/src/VirtualClient/VirtualClient.Main/ExecuteProfileCommand.cs b/src/VirtualClient/VirtualClient.Main/ExecuteProfileCommand.cs index bf5c5f655b..7ee7ec731d 100644 --- a/src/VirtualClient/VirtualClient.Main/ExecuteProfileCommand.cs +++ b/src/VirtualClient/VirtualClient.Main/ExecuteProfileCommand.cs @@ -669,7 +669,7 @@ protected void SetHostMetadataTelemetryProperties(IEnumerable profiles, new Dictionary { { "exitWait", this.ExitWait }, - { "layout", this.Layout.ToString() }, + { "layout", this.Layout?.ToString() }, { "logToFile", this.LogToFile }, { "iterations", this.Iterations?.ProfileIterations }, { "profiles", string.Join(",", profiles.Select(p => Path.GetFileName(p))) }, diff --git a/src/VirtualClient/VirtualClient.UnitTests/ExecuteProfileCommandTests.cs b/src/VirtualClient/VirtualClient.UnitTests/ExecuteProfileCommandTests.cs index debbd18436..0d513d4002 100644 --- a/src/VirtualClient/VirtualClient.UnitTests/ExecuteProfileCommandTests.cs +++ b/src/VirtualClient/VirtualClient.UnitTests/ExecuteProfileCommandTests.cs @@ -538,5 +538,18 @@ private static Tuple GetAccessTokenPair() return new Tuple(decodedOriginalBytes, decodedObscuredBytes); } + + [Test] + public void SetHostMetadataTelemetryPropertiesDoesNotThrowWhenLayoutIsNull() + { + // Layout is not mandatory for setting host metadata properties. + this.command.Layout = null; + + string profile = "TEST-WORKLOAD-PROFILE.json"; + List profiles = new List { this.mockFixture.GetProfilesPath(profile) }; + + // Act & Assert - Should not throw expection + Assert.DoesNotThrow(() => this.command.SetHostMetadataTelemetryProperties(profiles, this.mockFixture.Dependencies)); + } } }