public void GetUpdates1199RegressionTest() { // Use the same package name, but force the version to be unique. string packageName = "NuGetGallery.FunctionalTests.ODataTests.GetUpdates1199RegressionTest"; string ticks = DateTime.Now.Ticks.ToString(); string version1 = new System.Version(ticks.Substring(0, 6) + "." + ticks.Substring(6, 6) + "." + ticks.Substring(12, 6)).ToString(); string version2 = new System.Version(Convert.ToInt32(ticks.Substring(0, 6) + 1).ToString() + "." + ticks.Substring(6, 6) + "." + ticks.Substring(12, 6)).ToString(); string standardOutput = string.Empty; string standardError = string.Empty; string package1Location = PackageCreationHelper.CreatePackageWithTargetFramework(packageName, version1, "net45"); int exitCode = CmdLineHelper.UploadPackage(package1Location, UrlHelper.V2FeedPushSourceUrl, out standardOutput, out standardError); Assert.IsTrue((exitCode == 0), "The package upload via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream. Exit Code: " + exitCode + ". Error message: \"" + standardError + "\""); string package2Location = PackageCreationHelper.CreatePackageWithTargetFramework(packageName, version2, "net40"); exitCode = CmdLineHelper.UploadPackage(package2Location, UrlHelper.V2FeedPushSourceUrl, out standardOutput, out standardError); Assert.IsTrue((exitCode == 0), "The package upload via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream. Exit Code: " + exitCode + ". Error message: \"" + standardError + "\""); WebRequest request = WebRequest.Create(UrlHelper.V2FeedRootUrl + @"/GetUpdates()?packageIds='NuGetGallery.FunctionalTests.ODataTests.GetUpdates1199RegressionTest%7COwin%7CMicrosoft.Web.Infrastructure%7CMicrosoft.AspNet.Identity.Core%7CMicrosoft.AspNet.Identity.EntityFramework%7CMicrosoft.AspNet.Identity.Owin%7CMicrosoft.AspNet.Web.Optimization%7CRespond%7CWebGrease%7CjQuery%7CjQuery.Validation%7CMicrosoft.Owin.Security.Twitter%7CMicrosoft.Owin.Security.OAuth%7CMicrosoft.Owin.Security.MicrosoftAccount%7CMicrosoft.Owin.Security.Google%7CMicrosoft.Owin.Security.Facebook%7CMicrosoft.Owin.Security.Cookies%7CMicrosoft.Owin%7CMicrosoft.Owin.Host.SystemWeb%7CMicrosoft.Owin.Security%7CModernizr%7CMicrosoft.jQuery.Unobtrusive.Validation%7CMicrosoft.AspNet.WebPages%7CMicrosoft.AspNet.Razor%7Cbootstrap%7CAntlr%7CMicrosoft.AspNet.Mvc%7CNewtonsoft.Json%7CEntityFramework'&versions='" + version1 + "%7C1.0%7C1.0.0.0%7C1.0.0%7C1.0.0%7C1.0.0%7C1.1.1%7C1.2.0%7C1.5.2%7C1.10.2%7C1.11.1%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.0.0%7C2.6.2%7C3.0.0%7C3.0.0%7C3.0.0%7C3.0.0%7C3.4.1.9004%7C5.0.0%7C5.0.6%7C6.0.0'&includePrerelease=false&includeAllVersions=false&targetFrameworks='net45'&versionConstraints='%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C'"); // Get the response. WebResponse response = request.GetResponse(); StreamReader sr = new StreamReader(response.GetResponseStream()); string responseText = sr.ReadToEnd(); // Verify at least one package is in the output. Assert.IsTrue(responseText.Contains(@"<title type=""text"">NuGetGallery.FunctionalTests.ODataTests.GetUpdates1199RegressionTest</title>")); Assert.IsTrue(responseText.Contains(@"<d:Version>" + version2 + "</d:Version><d:NormalizedVersion>" + version2 + "</d:NormalizedVersion>")); }
protected string[] RunCommand(string exeName, ArgBuilder args, ICredentials creds, string workingDir) { var provider = this as IScmProvider; if (String.IsNullOrEmpty(exeName)) { exeName = DefaultExeName; } var h = new CmdLineHelper(workingDir) { CredentialsString = provider?.FormatCredentials(creds) }; var result = h.Call(exeName, args.ToString()); if (provider != null) { if (provider.IsError(h.LastExitCode)) { throw new Exception($"SCM provider {provider.Name} returned exit code '{h.LastExitCode}'."); } } return(result); }
private void GetParams(IEnumerable <string> args) { _cmd = new CmdLineHelper(); _cmd.Parse(args); _processName = _cmd.ParamAfterSwitch("ProcessName"); _scriptFile = _cmd.ParamAfterSwitch("ScriptFile"); _code = _cmd.ParamAfterSwitch("Code"); }
public void DownloadPackageWithNuGetCommandLineTest() { string packageId = Constants.TestPackageId; //try to down load a pre-defined test package. ClientSDKHelper.ClearLocalPackageFolder(packageId); int exitCode = CmdLineHelper.InstallPackage(packageId, UrlHelper.V2FeedRootUrl, Environment.CurrentDirectory); Assert.IsTrue((exitCode == 0), Constants.PackageDownloadFailureMessage); Assert.IsTrue(ClientSDKHelper.CheckIfPackageInstalled(packageId), Constants.PackageInstallFailureMessage); }
public void DownPackageWithNuGetCommandLineTest() { string packageId = Constants.TestPackageId; //try to down load a pre-defined test package. ClientSDKHelper.ClearLocalPackageFolder(packageId); int exitCode = CmdLineHelper.InstallPackage(packageId, UrlHelper.V2FeedRootUrl); Assert.IsTrue((exitCode == 0), "The package install via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream"); Assert.IsTrue(ClientSDKHelper.CheckIfPackageInstalled(packageId), "Package install failed. Either the file is not present on disk or it is corrupted. Check logs for details"); }
/// <summary> /// Maps the special commands. /// </summary> /// <param name="cmdLineHelper">The CMD line helper.</param> /// <returns></returns> public List<Action> MapSpecialCommands(CmdLineHelper cmdLineHelper) { MethodInfo[] methods = this.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance); List<Action> results = new List<Action>(); foreach (MethodInfo method in methods) { CommandAttribute[] attrib = (CommandAttribute[])method.GetCustomAttributes(typeof(CommandAttribute), false); if (attrib.Length > 0) { if (!cmdLineHelper.HasSwitch(method.Name)) { continue; } var args = cmdLineHelper.ParamsAfterSwitch(method.Name).ToList(); var convertedArgs = new List<object>(); for (int i = 0; i < args.Count(); i++) { var parameters = method.GetParameters().ToList(); Type parameterType = parameters[i].ParameterType; object value = null; if (parameterType.IsEnum) { value = Enum.Parse(parameterType, args[i]); } else { value = Convert.ChangeType(args[i], parameterType); } convertedArgs.Add(value); } var methodToExecute = method; results.Add(() => { try { methodToExecute.Invoke(this, convertedArgs.ToArray()); } catch (Exception e) { string error = string.Format("Fatal Error, command: ({0}). Exception: {1}", methodToExecute.Name, e.Message); Console.WriteLine(error); throw new Exception(error); } }); } } return results; }
/// <summary> Callback to parse the command line options. </summary> public override void Load() { var args = CmdLineHelper.FilterArguments(Args); var switches = CmdLineHelper.FilterSwitches(Args); // with the above we split up all the switches and arguments into separate variables // switches - contains anything starting with a / - -- // args - contains everything else Data = SplitLoadFunc(args, switches); }
public void DownloadPackageWithNuGetCommandLineTest() { // Temporary work around for the SSL issue, which keeps the upload tests from working on sites with cloudapp.net if (UrlHelper.BaseUrl.Contains("nugettest.org") || UrlHelper.BaseUrl.Contains("nuget.org")) { string packageId = Constants.TestPackageId; //try to down load a pre-defined test package. ClientSDKHelper.ClearLocalPackageFolder(packageId); int exitCode = CmdLineHelper.InstallPackage(packageId, UrlHelper.V2FeedRootUrl, Environment.CurrentDirectory); Assert.IsTrue((exitCode == 0), Constants.PackageDownloadFailureMessage); Assert.IsTrue(ClientSDKHelper.CheckIfPackageInstalled(packageId), Constants.PackageInstallFailureMessage); } }
public void AddPackageToWindows8CuratedFeed() { string packageId = testContextInstance.TestName + DateTime.Now.Ticks.ToString(); string packageFullPath = PackageCreationHelper.CreateWindows8CuratedPackage(packageId); int exitCode = CmdLineHelper.UploadPackage(packageFullPath, UrlHelper.V2FeedPushSourceUrl); Assert.IsTrue((exitCode == 0), "The package upload via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream"); //check if the package is present in windows 8 feed. //TBD : Need to check the exact the url for curated feed. System.Threading.Thread.Sleep(60000); Assert.IsTrue(ClientSDKHelper.CheckIfPackageExistsInSource(packageId, UrlHelper.Windows8CuratedFeedUrl), "Package {0} is not found in the site {1} after uploading.", packageId, UrlHelper.Windows8CuratedFeedUrl); }
void Run(string[] args) { //TestMode(); //return; Console.OutputEncoding = Encoding.ASCII; var cmd = new CmdLineHelper(); _runner = new PyRunner(cmd.ParamAfterSwitch("command"), cmd.ParamAfterSwitch("script"), cmd.ParamAfterSwitch("args"), cmd.ParamAfterSwitch("workingDirectory"), cmd); _runner.Run(); //Console.ReadKey(); }
void TestMode() { // -script "TestScript.py" -args "status" -command "hg" -workingDirectory "d:\Dev\Openbox\Change Controls\GBS Reforecasts Integration" Console.OutputEncoding = Encoding.ASCII; var cmd = new CmdLineHelper(); _runner = new PyRunner("notepad.exe", "TestScript.py", "test.txt", @"c:\temp", cmd); _runner.Run(); // Console.ReadKey(); }
public Form1() { InitializeComponent(); FormClosing += new FormClosingEventHandler(Form1_FormClosing); _configuration = new BindingList <IPConfiguration>(); _configuration.Clear(); foreach (var s in Properties.Settings.Default.ConfigurationStrings) { var cmd = new CmdLineHelper(); cmd.ParseString(s); var config = new IPConfiguration(); config.Configure(cmd); _configuration.Add(config); } UpdateContextMenu(); }
/// <summary> Determine if someone has specified an alternative configuration file. </summary> /// <param name="opts"> Command line options. </param> /// <returns> The configuration file path. </returns> private static string GetCfgFilePath(IEnumerable <string> opts) { // Default path for configuration file var cfgfile = "Settings1.json"; // search the switches for a cfgfile setting i.e. --cfgfile="Settings2.json" var switches = CmdLineHelper.FilterSwitches(opts); if (switches.ContainsKey("cfgfile")) { cfgfile = switches["cfgfile"]; // If the user has specified one then warn if it doesn't exist if (!File.Exists(cfgfile)) { Console.WriteLine($"Warning unable to locate configuration file: {cfgfile}"); } } return(cfgfile); }
public void UploadAndDownLoadPackageWithMinClientVersion() { string packageId = DateTime.Now.Ticks.ToString() + "PackageWithDotCsNames.Cs"; string version = "1.0.0"; string packageFullPath = PackageCreationHelper.CreatePackageWithMinClientVersion(packageId, version, "2.3"); int exitCode = CmdLineHelper.UploadPackage(packageFullPath, UrlHelper.V2FeedPushSourceUrl); Assert.IsTrue((exitCode == 0), Constants.UploadFailureMessage); Assert.IsTrue(ClientSDKHelper.CheckIfPackageVersionExistsInSource(packageId, version, UrlHelper.V2FeedRootUrl), Constants.PackageNotFoundAfterUpload, packageId, UrlHelper.V2FeedRootUrl); //Delete package from local disk so once it gets uploaded if (File.Exists(packageFullPath)) { File.Delete(packageFullPath); Directory.Delete(Path.GetFullPath(Path.GetDirectoryName(packageFullPath)), true); } AssertAndValidationHelper.DownloadPackageAndVerify(packageId); }
public int UploadPackageToCuratedFeed(string packageName, string version, FeedType feedType) { string packageFullPath = string.Empty; switch (feedType) { case FeedType.Windows8CuratedFeed: packageFullPath = PackageCreationHelper.CreateWindows8CuratedPackage(packageName, version); break; case FeedType.WebMatrixCuratedFeed: packageFullPath = PackageCreationHelper.CreateWindows8CuratedPackage(packageName, version); break; } int exitCode = CmdLineHelper.UploadPackage(packageFullPath, UrlHelper.V2FeedPushSourceUrl); return(exitCode); }
[Ignore] //This method is marked ignore as we don't it to be run in regular runs. It will be run only when required. public void UploadAndDownLoadTestBombPackage() { string packageId = DateTime.Now.Ticks.ToString() + testContextInstance.TestName; string version = "1.0.0"; string packageFullPath = PackageCreationHelper.CreateGalleryTestBombPackage(packageId); int exitCode = CmdLineHelper.UploadPackage(packageFullPath, UrlHelper.V2FeedPushSourceUrl); Assert.IsTrue((exitCode == 0), "The package upload via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream"); Assert.IsTrue(ClientSDKHelper.CheckIfPackageVersionExistsInSource(packageId, version, UrlHelper.V2FeedRootUrl), "Package {0} is not found in the site {1} after uploading.", packageId, UrlHelper.V2FeedRootUrl); //Delete package from local disk so once it gets uploaded if (File.Exists(packageFullPath)) { File.Delete(packageFullPath); Directory.Delete(Path.GetFullPath(Path.GetDirectoryName(packageFullPath)), true); } AssertAndValidationHelper.DownloadPackageAndVerify(packageId); }
/// <summary> Callback to parse the command line options. </summary> public override void Load() { var splitindex = Array.IndexOf(Args, "--"); var arr1 = Args.Take(splitindex).ToList(); var arr2 = Args.Skip(splitindex).ToList(); var args1 = CmdLineHelper.FilterArguments(arr1); var switches1 = CmdLineHelper.FilterSwitches(arr1); var args2 = CmdLineHelper.FilterArguments(arr2); var switches2 = CmdLineHelper.FilterSwitches(arr2); // This is the same as the split provider // However we split the arguments and switches into two groups // seperated by wherever -- shows up on the command line // This is often used by apps that launch / act as a proxy for other apps and need to pass options across to them Data = DoubleSplitLoadFunc(args1, switches1, args2, switches2); }
public PyProcessContext CreateSpawnedProcess(string command, string commandArguments, string workingDirectory, dynamic processHandler) { if (workingDirectory == null) { workingDirectory = _workingDirectory; } var cmd = new CmdLineHelper(); cmd.ParseString(commandArguments); return(new PyProcessContext(_scriptContext, processHandler, this._processFactory, command, commandArguments, workingDirectory, cmd)); }
/// <summary> /// Creates a package with the specified Id and Version and uploads it and checks if the upload has suceeded. /// This will be used by test classes which tests scenarios on top of upload. /// </summary> /// <param name="packageId"></param> /// <param name="version"></param> public static void UploadNewPackageAndVerify(string packageId, string version = "1.0.0") { if (string.IsNullOrEmpty(packageId)) { packageId = DateTime.Now.Ticks.ToString(); } string packageFullPath = PackageCreationHelper.CreatePackage(packageId, version); string standardOutput = string.Empty; string standardError = string.Empty; int exitCode = CmdLineHelper.UploadPackage(packageFullPath, UrlHelper.V2FeedPushSourceUrl, out standardOutput, out standardError); Assert.IsTrue((exitCode == 0), "The package upload via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream. Exit Code: " + exitCode + ". Error message: \"" + standardError + "\""); Console.WriteLine(standardOutput); Console.WriteLine(standardError); Assert.IsTrue(ClientSDKHelper.CheckIfPackageVersionExistsInSource(packageId, version, UrlHelper.V2FeedRootUrl), "Package {0} is not found in the site {1} after uploading.", packageId, UrlHelper.V2FeedRootUrl); //Delete package from local disk so once it gets uploaded if (File.Exists(packageFullPath)) { File.Delete(packageFullPath); Directory.Delete(Path.GetFullPath(Path.GetDirectoryName(packageFullPath)), true); } }
/// <summary> Loads the given options into key value pairs. </summary> /// <param name="opts"> The Options to load. </param> /// <returns> The options in key / value pairs </returns> public static Dictionary <string, string> Load(string[] opts) { var data = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); // Get the arguments / switches var args_noswitches = CmdLineHelper.FilterArguments(opts); var switches = CmdLineHelper.FilterSwitches(opts); // Make a note of the configuration file path if there is one if (switches.ContainsKey("cfgfile")) { data["cmdline:cfgfile"] = switches["cfgfile"]; } // If --help is asked for if (switches.ContainsKey("help")) { data["cmdline:showhelp"] = "true"; } return(data); }
public void SearchWebMatrixCuratedFeed() { string packageName = "NuGetGallery.FunctionalTests.SearchWebMatrixCuratedFeed"; string ticks = DateTime.Now.Ticks.ToString(); string version = new System.Version(ticks.Substring(0, 6) + "." + ticks.Substring(6, 6) + "." + ticks.Substring(12, 6)).ToString(); string packageFullPath = PackageCreationHelper.CreateWebMatrixCuratedPackage(packageName, version); int exitCode = CmdLineHelper.UploadPackage(packageFullPath, UrlHelper.V2FeedPushSourceUrl); Assert.IsTrue((exitCode == 0), "The package upload via Nuget.exe didnt suceed properly. Check the logs to see the process error and output stream"); // The feed could update anytime in the next 5 minutes and this test would be considered a success. bool applied = false; for (int i = 0; i < 10 && applied == false; i++) { System.Threading.Thread.Sleep(30000); if (ClientSDKHelper.CheckIfPackageExistsInSource(packageName, UrlHelper.WebMatrixCuratedFeedUrl)) { applied = true; } } Assert.IsTrue(applied, "Package {0} is not found in the site {1} after uploading.", packageName, UrlHelper.WebMatrixCuratedFeedUrl); }
/// <summary> /// Instance method that Runs the program /// </summary> /// <param name="args">The args.</param> public void Run(string[] args) { if (args != null && args.Count() > 0) { #if DEBUG bool debug = false; if (bool.TryParse(ConfigurationManager.AppSettings["AttachToDebugger"], out debug)) { if (debug) { if (!Debugger.IsAttached) { Debugger.Launch(); } Debugger.Break(); } } #endif var cmdLineHelper = new CmdLineHelper(); List<Action> specialCommands = this.MapSpecialCommands(cmdLineHelper); if (specialCommands.Count > 0) { specialCommands.ForEach(a => a()); return; } int reportGenerationQueueId; int.TryParse(args[0], out reportGenerationQueueId); // We catch a generic exception here and handle according to the config file configuration try { var runner = new ProcessRunner(() => //new ReportQueueStatusWCFService() new ReportQueueStatusDBService() ); Console.WriteLine(string.Format("Generating report: {0}", reportGenerationQueueId.ToString())); // Generate Report runner.Run(reportGenerationQueueId); LogMessage("Report Generated."); } catch (Exception ex) { LogMessage(ex.Message); // this will rethrow the error if it needs to AdaptableErrorHandler.AdaptableErrorHandlerInstance.HandleError("Application", "GRP Report Queue Item Process", ex); } } else { LogMessage("Please provide the correct arguments for the Processor."); // this will throw the error if it needs to AdaptableErrorHandler.AdaptableErrorHandlerInstance.HandleError("Application", "GRP Report Queue Item Process", new ApplicationException("Please provide the correct arguments for the Processor.")); } }
public override IEnumerator <WebTestRequest> GetRequestEnumerator() { ExtractHiddenFields defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields(); //Do initial login WebTestRequest logonGet = AssertAndValidationHelper.GetLogonGetRequest(); yield return(logonGet); logonGet = null; WebTestRequest logonPost = AssertAndValidationHelper.GetLogonPostRequest(this); yield return(logonPost); logonPost = null; WebTestRequest uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl); yield return(uploadRequest); uploadRequest = null; // The API key is part of the nuget.config file that is present under the solution dir. string packageId = DateTime.Now.Ticks.ToString(); string packageFullPath = CmdLineHelper.CreatePackage(packageId); WebTestRequest uploadPostRequest = new WebTestRequest(UrlHelper.UploadPageUrl); uploadPostRequest.Method = "POST"; uploadPostRequest.ExpectedResponseUrl = UrlHelper.VerifyUploadPageUrl; FormPostHttpBody uploadPostBody = new FormPostHttpBody(); uploadPostBody.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString()); uploadPostBody.FormPostParameters.Add(new FileUploadParameter("UploadFile", packageFullPath, "application/x-zip-compressed", true)); uploadPostRequest.Body = uploadPostBody; yield return(uploadPostRequest); uploadPostRequest = null; WebTestRequest verifyUploadRequest = new WebTestRequest(UrlHelper.VerifyUploadPageUrl); verifyUploadRequest.ExtractValues += new EventHandler <ExtractionEventArgs>(defaultExtractionRule.Extract); yield return(verifyUploadRequest); verifyUploadRequest = null; WebTestRequest verifyUploadPostRequest = new WebTestRequest(UrlHelper.VerifyUploadPageUrl); verifyUploadPostRequest.Method = "POST"; verifyUploadPostRequest.ExpectedResponseUrl = UrlHelper.GetPackagePageUrl(packageId) + "/1.0.0"; FormPostHttpBody verifyUploadPostRequestBody = new FormPostHttpBody(); verifyUploadPostRequestBody.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString()); verifyUploadPostRequestBody.FormPostParameters.Add("Listed", "true"); verifyUploadPostRequestBody.FormPostParameters.Add("Listed", this.Context["$HIDDEN1.Listed"].ToString()); verifyUploadPostRequest.Body = verifyUploadPostRequestBody; yield return(verifyUploadPostRequest); verifyUploadPostRequest = null; }