mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-31 14:13:02 +02:00
Add WithProxy(string proxyUrl, X509Certificate2 certificate) (#880)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using JetBrains.Annotations;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using WireMock.Settings;
|
||||
|
||||
namespace WireMock.ResponseBuilders;
|
||||
@@ -17,9 +17,17 @@ public interface IProxyResponseBuilder : IStatusCodeResponseBuilder
|
||||
IResponseBuilder WithProxy(string proxyUrl, string? clientX509Certificate2ThumbprintOrSubjectName = null);
|
||||
|
||||
/// <summary>
|
||||
/// WithProxy using IProxyAndRecordSettings.
|
||||
/// WithProxy using <see cref="ProxyAndRecordSettings"/>.
|
||||
/// </summary>
|
||||
/// <param name="settings">The IProxyAndRecordSettings.</param>
|
||||
/// <param name="settings">The ProxyAndRecordSettings.</param>
|
||||
/// <returns>A <see cref="IResponseBuilder"/>.</returns>
|
||||
IResponseBuilder WithProxy([NotNull] ProxyAndRecordSettings settings);
|
||||
IResponseBuilder WithProxy(ProxyAndRecordSettings settings);
|
||||
|
||||
/// <summary>
|
||||
/// WithProxy using <see cref="X509Certificate2"/>.
|
||||
/// </summary>
|
||||
/// <param name="proxyUrl">The proxy url.</param>
|
||||
/// <param name="certificate"">The X509Certificate2.</param>
|
||||
/// <returns>A <see cref="IResponseBuilder"/>.</returns>
|
||||
IResponseBuilder WithProxy(string proxyUrl, X509Certificate2 certificate);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System.Net.Http;
|
||||
using WireMock.Http;
|
||||
using WireMock.Settings;
|
||||
using Stef.Validation;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace WireMock.ResponseBuilders;
|
||||
|
||||
@@ -38,4 +39,19 @@ public partial class Response
|
||||
_httpClientForProxy = HttpClientBuilder.Build(settings);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IResponseBuilder WithProxy(string proxyUrl, X509Certificate2 certificate)
|
||||
{
|
||||
Guard.NotNullOrEmpty(proxyUrl);
|
||||
Guard.NotNull(certificate);
|
||||
|
||||
var settings = new ProxyAndRecordSettings
|
||||
{
|
||||
Url = proxyUrl,
|
||||
Certificate = certificate
|
||||
};
|
||||
|
||||
return WithProxy(settings);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user