From 26250eb04af4ac365d98a75f35572f6cde83fe5f Mon Sep 17 00:00:00 2001 From: Ralph El Hage Date: Thu, 4 Apr 2024 13:08:44 -0700 Subject: [PATCH] Fix test failuies --- src/common/details/helpers/process_helpers.cs | 7 ++++--- .../adapters/recordingadapter/TestProxyClient.cs | 12 +++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/common/details/helpers/process_helpers.cs b/src/common/details/helpers/process_helpers.cs index d3b7724f..7f9eac06 100644 --- a/src/common/details/helpers/process_helpers.cs +++ b/src/common/details/helpers/process_helpers.cs @@ -9,8 +9,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; -using Azure.AI.CLI.Common.Clients.Models; -using Newtonsoft.Json.Linq; namespace Azure.AI.Details.Common.CLI { @@ -21,7 +19,10 @@ public readonly struct ProcessOutput public string MergedOutput { get; init; } public int ExitCode { get; init; } - public bool HasError => ExitCode != 0 || !string.IsNullOrWhiteSpace(StdError); + public bool HasError => ExitCode != 0 + || (!string.IsNullOrWhiteSpace(StdError) + // Special case to ignore errors when tests are running against the test-proxy + && !(StdError.Contains("`subjectAltName`") && StdError.Contains("`commonName`"))); } public class ProcessHelpers diff --git a/src/testing/adapters/recordingadapter/TestProxyClient.cs b/src/testing/adapters/recordingadapter/TestProxyClient.cs index f9dbfbb6..ccc9b407 100644 --- a/src/testing/adapters/recordingadapter/TestProxyClient.cs +++ b/src/testing/adapters/recordingadapter/TestProxyClient.cs @@ -190,7 +190,17 @@ private static async Task AddSanitizer(string headerName, JsonObject json) var result = await _httpClient.SendAsync(message); if (result.StatusCode != HttpStatusCode.OK) { - throw new Exception($"Failed to add sanitizer {result.StatusCode} {result.Content}"); + string responseContent = string.Empty; + if (result.Content != null) + { + try + { + responseContent = await result.Content.ReadAsStringAsync(); + } + catch { } + } + + throw new Exception($"Failed to add sanitizer {result.StatusCode} {responseContent}"); } }