Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLVS-1369 Add checkServerTrusted rpc method implementation #5667

Conversation

georgii-borovinskikh-sonarsource
Copy link
Contributor

@georgii-borovinskikh-sonarsource georgii-borovinskikh-sonarsource commented Sep 3, 2024

public bool ValidateChain(X509Certificate2 primaryCertificate, IEnumerable<X509Certificate2> additionalCertificates)
{
logger.LogVerbose($"[{nameof(CertificateChainValidator)}] Validating certificate: " + primaryCertificate);
var x509Chain = new X509Chain();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The X509Chain implements IDisposable. Wrap code in a using statement

public async Task CheckServerTrustedAsync_MultipleCertificates_ConvertsAndValidates(bool validationResult)
{
var primaryCertificateDto = new X509CertificateDto("some certificate");
var additionalCertificateDto1 = new X509CertificateDto("some other certificate 1");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract the mocking of a certificate in a separate method and reuse the method in all unit tests. This will reduce the noise in this unit test and it will make it easier to understand.

Copy link

sonarqubecloud bot commented Sep 9, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants