public void CommandLineArgs() { var app = new ConsoleApplicationBase(); var expected = System.Environment.GetCommandLineArgs().Skip(1).ToArray(); Assert.Equal(expected, app.CommandLineArgs); }
public void UmbracoFieldOverriddenOnLogin() { var application = new ConsoleApplicationBase(); application.Start(application, new EventArgs()); var context = ApplicationContext.Current; CreateFieldMappings(context.DatabaseContext.Database); CreateMemberTypesIfRequired(context); CanRegisterAndLoginToCms(); var memberService = context.Services.MemberService; var member = memberService.GetByEmail(_newEmail); Assert.IsNotNull(member, "Member not found in Umbraco after creation"); // update member with some random crap so we can check it is updated correctly member.SetValue(_umbracoFirstName, "laksjdfasjdflasjdklfajslkdf"); member.SetValue(_umbracoLastName, "lskdjfskldf"); memberService.Save(member); var logoutButton = _driver.FindElement(By.ClassName("gigya-logout"), 10); Assert.IsNotNull(logoutButton, "Logout button not found. User should be logged in."); logoutButton.Click(); CanLoginToFrontEnd(); member = memberService.GetByEmail(_newEmail); Assert.IsNotNull(member, "Member not found in Umbraco after creation"); // check fields have been updated Assert.AreEqual(_firstName, member.GetValue("firstName"), "First name not mapped"); Assert.AreEqual(_lastName, member.GetValue("lastName"), "Last name not mapped"); }
public void Umbraco_IsLoggedOutOfGigyaAfterTimeout_UmbracoSessionProvider() { SetFormsTimeout(1); // configure web.config timeout to using (var application = new ConsoleApplicationBase()) { application.Start(application, new EventArgs()); var context = ApplicationContext.Current; var db = context.DatabaseContext.Database; var sql = "UPDATE gigya_settings SET SessionProvider = 1, GlobalParameters = '{ \"sessionExpiration\": 100 }'"; var settings = db.ExecuteScalar <GigyaUmbracoModuleSettings>(sql); // login to CMS CanRegisterAndLoginToCms(); // wait 70 secs Thread.Sleep(70000); _driver.Navigate().Refresh(); Thread.Sleep(5000); // check that user is logged out of Gigya var cookies = _driver.Manage().Cookies.AllCookies; if (cookies.Any(i => i.Name.StartsWith("glt"))) { Assert.Fail("Found Gigya cookie starting with glt. User should be logged out of Gigya"); } Thread.Sleep(5000); } }
public void Initialise(ConsoleApplicationBase app, MethodParameterInjector injector, CommandLineInterpreterConfiguration config, Dictionary<Type, ICommandHandler> handlers) { _app = app; _injector = injector; _config = config; _handlers = handlers; }
public void Umbraco_IsLoggedIntoGigyaAfterTimeout_UmbracoSessionProvider() { SetFormsTimeout(1); // configure web.config timeout to using (var application = new ConsoleApplicationBase()) { application.Start(application, new EventArgs()); var context = ApplicationContext.Current; var db = context.DatabaseContext.Database; var sql = "UPDATE gigya_settings SET SessionProvider = 1, GlobalParameters = '{ \"sessionExpiration\": 10 }'"; var settings = db.ExecuteScalar <GigyaUmbracoModuleSettings>(sql); // login to CMS CanRegisterAndLoginToCms(); // wait 11 secs Thread.Sleep(11000); _driver.Navigate().Refresh(); //Thread.Sleep(5000); // check that user is logged into Gigya var cookies = _driver.Manage().Cookies.AllCookies; if (!cookies.Any(i => i.Name.StartsWith("glt_3_qkAT5OcGyvYpkjc_VF6-OfoeTKGk4T_jVwjFF9f5TQzoAg-mH8SBsjQi1srdsOm6"))) { Assert.Fail("Failed to find Gigya cookie starting with glt"); } Thread.Sleep(5000); } }
public InteractiveSession(ConsoleApplicationBase app, MethodParameterInjector injector, Dictionary<Type, ICommandHandler> handlers, IConsoleAdapter console, IErrorAdapter error, CommandLineInterpreterConfiguration config) { _app = app; _injector = injector; _handlers = handlers; _console = console; _error = error; _config = config; _interpreter = new CommandLineInterpreter(_config); }
public void Umbraco_IsSessionExpiredCorrectly() { using (var application = new ConsoleApplicationBase()) { application.Start(application, new EventArgs()); var context = ApplicationContext.Current; var db = context.DatabaseContext.Database; var sql = "SELECT * FROM gigya_settings"; var settings = db.Fetch <GigyaUmbracoModuleSettings>(sql); var currentGlobalSettings = settings.Select(i => i.GlobalParameters).ToList(); // update all to 10 seconds foreach (var setting in settings) { setting.GlobalParameters = "{ \"sessionExpiration\": 10 }"; db.Save(setting); } var reset = false; try { // test session expiration works now that we know all sites are using 10 second timeout CanRegisterAndLoginToCms(); IsLoggedIntoSecondSiteAsWell(); _driver.Navigate().GoToUrl(Config.Site1BaseURL); // wait for session to expire Thread.Sleep(11000); HasSessionExpired(); // check logged out of site 2 as well _driver.Navigate().GoToUrl(Config.Site2BaseURL); HasSessionExpired(); // login again CanLoginToFrontEnd(); ResetSettings(db, settings, currentGlobalSettings); reset = true; } catch { if (!reset) { ResetSettings(db, settings, currentGlobalSettings); } throw; } } }
public void Umbraco_CanUpdateProfile() { using (var application = new ConsoleApplicationBase()) { application.Start(application, new EventArgs()); var context = ApplicationContext.Current; //CreateMemberTypesIfRequired(context); //CreateFieldMappings(context.DatabaseContext.Database); CanRegisterAndLoginToCms(); var button = _driver.FindElement(By.CssSelector(".gigya-edit-profile"), 10); if (button != null) { button.Click(); } // wait for form var form = _driver.FindElement(By.Id("gigya-profile-form"), 5); form.FindElement(By.Name("profile.firstName")).ClearAndSendKeys(_updatedFirstName); form.FindElement(By.Name("profile.lastName")).ClearAndSendKeys(_updatedLastName); form.FindElement(By.Name("profile.email")).ClearAndSendKeys(_newEmail); // set DOB var age = 50; var dob = DateTime.Now.AddYears(age * -1); form.FindElement(By.Name("profile.birthDay")).SendKeys(dob.Day.ToString()); form.FindElement(By.Name("profile.birthMonth")).SendKeys(dob.Month.ToString()); form.FindElement(By.Name("profile.birthYear")).SendKeys(dob.Year.ToString()); // save profile form.FindElement(By.CssSelector("input.gigya-input-submit")).Click(); // wait for profile update Thread.Sleep(5000); var memberService = context.Services.MemberService; var member = memberService.GetByEmail(_newEmail); Assert.IsNotNull(member, "Member not found in Umbraco after creation"); // check fields are mapped Assert.IsTrue(member.HasProperty(_umbracoFirstName), "Member not configured with firstName property. Check setup."); Assert.AreEqual(_updatedFirstName, member.GetValue(_umbracoFirstName), "First name not mapped"); Assert.IsTrue(member.HasProperty(_umbracoLastName), "Member not configured with lastName property. Check setup."); Assert.AreEqual(_updatedLastName, member.GetValue(_umbracoLastName), "Last name not mapped"); Assert.IsTrue(member.HasProperty(_umbracoAge), "Member not configured with age property. Check setup."); Assert.AreEqual(age, Convert.ToInt32(member.GetValue(_umbracoAge)), "Age not mapped"); } }
internal void Execute(ConsoleApplicationBase app, object command, MethodParameterInjector injector) { try { var parameters = injector.GetParameters(_method, new[] { command }); MethodInvoker.Invoke(_method, app, parameters); } catch (Exception e) { Toolkit.HandleException(e, command, injector); } }
public void Execute(ConsoleApplicationBase app, object command, IConsoleAdapter console, MethodParameterInjector injector, CommandExecutionMode executionMode) { var parameter = _parameterGetter == null || command == null ? String.Empty : _parameterGetter(command); if (String.IsNullOrWhiteSpace(parameter)) { CommandDescriber.Describe(_config, console, DefaultApplicationNameExtractor.Extract(app.GetType()), executionMode, Adorner); } else { var chosenCommand = _config.Commands.FirstOrDefault(c => String.CompareOrdinal(c.Name, parameter) == 0); if (chosenCommand == null) { console.WrapLine(@"The command ""{0}"" is not supported."); } else { CommandDescriber.Describe(chosenCommand, console, executionMode, Adorner); } } }
public override void Execute(ConsoleApplicationBase consoleApplication, IList <ArgumentInfo> args) { var options = from arg in args where arg.Type == ArgumentType.Option select arg; if (options.Count() < 1 || string.IsNullOrEmpty(ProjectName)) { consoleApplication.PrintHelpMessage(); return; } if (!NoLogo) { consoleApplication.PrintLogo(); } Console.WriteLine("Starting Tree Generation{0}", Environment.NewLine); Console.WriteLine(" Project Name: \"{0}\"", ProjectName); Console.WriteLine(" Version: \"{0}\"", Version); Console.WriteLine("Unit Test Framework: \"{0}\"", UnitTestFramework); Console.WriteLine(); var frontEnd = new TreeSurgeonFrontEnd(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Version); if (Overwrite) { Directory.Delete(frontEnd.GetOutputPath(ProjectName), true); } var outputDirectory = frontEnd.GenerateDevelopmentTree(ProjectName, UnitTestFramework); Console.WriteLine("Tree Generation complete.{0}{0}Files can be found at:{0}\"{1}\"", Environment.NewLine, outputDirectory); }
public void IsUserLoggedInAfterUmbracoSessionExpired() { XmlDocument webConfigDoc = new XmlDocument(); webConfigDoc.Load(Path.Combine(Config.UmbracoRootPath, "web.config")); // update session timeout in web.config var sessionElem = webConfigDoc.SelectSingleNode("/configuration/system.web/sessionState"); if (sessionElem == null) { sessionElem = webConfigDoc.CreateElement("sessionState"); webConfigDoc.SelectSingleNode("/configuration/system.web").AppendChild(sessionElem); } var timeoutAttribute = sessionElem.Attributes["timeout"]; if (timeoutAttribute == null) { timeoutAttribute = webConfigDoc.CreateAttribute("timeout"); sessionElem.Attributes.Append(timeoutAttribute); } timeoutAttribute.Value = "1"; // update forms timeout in web.config var formsElem = webConfigDoc.SelectSingleNode("/configuration/system.web/authentication/forms"); var formsTimeoutAttribute = formsElem.Attributes["timeout"]; if (formsTimeoutAttribute == null) { formsTimeoutAttribute = webConfigDoc.CreateAttribute("timeout"); formsElem.Attributes.Append(formsTimeoutAttribute); } formsTimeoutAttribute.Value = "1"; timeoutAttribute.Value = "1"; webConfigDoc.Save(Path.Combine(Config.UmbracoRootPath, "web.config")); var application = new ConsoleApplicationBase(); application.Start(application, new EventArgs()); var context = ApplicationContext.Current; var db = context.DatabaseContext.Database; var sql = "SELECT * FROM gigya_settings"; var settings = db.Fetch <GigyaUmbracoModuleSettings>(sql); var currentGlobalSettings = settings.Select(i => i.GlobalParameters).ToList(); // update all to 80 seconds foreach (var setting in settings) { setting.GlobalParameters = "{ \"sessionExpiration\": 500 }"; db.Save(setting); } var reset = false; try { // test session expiration works now that we know all sites are using 10 second timeout CanRegisterAndLoginToCms(); IsLoggedIntoSecondSiteAsWell(); _driver.Navigate().GoToUrl(Config.Site1BaseURL); // wait for umbraco session to expire Thread.Sleep(70000); // refresh page and should now be logged out as umbraco session is set to 1 min _driver.Navigate().Refresh(); // user should now be logged out var loginButton = _driver.FindElement(By.ClassName("gigya-login"), 10); Assert.IsNotNull(loginButton, "Login button not found. User should be logged out."); Thread.Sleep(5000); // refresh page and should now be logged in as gigya session timeout is more than umbraco _driver.Navigate().Refresh(); var logoutButton = _driver.FindElement(By.ClassName("gigya-logout"), 10); Assert.IsNotNull(logoutButton, "Logout button not found. User should be logged in."); ResetSettings(db, settings, currentGlobalSettings); // reset formsTimeoutAttribute.Value = "30"; timeoutAttribute.Value = "30"; webConfigDoc.Save(Path.Combine(Config.UmbracoRootPath, "web.config")); reset = true; } catch { if (!reset) { ResetSettings(db, settings, currentGlobalSettings); // reset formsTimeoutAttribute.Value = "30"; timeoutAttribute.Value = "30"; webConfigDoc.Save(Path.Combine(Config.UmbracoRootPath, "web.config")); } throw; } }
public override void Execute(ConsoleApplicationBase consoleApplication, IList <ArgumentInfo> args) { consoleApplication.PrintHelpMessage(); }
public void Execute(ConsoleApplicationBase app, object command, IConsoleAdapter console, MethodParameterInjector injector, CommandExecutionMode executionMode) { try { var parameters = injector.GetParameters(_method, new[] { command }); MethodInvoker.Invoke(_method, command, parameters); } catch (Exception e) { Toolkit.HandleException(e, command, injector); } }
public void Execute(ConsoleApplicationBase app, object command, IConsoleAdapter console, MethodParameterInjector injector, CommandExecutionMode executionMode) { Execute(app, command, injector); }
public void Umbraco_IsUserLoggedInAfterSessionExpired() { SetFormsTimeout(1); using (var application = new ConsoleApplicationBase()) { application.Start(application, new EventArgs()); var context = ApplicationContext.Current; var db = context.DatabaseContext.Database; var sql = "SELECT * FROM gigya_settings"; var settings = db.Fetch <GigyaUmbracoModuleSettings>(sql); var currentGlobalSettings = settings.Select(i => i.GlobalParameters).ToList(); // update all to 500 seconds foreach (var setting in settings) { setting.GlobalParameters = "{ \"sessionExpiration\": 500 }"; db.Save(setting); } var reset = false; try { // test session expiration works now that we know all sites are using 500 second timeout CanRegisterAndLoginToCms(); IsLoggedIntoSecondSiteAsWell(); _driver.Navigate().GoToUrl(Config.Site1BaseURL); // wait for umbraco session to expire Thread.Sleep(70000); // refresh page and should now be logged out as umbraco session is set to 1 min _driver.Navigate().Refresh(); // user should now be logged out var loginButton = _driver.FindElement(By.ClassName("gigya-login"), 10); Assert.IsNotNull(loginButton, "Login button not found. User should be logged out."); Thread.Sleep(5000); // refresh page and should now be logged in as gigya session timeout is more than umbraco _driver.Navigate().Refresh(); var logoutButton = _driver.FindElement(By.ClassName("gigya-logout"), 10); Assert.IsNotNull(logoutButton, "Logout button not found. User should be logged in."); ResetSettings(db, settings, currentGlobalSettings); // reset SetFormsTimeout(30); reset = true; } catch { if (!reset) { ResetSettings(db, settings, currentGlobalSettings); // reset SetFormsTimeout(30); } throw; } } Thread.Sleep(5000); }