コード例 #1
0
        public void FindSecrets(Func <SecretItem, bool> comparison, List <string> expectedMatches)
        {
            List <IEnumerable <SecretItem> > secretsPages = new List <IEnumerable <SecretItem> >()
            {
                new List <SecretItem>()
                {
                    new SecretItem("https://testkeyvault.vault.azure.net/secrets/Atlanta"),
                    new SecretItem("https://testkeyvault.vault.azure.net/secrets/Seattle"),
                    new SecretItem("https://testkeyvault.vault.azure.net/secrets/NewYork"),
                    new SecretItem("https://testkeyvault.vault.azure.net/secrets/Chicago")
                },
                new List <SecretItem>()
                {
                    new SecretItem("https://testkeyvault.vault.azure.net/secrets/Portland"),
                    new SecretItem("https://testkeyvault.vault.azure.net/secrets/Austin"),
                    new SecretItem("https://testkeyvault.vault.azure.net/secrets/SanDiego"),
                    new SecretItem("https://testkeyvault.vault.azure.net/secrets/LosAngeles")
                }
            };

            var matches = KeyVaultSecretsRepository.FindSecrets(secretsPages, comparison);

            Assert.Equal(expectedMatches.Count, matches.Count);
            foreach (string name in expectedMatches)
            {
                var matchingNames = matches.Where(x => x.Identifier.Name == name);
                Assert.Equal(matchingNames.Count(), 1);
                Assert.Equal(matchingNames.First().Identifier.Name, name);
            }
        }
コード例 #2
0
        public async Task FindSecrets(Func <SecretProperties, bool> comparison, List <string> expectedMatches)
        {
            AsyncPageable <SecretProperties> secretsPages = GetSecretProperties();
            var matches = await KeyVaultSecretsRepository.FindSecrets(secretsPages, comparison);

            Assert.Equal(expectedMatches.Count, matches.Count);
            foreach (string name in expectedMatches)
            {
                var matchingNames = matches.Where(x => x.Name == name);
                Assert.Equal(matchingNames.Count(), 1);
                Assert.Equal(matchingNames.First().Name, name);
            }
        }