Skip to content

Commit

Permalink
Revert changes in CertificateServiceClientCredentialsFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
ceciliaavila committed Oct 12, 2023
1 parent 9bc3eee commit bbfe786
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Microsoft.Bot.Connector.Authentication
public class CertificateServiceClientCredentialsFactory : ServiceClientCredentialsFactory
{
private readonly X509Certificate2 _certificate;
private readonly bool _sendX5c = false;
private readonly string _appId;
private readonly string _tenantId;
private readonly HttpClient _httpClient;
Expand Down Expand Up @@ -46,22 +45,6 @@ public CertificateServiceClientCredentialsFactory(X509Certificate2 certificate,
_logger = logger;
}

/// <summary>
/// Initializes a new instance of the <see cref="CertificateServiceClientCredentialsFactory"/> class.
/// </summary>
/// <param name="certificate">The certificate to use for authentication.</param>
/// <param name="sendX5c">If true will send the public certificate to Azure AD along with the token request, so that
/// Azure AD can use it to validate the subject name based on a trusted issuer policy.</param>
/// <param name="appId">Microsoft application Id related to the certificate.</param>
/// <param name="tenantId">The oauth token tenant.</param>
/// <param name="httpClient">A custom httpClient to use.</param>
/// <param name="logger">A logger instance to use.</param>
public CertificateServiceClientCredentialsFactory(X509Certificate2 certificate, bool sendX5c, string appId, string tenantId = null, HttpClient httpClient = null, ILogger logger = null)
: this(certificate, appId, tenantId, httpClient, logger)
{
_sendX5c = sendX5c;
}

/// <inheritdoc />
public override Task<bool> IsValidAppIdAsync(string appId, CancellationToken cancellationToken)
{
Expand All @@ -85,7 +68,7 @@ public override Task<ServiceClientCredentials> CreateCredentialsAsync(
}

return Task.FromResult<ServiceClientCredentials>(
new CertificateAppCredentials(_certificate, _sendX5c, _appId, _tenantId, _httpClient, _logger));
new CertificateAppCredentials(_certificate, _appId, _tenantId, _httpClient, _logger));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void IsAuthenticationDisabledTest()
[Fact]
public async void CanCreateCredentials()
{
var factory = new CertificateServiceClientCredentialsFactory(certificate.Object, false, TestAppId);
var factory = new CertificateServiceClientCredentialsFactory(certificate.Object, TestAppId);

var credentials = await factory.CreateCredentialsAsync(
TestAppId, TestAudience, "https://login.microsoftonline.com", true, CancellationToken.None);
Expand All @@ -76,7 +76,7 @@ public async void CanCreateCredentials()
[Fact]
public void CannotCreateCredentialsWithInvalidAppId()
{
var factory = new CertificateServiceClientCredentialsFactory(certificate.Object, false, TestAppId);
var factory = new CertificateServiceClientCredentialsFactory(certificate.Object, TestAppId);

Assert.ThrowsAsync<InvalidOperationException>(() => factory.CreateCredentialsAsync(
"InvalidAppId", TestAudience, "https://login.microsoftonline.com", true, CancellationToken.None));
Expand Down

0 comments on commit bbfe786

Please sign in to comment.