From 6bfff6501e0f18d8321e5fa73a4bd46544917e25 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Tue, 1 Oct 2024 13:00:35 -0600 Subject: [PATCH 1/2] - Bump vulnerable RestSharp dependency in test suite --- EasyVCR.Tests/EasyVCR.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyVCR.Tests/EasyVCR.Tests.csproj b/EasyVCR.Tests/EasyVCR.Tests.csproj index 988d82b..309d3ff 100644 --- a/EasyVCR.Tests/EasyVCR.Tests.csproj +++ b/EasyVCR.Tests/EasyVCR.Tests.csproj @@ -20,7 +20,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 9aaf622012f554fddebaee0fa89961c1dd92a1e2 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Tue, 1 Oct 2024 14:53:15 -0600 Subject: [PATCH 2/2] - Remove no-longer-valid RestSharp test --- EasyVCR.Tests/ClientTest.cs | 35 ------------------------------ EasyVCR.Tests/EasyVCR.Tests.csproj | 1 - 2 files changed, 36 deletions(-) diff --git a/EasyVCR.Tests/ClientTest.cs b/EasyVCR.Tests/ClientTest.cs index 8907375..ea0c67e 100644 --- a/EasyVCR.Tests/ClientTest.cs +++ b/EasyVCR.Tests/ClientTest.cs @@ -9,7 +9,6 @@ using EasyVCR.Handlers; using EasyVCR.RequestElements; using Microsoft.VisualStudio.TestTools.UnitTesting; -using RestSharp; // ReSharper disable InconsistentNaming namespace EasyVCR.Tests @@ -46,40 +45,6 @@ public async Task TestClientClone() var handler = client.VcrHandler; var clonedHandler = clonedClient.VcrHandler; Assert.AreEqual(handler, clonedHandler); - - // lock the original client into a request (internally, RestClient will pass/lock the options to the HttpClient, which is what causes this issue) - var options = new RestClientOptions - { - MaxTimeout = 60000, - UserAgent = "EasyVCR Test Client", - BaseUrl = new Uri("https://httpbin.org"), - }; - - var restClient = new RestClient(client, options); - var request = new RestRequest("https://www.google.com"); - var _ = await restClient.ExecuteAsync(request); - - // now, if we try to reuse the client in another RestClient, it will throw an exception that the HttpClient is already in use - Assert.ThrowsException(() => new RestClient(client, options)); - - // even if we try with a different set of options - var options2 = new RestClientOptions - { - MaxTimeout = 30000, - UserAgent = "EasyVCR Test Client 2", - BaseUrl = new Uri("https://example.com"), - }; - Assert.ThrowsException(() => new RestClient(client, options2)); - - // if we use the cloned client, it will work - var restClient3 = new RestClient(clonedClient, options); - var request3 = new RestRequest("https://www.google.com"); - _ = await restClient3.ExecuteAsync(request3); - - // side-note, you CAN re-use the original client if you don't have any options (it's the RestClientOptions that's causing this issue) - var restClient4 = new RestClient(client); - var request4 = new RestRequest("https://www.google.com"); - _ = await restClient4.ExecuteAsync(request4); } [TestMethod] diff --git a/EasyVCR.Tests/EasyVCR.Tests.csproj b/EasyVCR.Tests/EasyVCR.Tests.csproj index 309d3ff..b745423 100644 --- a/EasyVCR.Tests/EasyVCR.Tests.csproj +++ b/EasyVCR.Tests/EasyVCR.Tests.csproj @@ -20,7 +20,6 @@ - all runtime; build; native; contentfiles; analyzers; buildtransitive