/// <summary> /// Returns a textual representation of the certificate template issuance settings. /// </summary> /// <returns>A textual representation of the certificate template issuance settings.</returns> public override String ToString() { var SB = new StringBuilder(); SB.Append("[Issuance Requirements]" + Environment.NewLine); SB.Append(" Authorized signature count: " + SignatureCount + Environment.NewLine); if (SignatureCount > 0) { if (ApplicationPolicy == null) { SB.Append(" Application policy required: None" + Environment.NewLine); } else { SB.Append(" Application policy required: " + ApplicationPolicy.Format(true) + Environment.NewLine); } if (!_certPolicies.Any()) { SB.Append(" Issuance policies required: None" + Environment.NewLine); } else { SB.Append(" Issuance policies required: "); foreach (Oid oid in CertificatePolicies) { SB.Append(oid.Format(true) + "; "); } SB.Append(Environment.NewLine); } } SB.Append(ExistingCertForRenewal ? " Reenrollment requires: existing valid certificate." : " Reenrollment requires: same criteria as for enrollment."); return(SB.ToString()); }
private static void AssertValidApplicationDefinition(ApplicationDefinition model, ApplicationDefinition getResult) { Assert.AreEqual(model.Data.Name, getResult.Data.Name); Assert.AreEqual(model.Data.Id, getResult.Data.Id); Assert.AreEqual(model.Data.Type, getResult.Data.Type); Assert.AreEqual(model.Data.LockLevel, getResult.Data.LockLevel); Assert.AreEqual(model.Data.DisplayName, getResult.Data.DisplayName); Assert.AreEqual(model.Data.IsEnabled, getResult.Data.IsEnabled); Assert.AreEqual(model.Data.Authorizations, getResult.Data.Authorizations); if (model.Data.Authorizations != null || getResult.Data.Authorizations != null) { Assert.NotNull(model.Data.Authorizations); Assert.NotNull(getResult.Data.Authorizations); Assert.AreEqual(model.Data.Authorizations.Count, getResult.Data.Authorizations.Count); for (int i = 0; i < model.Data.Authorizations.Count; ++i) { ApplicationAuthorization modelAuthorizations = model.Data.Authorizations[i], getResultAuthorizations = getResult.Data.Authorizations[i]; AssertValidAuthorizations(modelAuthorizations, getResultAuthorizations); } } if (model.Data.Artifacts != null || getResult.Data.Artifacts != null) { Assert.NotNull(model.Data.Artifacts); Assert.NotNull(getResult.Data.Artifacts); Assert.AreEqual(model.Data.Artifacts.Count, getResult.Data.Artifacts.Count); for (int i = 0; i < model.Data.Artifacts.Count; ++i) { ApplicationDefinitionArtifact modelArtifacts = model.Data.Artifacts[i], getResultArtifacts = getResult.Data.Artifacts[i]; AssertValidArtifacts(modelArtifacts, getResultArtifacts); } } Assert.AreEqual(model.Data.Description, getResult.Data.Description); Assert.AreEqual(model.Data.PackageFileUri, getResult.Data.PackageFileUri); Assert.AreEqual(model.Data.MainTemplate, getResult.Data.MainTemplate); Assert.AreEqual(model.Data.CreateUiDefinition, getResult.Data.CreateUiDefinition); if (model.Data.NotificationPolicy != null || getResult.Data.NotificationPolicy != null) { Assert.NotNull(model.Data.NotificationPolicy); Assert.NotNull(getResult.Data.NotificationPolicy); if (model.Data.NotificationPolicy.NotificationEndpoints != null || getResult.Data.NotificationPolicy.NotificationEndpoints != null) { Assert.NotNull(model.Data.NotificationPolicy.NotificationEndpoints); Assert.NotNull(getResult.Data.NotificationPolicy.NotificationEndpoints); Assert.AreEqual(model.Data.NotificationPolicy.NotificationEndpoints.Count, getResult.Data.NotificationPolicy.NotificationEndpoints.Count); for (int i = 0; i < model.Data.NotificationPolicy.NotificationEndpoints.Count; ++i) { Assert.AreEqual(model.Data.NotificationPolicy.NotificationEndpoints[i].Uri, getResult.Data.NotificationPolicy.NotificationEndpoints[i].Uri); } } } if (model.Data.LockingPolicy != null || getResult.Data.LockingPolicy != null) { Assert.NotNull(model.Data.LockingPolicy); Assert.NotNull(getResult.Data.LockingPolicy); if (model.Data.LockingPolicy.AllowedActions != null || getResult.Data.LockingPolicy.AllowedActions != null) { Assert.NotNull(model.Data.LockingPolicy.AllowedActions); Assert.NotNull(getResult.Data.LockingPolicy.AllowedActions); Assert.AreEqual(model.Data.LockingPolicy.AllowedActions.Count, getResult.Data.LockingPolicy.AllowedActions.Count); for (int i = 0; i < model.Data.LockingPolicy.AllowedActions.Count; ++i) { Assert.AreEqual(model.Data.LockingPolicy.AllowedActions[i], getResult.Data.LockingPolicy.AllowedActions[i]); } } } if (model.Data.DeploymentPolicy != null || getResult.Data.DeploymentPolicy != null) { Assert.NotNull(model.Data.DeploymentPolicy); Assert.NotNull(getResult.Data.DeploymentPolicy); Assert.AreEqual(model.Data.DeploymentPolicy.DeploymentMode, getResult.Data.DeploymentPolicy.DeploymentMode); } if (model.Data.ManagementPolicy != null || getResult.Data.ManagementPolicy != null) { Assert.NotNull(model.Data.ManagementPolicy); Assert.NotNull(getResult.Data.ManagementPolicy); Assert.AreEqual(model.Data.ManagementPolicy.Mode, getResult.Data.ManagementPolicy.Mode); } if (model.Data.Policies != null || getResult.Data.Policies != null) { Assert.NotNull(model.Data.Policies); Assert.NotNull(getResult.Data.Policies); Assert.AreEqual(model.Data.Policies.Count, getResult.Data.Policies.Count); for (int i = 0; i < model.Data.Policies.Count; ++i) { ApplicationPolicy policy = model.Data.Policies[i], getPolicy = getResult.Data.Policies[i]; AssertValidPolicy(policy, getPolicy); } } }
private static void AssertValidPolicy(ApplicationPolicy model, ApplicationPolicy getResult) { Assert.AreEqual(model.Name, getResult.Name); Assert.AreEqual(model.Parameters, getResult.Parameters); Assert.AreEqual(model.PolicyDefinitionId, getResult.PolicyDefinitionId); }
internal static ApplicationDefinitionData DeserializeApplicationDefinitionData(JsonElement element) { Optional <string> managedBy = default; Optional <SkuAutoGenerated> sku = default; IDictionary <string, string> tags = default; Location location = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; ApplicationLockLevel lockLevel = default; Optional <string> displayName = default; Optional <bool> isEnabled = default; Optional <IList <ApplicationAuthorization> > authorizations = default; Optional <IList <ApplicationDefinitionArtifact> > artifacts = default; Optional <string> description = default; Optional <string> packageFileUri = default; Optional <object> mainTemplate = default; Optional <object> createUiDefinition = default; Optional <ApplicationNotificationPolicy> notificationPolicy = default; Optional <ApplicationPackageLockingPolicyDefinition> lockingPolicy = default; Optional <ApplicationDeploymentPolicy> deploymentPolicy = default; Optional <ApplicationManagementPolicy> managementPolicy = default; Optional <IList <ApplicationPolicy> > policies = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("managedBy")) { managedBy = property.Value.GetString(); continue; } if (property.NameEquals("sku")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } sku = SkuAutoGenerated.DeserializeSkuAutoGenerated(property.Value); continue; } if (property.NameEquals("tags")) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("location")) { location = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("lockLevel")) { lockLevel = property0.Value.GetString().ToApplicationLockLevel(); continue; } if (property0.NameEquals("displayName")) { displayName = property0.Value.GetString(); continue; } if (property0.NameEquals("isEnabled")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } isEnabled = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("authorizations")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <ApplicationAuthorization> array = new List <ApplicationAuthorization>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(ApplicationAuthorization.DeserializeApplicationAuthorization(item)); } authorizations = array; continue; } if (property0.NameEquals("artifacts")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <ApplicationDefinitionArtifact> array = new List <ApplicationDefinitionArtifact>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(ApplicationDefinitionArtifact.DeserializeApplicationDefinitionArtifact(item)); } artifacts = array; continue; } if (property0.NameEquals("description")) { description = property0.Value.GetString(); continue; } if (property0.NameEquals("packageFileUri")) { packageFileUri = property0.Value.GetString(); continue; } if (property0.NameEquals("mainTemplate")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } mainTemplate = property0.Value.GetObject(); continue; } if (property0.NameEquals("createUiDefinition")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } createUiDefinition = property0.Value.GetObject(); continue; } if (property0.NameEquals("notificationPolicy")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } notificationPolicy = ApplicationNotificationPolicy.DeserializeApplicationNotificationPolicy(property0.Value); continue; } if (property0.NameEquals("lockingPolicy")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } lockingPolicy = ApplicationPackageLockingPolicyDefinition.DeserializeApplicationPackageLockingPolicyDefinition(property0.Value); continue; } if (property0.NameEquals("deploymentPolicy")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } deploymentPolicy = ApplicationDeploymentPolicy.DeserializeApplicationDeploymentPolicy(property0.Value); continue; } if (property0.NameEquals("managementPolicy")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } managementPolicy = ApplicationManagementPolicy.DeserializeApplicationManagementPolicy(property0.Value); continue; } if (property0.NameEquals("policies")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <ApplicationPolicy> array = new List <ApplicationPolicy>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(ApplicationPolicy.DeserializeApplicationPolicy(item)); } policies = array; continue; } } continue; } } return(new ApplicationDefinitionData(id, name, type, tags, location, managedBy.Value, sku.Value, lockLevel, displayName.Value, Optional.ToNullable(isEnabled), Optional.ToList(authorizations), Optional.ToList(artifacts), description.Value, packageFileUri.Value, mainTemplate.Value, createUiDefinition.Value, notificationPolicy.Value, lockingPolicy.Value, deploymentPolicy.Value, managementPolicy.Value, Optional.ToList(policies))); }