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

Add logging through to Azure services #808

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
clairernovotny committed Dec 13, 2024
commit ec80c5886b965a5fefaa8dc5dd93a682c9c47db3
5 changes: 5 additions & 0 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="cs" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">Načetl se certifikát. [{milliseconds} ms]</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="de" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">Zertifikat abgerufen. [{milliseconds} ms]</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="es" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">Certificado capturado. [{milliseconds} ms]</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="fr" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">Certificat récupéré. [{milliseconds} ms]</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="it" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">Il certificato è stato recuperato. [{milliseconds} ms]</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ja" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">証明書をフェッチしました。[{milliseconds} ミリ秒]</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ko" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">인증서를 가져왔습니다. [{milliseconds}ms]</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pl" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">Pobrano certyfikat. [{milliseconds} ms]</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pt-BR" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">Certificado buscado. [{milliseconds} ms]</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ru" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">Получен сертификат. [{milliseconds} мс]</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Sign.SignatureProviders.KeyVault/xlf/Resources.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="tr" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">Sertifika getirildi. [{milliseconds} ms]</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="zh-Hans" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">已提取证书。[{milliseconds} 毫秒]</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="zh-Hant" original="../Resources.resx">
<body>
<trans-unit id="CertificateDetails">
<source>Certificate Details:\n{details}</source>
<target state="new">Certificate Details:\n{details}</target>
<note />
</trans-unit>
<trans-unit id="FetchedCertificate">
<source>Fetched certificate. [{milliseconds} ms]</source>
<target state="translated">已擷取憑證。[{milliseconds} 毫秒]</target>
Expand Down
2 changes: 1 addition & 1 deletion test/Sign.Core.Test/ServiceProviderFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void AddService_ServicesIsNull_Throws()
ArgumentNullException exception = Assert.Throws<ArgumentNullException>(
() => factory.AddServices(null!));

Assert.Equal("services", exception.ParamName);
Assert.Equal("addServices", exception.ParamName);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,45 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE.txt file in the project root for more information.

using Azure.Core;
using Azure.Security.KeyVault.Certificates;
using Azure.Security.KeyVault.Keys.Cryptography;

using Microsoft.Extensions.Logging;

using Moq;

namespace Sign.SignatureProviders.KeyVault.Test
{
public class KeyVaultServiceTests
{
private readonly static TokenCredential TokenCredential = Mock.Of<TokenCredential>();
private readonly static Uri KeyVaultUrl = new("https://keyvault.test");
private static readonly CertificateClient CertificateClient = Mock.Of<CertificateClient>();
private static readonly CryptographyClient CryptographyClient = Mock.Of<CryptographyClient>();
private const string CertificateName = "a";
private readonly static ILogger<KeyVaultService> logger = Mock.Of<ILogger<KeyVaultService>>();
private static readonly ILogger<KeyVaultService> logger = Mock.Of<ILogger<KeyVaultService>>();

[Fact]
public void Constructor_WhenTokenCredentialIsNull_Throws()
public void Constructor_WhenCertificateClientIsNull_Throws()
{
ArgumentNullException exception = Assert.Throws<ArgumentNullException>(
() => new KeyVaultService(tokenCredential: null!, KeyVaultUrl, CertificateName, logger));
() => new KeyVaultService(certificateClient: null!, CryptographyClient, CertificateName, logger));

Assert.Equal("tokenCredential", exception.ParamName);
Assert.Equal("certificateClient", exception.ParamName);
}

[Fact]
public void Constructor_WhenKeyVaultUrlIsNull_Throws()
public void Constructor_WhenCryptographyClientIsNull_Throws()
{
ArgumentNullException exception = Assert.Throws<ArgumentNullException>(
() => new KeyVaultService(TokenCredential, keyVaultUrl: null!, CertificateName, logger));
() => new KeyVaultService(CertificateClient, cryptographyClient: null!, CertificateName, logger));

Assert.Equal("keyVaultUrl", exception.ParamName);
Assert.Equal("cryptographyClient", exception.ParamName);
}

[Fact]
public void Constructor_WhenCertificateNameIsNull_Throws()
{
ArgumentNullException exception = Assert.Throws<ArgumentNullException>(
() => new KeyVaultService(TokenCredential, KeyVaultUrl, certificateName: null!, logger));
() => new KeyVaultService(CertificateClient, CryptographyClient, certificateName: null!, logger));

Assert.Equal("certificateName", exception.ParamName);
}
Expand All @@ -46,7 +49,7 @@ public void Constructor_WhenCertificateNameIsNull_Throws()
public void Constructor_WhenCertificateNameIsEmpty_Throws()
{
ArgumentException exception = Assert.Throws<ArgumentException>(
() => new KeyVaultService(TokenCredential, KeyVaultUrl, certificateName: string.Empty, logger));
() => new KeyVaultService(CertificateClient, CryptographyClient, certificateName: string.Empty, logger));

Assert.Equal("certificateName", exception.ParamName);
}
Expand All @@ -55,7 +58,7 @@ public void Constructor_WhenCertificateNameIsEmpty_Throws()
public void Constructor_WhenLoggerIsNull_Throws()
{
ArgumentNullException exception = Assert.Throws<ArgumentNullException>(
() => new KeyVaultService(TokenCredential, KeyVaultUrl, CertificateName, logger: null!));
() => new KeyVaultService(CertificateClient, CryptographyClient, CertificateName, logger: null!));

Assert.Equal("logger", exception.ParamName);
}
Expand Down