public void TryMatchSecretRefTest_ValidSecretReference() { var validSecretRef = "[reference('seCrets/secretName_-10/valUes/1.0-alpha_Beta')]"; if (!ApplicationPackageGenerator.TryMatchSecretRef(ref validSecretRef)) { Assert.Fail("Valid secret ref is treated as invalid."); } Assert.AreEqual("secretName_-10:1.0-alpha_Beta", validSecretRef); }
private string TryMatchStorageAccountKeySecretRef(ref string accountKeyValue) { if (ApplicationPackageGenerator.TryMatchSecretRef(ref accountKeyValue)) { return(EnvironmentVariableTypeType.SecretsStoreRef.ToString()); } else { return(EnvironmentVariableTypeType.PlainText.ToString()); } }
private static void ApplicationOperation(Arguments parsedArguments) { if (String.IsNullOrEmpty(parsedArguments.ApplicationDescriptionPath) || String.IsNullOrEmpty(parsedArguments.GeneratedApplicationPackagePath)) { Console.WriteLine("ApplicationDescriptionPath and GeneratedApplicationPackagePath should be specified for SingleInstance"); return; } try { Application application = null; using (StreamReader file = File.OpenText(parsedArguments.ApplicationDescriptionPath)) { JsonSerializer serializer = new JsonSerializer(); serializer.Converters.Add(new DiagnosticsSinkJsonConverter()); serializer.Converters.Add(new VolumeMountJsonConverter()); application = (Application)serializer.Deserialize(file, typeof(Application)); } ApplicationManifestType appManifest; IList <ServiceManifestType> serviceManifest; GenerationConfig config = new GenerationConfig() { RemoveServiceFabricRuntimeAccess = true, IsolationLevel = "hyperV" }; var generator = new ApplicationPackageGenerator("TestType", "1.0", application, true, false, "C:\\settings", true, config); Dictionary <string, Dictionary <string, SettingsType> > settingsType; generator.Generate(out appManifest, out serviceManifest, out settingsType); DockerComposeUtils.GenerateApplicationPackage(appManifest, serviceManifest, settingsType, parsedArguments.GeneratedApplicationPackagePath); } catch (Exception e) { Console.WriteLine(e); } }
public void TryMatchSecretRefTest_InvalidSecretReference() { // Invalid secret reference: secret name contains "."; var invalidSecretRef = "[reference('secrets/secretName._-10/values/1.0-alpha_Beta')]"; if (ApplicationPackageGenerator.TryMatchSecretRef(ref invalidSecretRef)) { Assert.Fail("Invalid secret ref (secret name contains '.') is treated as valid."); } // Invalid secret reference: invalid format. invalidSecretRef = "[ref(\"secrets/secretName_-10/values/1.0-alpha_Beta\")]"; if (ApplicationPackageGenerator.TryMatchSecretRef(ref invalidSecretRef)) { Assert.Fail("Invalid secret ref (invalid format) is treated as valid."); } // Invalid secret reference: invalid version. invalidSecretRef = "[reference('secrets/secretName._-10/values/*')]"; if (ApplicationPackageGenerator.TryMatchSecretRef(ref invalidSecretRef)) { Assert.Fail("Invalid secret ref (invalid version) is treated as valid."); } // Invalid secret reference: missing version. invalidSecretRef = "[reference('secrets/secretName._-10/values/')]"; if (ApplicationPackageGenerator.TryMatchSecretRef(ref invalidSecretRef)) { Assert.Fail("Invalid secret ref (missing version) is treated as valid."); } // Invalid secret reference: missing secret name. invalidSecretRef = "[reference('secrets//values/1.0')]"; if (ApplicationPackageGenerator.TryMatchSecretRef(ref invalidSecretRef)) { Assert.Fail("Invalid secret ref (missing secret name) is treated as valid."); } }