public void TestGetHashCode()
        {
            Uri uri = new Uri("https://test.vault.azure.net/keys/test-name/test-version");
            KeyVaultKeyIdentifier keyId = new KeyVaultKeyIdentifier(uri);

            Assert.AreEqual(uri.GetHashCode(), keyId.GetHashCode());
        }
        public void NotEquals()
        {
            KeyVaultKeyIdentifier a = new KeyVaultKeyIdentifier(new Uri("https://test.vault.azure.net/keys/test-name/test-version?api-version=7.0"));
            KeyVaultKeyIdentifier b = new KeyVaultKeyIdentifier(new Uri("https://test.vault.azure.net/keys/test-name/test-version?api-version=7.1"));

            Assert.AreNotEqual(a, b);
        }
        public Task <IKeyIdentifier> AddKey(IEnclaveKey key)
        {
            var kvKey = (KeyVaultKey)key;

            IKeyIdentifier id = new KeyVaultKeyIdentifier(kvKey.Identifier);

            return(Task.FromResult(id));
        }
Exemple #4
0
        public bool TryParse(Uri id, Uri vaultUri, string name, string version)
        {
            if (KeyVaultKeyIdentifier.TryParse(id, out KeyVaultKeyIdentifier identifier))
            {
                Assert.AreEqual(id, identifier.SourceId);
                Assert.AreEqual(vaultUri, identifier.VaultUri);
                Assert.AreEqual(name, identifier.Name);
                Assert.AreEqual(version, identifier.Version);

                return(true);
            }

            return(false);
        }
        public bool TryCreate(Uri id, Uri vaultUri, string name, string version)
        {
            bool result = KeyVaultKeyIdentifier.TryCreate(id, out KeyVaultKeyIdentifier identifier);

            if (result)
            {
                Assert.AreEqual(id, identifier.SourceId);
                Assert.AreEqual(vaultUri, identifier.VaultUri);
                Assert.AreEqual(name, identifier.Name);
                Assert.AreEqual(version, identifier.Version);
            }

            return(result);
        }
Exemple #6
0
        public bool Parse(Uri id, Uri vaultUri, string name, string version)
        {
            try
            {
                KeyVaultKeyIdentifier identifier = KeyVaultKeyIdentifier.Parse(id);

                Assert.AreEqual(id, identifier.SourceId);
                Assert.AreEqual(vaultUri, identifier.VaultUri);
                Assert.AreEqual(name, identifier.Name);
                Assert.AreEqual(version, identifier.Version);

                return(true);
            }
            catch (ArgumentException ex) when(ex.ParamName == "id")
            {
                return(false);
            }
        }
 public void TryCreateFromNull()
 {
     Assert.IsFalse(KeyVaultKeyIdentifier.TryCreate(null, out KeyVaultKeyIdentifier identifier));
     Assert.That(() => default(KeyVaultKeyIdentifier).Equals(identifier));
 }