Beispiel #1
0
        protected string GetStringFromAzureLocation(AzureLocation location)
        {
            string locationString = string.Empty;

            switch (location)
            {
            case AzureLocation.SouthCentralUS:
                locationString = "southcentralus";
                break;
            }
            if (string.IsNullOrWhiteSpace(locationString))
            {
                throw new Exception("Invalid Azure Location: " + location.ToString());
            }
            return(locationString);
        }
        private void ValidateVault(
            ManagedHsmData managedHsmData,
            string expectedVaultName,
            string expectedResourceGroupName,
            string expectedSubId,
            Guid expectedTenantId,
            AzureLocation expectedLocation,
            ManagedHsmSkuFamily expectedSkuFamily,
            ManagedHsmSkuName expectedSkuName,
            bool expectedEnablePurgeProtection,
            bool expectedEnableSoftDelete,
            List <string> expectedInitialAdminObjectIds,
            ManagedHsmNetworkRuleSet expectedNetworkAcls,
            PublicNetworkAccess expectedPublicNetworkAccess,
            int expectedSoftDeleteRetentionInDays,
            Dictionary <string, string> expectedTags)
        {
            Assert.NotNull(managedHsmData);
            Assert.NotNull(managedHsmData.Properties);

            string resourceIdFormat   = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.KeyVault/managedHSMs/{2}";
            string expectedResourceId = string.Format(resourceIdFormat, expectedSubId, expectedResourceGroupName, expectedVaultName);
            string expectedHsmUri     = $"https://{expectedVaultName}.managedhsm.azure.net/";

            Assert.AreEqual(expectedResourceId, managedHsmData.Id.ToString());
            Assert.AreEqual(expectedLocation.ToString(), managedHsmData.Location.ToString());
            Assert.AreEqual(expectedTenantId, managedHsmData.Properties.TenantId);
            Assert.AreEqual(expectedVaultName, managedHsmData.Name);
            Assert.AreEqual(expectedSkuFamily, managedHsmData.Sku.Family);
            Assert.AreEqual(expectedSkuName, managedHsmData.Sku.Name);
            Assert.AreEqual(expectedEnablePurgeProtection, managedHsmData.Properties.EnablePurgeProtection);
            Assert.AreEqual(expectedEnableSoftDelete, managedHsmData.Properties.EnableSoftDelete);
            Assert.AreEqual(expectedHsmUri, managedHsmData.Properties.HsmUri.ToString());
            Assert.AreEqual(expectedInitialAdminObjectIds, managedHsmData.Properties.InitialAdminObjectIds);
            Assert.AreEqual(expectedNetworkAcls.Bypass, managedHsmData.Properties.NetworkRuleSet.Bypass);
            Assert.AreEqual(expectedNetworkAcls.DefaultAction, managedHsmData.Properties.NetworkRuleSet.DefaultAction);
            Assert.AreEqual(expectedPublicNetworkAccess, managedHsmData.Properties.PublicNetworkAccess);
            Assert.AreEqual(expectedSoftDeleteRetentionInDays, managedHsmData.Properties.SoftDeleteRetentionInDays);
            Assert.True(expectedTags.DictionaryEqual(managedHsmData.Tags));
        }