Ejemplo n.º 1
0
        public async Task ReturnsNullIfNoAccount()
        {
            var(secretClient, secretClientFactory) = CreateMockClient();

            var store = new AzureKeyVaultAccountStore(
                NullLogger <AzureKeyVaultAccountStore> .Instance,
                Options.Create(new AzureKeyVaultLettuceEncryptOptions()),
                secretClientFactory,
                _mockCertificateAuthority);

            secretClient.Setup(c =>
                               c.GetSecretAsync(It.IsAny <string>(),
                                                null,
                                                default))
            .Throws(new RequestFailedException(404, "Not found"));

            var account = await store.GetAccountAsync(default);
Ejemplo n.º 2
0
        public async Task StoresAccountAsJsonSecret()
        {
            var(secretClient, secretClientFactory) = CreateMockClient();

            var store = new AzureKeyVaultAccountStore(
                NullLogger <AzureKeyVaultAccountStore> .Instance,
                Options.Create(new AzureKeyVaultLettuceEncryptOptions()),
                secretClientFactory,
                _mockCertificateAuthority);

            var accountModel = new AccountModel
            {
                Id             = 1234,
                EmailAddresses = new[] { "*****@*****.**" },
                PrivateKey     = KeyFactory.NewKey(Certes.KeyAlgorithm.ES512).ToDer(),
            };

            await store.SaveAccountAsync(accountModel, default);

            secretClient.Verify(c => c.SetSecretAsync(
                                    "le-account-acme-v02-api-letsencrypt-org",
                                    It.IsAny <string>(),
                                    default));
        }