diff --git a/src/Orchard.Specs/Bindings/CommandLine.cs b/src/Orchard.Specs/Bindings/CommandLine.cs new file mode 100644 index 000000000..50d0e361e --- /dev/null +++ b/src/Orchard.Specs/Bindings/CommandLine.cs @@ -0,0 +1,34 @@ +using System; +using System.IO; +using System.Linq; +using Orchard.Commands; +using Orchard.Parameters; +using Orchard.Specs.Hosting; +using TechTalk.SpecFlow; + +namespace Orchard.Specs.Bindings { + [Binding] + public class CommandLine : BindingBase { + [When(@"I execute >(.*)")] + public void WhenIExecute(string commandLine) { + var details = new RequestDetails(); + Binding().Host.Execute(() => { + var args = commandLine.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + var parameters = new CommandParametersParser().Parse(args); + var agent = new CommandHostAgent(); + var input = new StringReader(""); + var output = new StringWriter(); + details.StatusCode = agent.RunSingleCommand( + input, + output, + "Default", + parameters.Arguments.ToArray(), + parameters.Switches.ToDictionary(kv => kv.Key, kv => kv.Value)); + details.StatusDescription = details.StatusCode.ToString(); + details.ResponseText = output.ToString(); + }); + + Binding().Details = details; + } + } +} diff --git a/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs b/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs index 423c8980a..605692f79 100644 --- a/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs +++ b/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs @@ -47,7 +47,7 @@ namespace Orchard.Specs.Bindings { descriptor.EnabledFeatures.Concat(new[] { new ShellFeature { Name = name } }), descriptor.Parameters); } - + Trace.WriteLine("This call to Host.Reinitialize should not be needed, eventually"); MvcApplication.Host.Reinitialize_Obsolete(); }); @@ -62,7 +62,30 @@ namespace Orchard.Specs.Bindings { Trace.WriteLine("This call to Host.Reinitialize should not be needed, eventually"); MvcApplication.Host.Reinitialize_Obsolete(); }); + } + [Given(@"I have tenant ""(.*)\"" on ""(.*)\"" as ""(.*)\""")] + public void GivenIHaveTenantOnSiteAsName(string shellName, string hostName, string siteName) { + var webApp = Binding(); + webApp.Host.Execute(() => { + var shellSettings = new ShellSettings { + Name = shellName, + RequestUrlHost = hostName, + State = new TenantState("Uninitialized"), + }; + using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { + environment.Resolve().SaveSettings(shellSettings); + } + MvcApplication.Host.Reinitialize_Obsolete(); + }); + + webApp.WhenIGoToPathOnHost("Setup", hostName); + + webApp.WhenIFillIn(TableData( + new { name = "SiteName", value = siteName }, + new { name = "AdminPassword", value = "6655321" })); + + webApp.WhenIHit("Finish Setup"); } } } diff --git a/src/Orchard.Specs/Bindings/WebAppHosting.cs b/src/Orchard.Specs/Bindings/WebAppHosting.cs index 6b6fa82a5..99e439472 100644 --- a/src/Orchard.Specs/Bindings/WebAppHosting.cs +++ b/src/Orchard.Specs/Bindings/WebAppHosting.cs @@ -30,6 +30,11 @@ namespace Orchard.Specs.Bindings { get { return _webHost; } } + public RequestDetails Details { + get { return _details; } + set { _details = value; } + } + [Given(@"I have a clean site")] public void GivenIHaveACleanSite() { GivenIHaveACleanSiteBasedOn("Orchard.Web"); @@ -122,16 +127,16 @@ namespace Orchard.Specs.Bindings { [When(@"I go to ""(.*)"" on host (.*)")] public void WhenIGoToPathOnHost(string urlPath, string host) { Host.HostName = host; - _details = Host.SendRequest(urlPath); + Details = Host.SendRequest(urlPath); _doc = new HtmlDocument(); - _doc.Load(new StringReader(_details.ResponseText)); + _doc.Load(new StringReader(Details.ResponseText)); } [When(@"I go to ""(.*)""")] public void WhenIGoTo(string urlPath) { - _details = Host.SendRequest(urlPath); + Details = Host.SendRequest(urlPath); _doc = new HtmlDocument(); - _doc.Load(new StringReader(_details.ResponseText)); + _doc.Load(new StringReader(Details.ResponseText)); } [When(@"I follow ""(.*)""")] @@ -153,7 +158,7 @@ namespace Orchard.Specs.Bindings { foreach (var row in table.Rows) { var r = row; var input = inputs.SingleOrDefault(x => x.GetAttributeValue("name", x.GetAttributeValue("id", "")) == r["name"]); - Assert.That(input, Is.Not.Null, "Unable to locate name {0} in page html:\r\n\r\n{1}", r["name"], _details.ResponseText); + Assert.That(input, Is.Not.Null, "Unable to locate name {0} in page html:\r\n\r\n{1}", r["name"], Details.ResponseText); input.Attributes.Add("value", row["value"]); } } @@ -165,21 +170,21 @@ namespace Orchard.Specs.Bindings { .Single(elt => elt.GetAttributeValue("value", null) == submitText); var form = Form.LocateAround(submit); - var urlPath = form.Start.GetAttributeValue("action", _details.UrlPath); + var urlPath = form.Start.GetAttributeValue("action", Details.UrlPath); var inputs = form.Children .SelectMany(elt => elt.DescendantsAndSelf("input")) .GroupBy(elt => elt.GetAttributeValue("name", elt.GetAttributeValue("id", "")), elt => elt.GetAttributeValue("value", "")) .ToDictionary(elt => elt.Key, elt => (IEnumerable)elt); - _details = Host.SendRequest(urlPath, inputs); + Details = Host.SendRequest(urlPath, inputs); _doc = new HtmlDocument(); - _doc.Load(new StringReader(_details.ResponseText)); + _doc.Load(new StringReader(Details.ResponseText)); } [When(@"I am redirected")] public void WhenIAmRedirected() { var urlPath = ""; - if (_details.ResponseHeaders.TryGetValue("Location", out urlPath)) { + if (Details.ResponseHeaders.TryGetValue("Location", out urlPath)) { WhenIGoTo(urlPath); } else { @@ -189,13 +194,13 @@ namespace Orchard.Specs.Bindings { [Then(@"the status should be (.*) (.*)")] public void ThenTheStatusShouldBe(int statusCode, string statusDescription) { - Assert.That(_details.StatusCode, Is.EqualTo(statusCode)); - Assert.That(_details.StatusDescription, Is.EqualTo(statusDescription)); + Assert.That(Details.StatusCode, Is.EqualTo(statusCode)); + Assert.That(Details.StatusDescription, Is.EqualTo(statusDescription)); } [Then(@"I should see ""(.*)""")] public void ThenIShouldSee(string text) { - Assert.That(_details.ResponseText, Is.StringContaining(text)); + Assert.That(Details.ResponseText, Is.StringContaining(text)); } [Then(@"the title contains ""(.*)""")] diff --git a/src/Orchard.Specs/Hosting/Orchard.Web/Config/Diagnostics.config b/src/Orchard.Specs/Hosting/Orchard.Web/Config/Diagnostics.config index f65fef8c7..a44c108d4 100644 --- a/src/Orchard.Specs/Hosting/Orchard.Web/Config/Diagnostics.config +++ b/src/Orchard.Specs/Hosting/Orchard.Web/Config/Diagnostics.config @@ -26,9 +26,6 @@ - - diff --git a/src/Orchard.Specs/Hosting/Orchard.Web/Config/Sites.Default.config b/src/Orchard.Specs/Hosting/Orchard.Web/Config/Sites.config similarity index 100% rename from src/Orchard.Specs/Hosting/Orchard.Web/Config/Sites.Default.config rename to src/Orchard.Specs/Hosting/Orchard.Web/Config/Sites.config diff --git a/src/Orchard.Specs/Hosting/TraceEnabledSessionFactoryBuilder.cs b/src/Orchard.Specs/Hosting/TraceEnabledSessionFactoryBuilder.cs index f05e8a392..cb82f295a 100644 --- a/src/Orchard.Specs/Hosting/TraceEnabledSessionFactoryBuilder.cs +++ b/src/Orchard.Specs/Hosting/TraceEnabledSessionFactoryBuilder.cs @@ -17,7 +17,8 @@ namespace Orchard.Specs.Hosting { } protected override IPersistenceConfigurer GetPersistenceConfigurer(bool createDatabase) { var config = (SQLiteConfiguration)base.GetPersistenceConfigurer(createDatabase); - return config.ShowSql(); + //config.ShowSql(); + return config; } } } diff --git a/src/Orchard.Specs/Hosting/WebHost.cs b/src/Orchard.Specs/Hosting/WebHost.cs index c188f76e7..d834cbe01 100644 --- a/src/Orchard.Specs/Hosting/WebHost.cs +++ b/src/Orchard.Specs/Hosting/WebHost.cs @@ -28,6 +28,7 @@ namespace Orchard.Specs.Hosting { baseDir .ShallowCopy("*.dll", _tempSite.Combine("bin")) + .ShallowCopy("*.exe", _tempSite.Combine("bin")) .ShallowCopy("*.pdb", _tempSite.Combine("bin")); HostName = "localhost"; diff --git a/src/Orchard.Specs/MultiTenancy.feature b/src/Orchard.Specs/MultiTenancy.feature index a32b0ab39..ed5bbed0b 100644 --- a/src/Orchard.Specs/MultiTenancy.feature +++ b/src/Orchard.Specs/MultiTenancy.feature @@ -74,3 +74,11 @@ Scenario: A new tenant runs the setup And I go to "/Default.aspx" Then I should see "

Scott Site

" And I should see "Welcome, admin!" + +Scenario: Listing tenants from command line + Given I have installed Orchard + And I have installed "Orchard.MultiTenancy" + And I have tenant "Alpha" on "example.org" as "New-site-name" + When I execute >orchard tenant list + Then I should see "Name: Alpha" + And I should see "Request Url Host: example.org" diff --git a/src/Orchard.Specs/MultiTenancy.feature.cs b/src/Orchard.Specs/MultiTenancy.feature.cs index 4dd7fc195..701a66ee0 100644 --- a/src/Orchard.Specs/MultiTenancy.feature.cs +++ b/src/Orchard.Specs/MultiTenancy.feature.cs @@ -250,6 +250,29 @@ this.ScenarioSetup(scenarioInfo); testRunner.Then("I should see \"

Scott Site

\""); #line 76 testRunner.And("I should see \"Welcome, admin!\""); +#line hidden + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Listing tenants from command line")] + public virtual void ListingTenantsFromCommandLine() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Listing tenants from command line", ((string[])(null))); +#line 78 +this.ScenarioSetup(scenarioInfo); +#line 79 + testRunner.Given("I have installed Orchard"); +#line 80 + testRunner.And("I have installed \"Orchard.MultiTenancy\""); +#line 81 + testRunner.And("I have tenant \"Alpha\" on \"example.org\" as \"New-site-name\""); +#line 82 + testRunner.When("I execute >tenant list"); +#line 83 + testRunner.Then("I should see \"Name: Alpha\""); +#line 84 + testRunner.And("I should see \"Request Url Host: example.org\""); #line hidden testRunner.CollectScenarioErrors(); } diff --git a/src/Orchard.Specs/Orchard.Specs.csproj b/src/Orchard.Specs/Orchard.Specs.csproj index 96cf0b66b..f6bfdc2d0 100644 --- a/src/Orchard.Specs/Orchard.Specs.csproj +++ b/src/Orchard.Specs/Orchard.Specs.csproj @@ -103,6 +103,7 @@ + @@ -158,7 +159,7 @@ Always - + Always @@ -248,6 +249,10 @@ {2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6} Orchard.Framework + + {33B1BC8D-E292-4972-A363-22056B207156} + Orchard + diff --git a/src/Orchard/Environment/IOrchardHost.cs b/src/Orchard/Environment/IOrchardHost.cs index be434f7a7..314560677 100644 --- a/src/Orchard/Environment/IOrchardHost.cs +++ b/src/Orchard/Environment/IOrchardHost.cs @@ -28,4 +28,5 @@ namespace Orchard.Environment { /// IStandaloneEnvironment CreateStandaloneEnvironment(ShellSettings shellSettings); } + } diff --git a/src/Orchard/Environment/ShellBuilders/ShellContainerFactory.cs b/src/Orchard/Environment/ShellBuilders/ShellContainerFactory.cs index 0cf188489..2db70da88 100644 --- a/src/Orchard/Environment/ShellBuilders/ShellContainerFactory.cs +++ b/src/Orchard/Environment/ShellBuilders/ShellContainerFactory.cs @@ -87,9 +87,13 @@ namespace Orchard.Environment.ShellBuilders { .InjectActionInvoker(); } - var optionalHostConfig = HostingEnvironment.MapPath("~/Config/Sites." + settings.Name + ".config"); - if (File.Exists(optionalHostConfig)) - builder.RegisterModule(new ConfigurationSettingsReader(ConfigurationSettingsReader.DefaultSectionName, optionalHostConfig)); + var optionalShellConfig = HostingEnvironment.MapPath("~/Config/Sites.config"); + if (File.Exists(optionalShellConfig)) + builder.RegisterModule(new ConfigurationSettingsReader(ConfigurationSettingsReader.DefaultSectionName, optionalShellConfig)); + + var optionalShellByNameConfig = HostingEnvironment.MapPath("~/Config/Sites." + settings.Name + ".config"); + if (File.Exists(optionalShellByNameConfig)) + builder.RegisterModule(new ConfigurationSettingsReader(ConfigurationSettingsReader.DefaultSectionName, optionalShellByNameConfig)); }); }