public void GivenIHaveTenantOnSiteAsName(string shellName, string hostName, string siteName) { var webApp = Binding <WebAppHosting>(); webApp.Host.Execute(() => { var shellSettings = new ShellSettings { Name = shellName, RequestUrlHost = hostName, State = TenantState.Uninitialized, }; using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { environment.Resolve <IShellSettingsManager>().SaveSettings(shellSettings); } MvcApplication.RestartTenant(shellName); }); webApp.WhenIGoToPathOnHost("Setup", hostName); webApp.WhenIFillIn(TableData( new { name = "SiteName", value = siteName }, new { name = "AdminPassword", value = "6655321" })); webApp.WhenIHit("Finish Setup"); }
public void GivenIHaveATypeWithFieldInPart( string typeName, string fieldType, string fieldName, string partName) { var webApp = Binding <WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var cdm = environment.Resolve <IContentDefinitionManager>(); var contentTypeDefinition = cdm.GetTypeDefinition(typeName); if (contentTypeDefinition == null) { contentTypeDefinition = new ContentTypeDefinition(typeName, typeName); cdm.StoreTypeDefinition(contentTypeDefinition); // We should also create the definition for the part with the same name as the type cdm.AlterPartDefinition(typeName, builder => builder.Attachable()); } var tName = typeName; var pName = partName; var fName = fieldName.ToSafeName(); var fType = fieldType; cdm.AlterTypeDefinition(typeName, cfg => cfg .WithPart(tName) // the part named like the type .WithPart(pName)); // the part we'll attach the field to cdm.AlterPartDefinition(pName, partBuilder => partBuilder .WithField(fName, fieldBuilder => fieldBuilder .OfType(fType) .WithDisplayName(fName))); } }); }
public void GivenIHaveTypeWithPart(string typeName, string partName) { var webApp = Binding <WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var cdm = environment.Resolve <IContentDefinitionManager>(); var contentTypeDefinition = cdm.GetTypeDefinition(typeName); if (contentTypeDefinition == null) { contentTypeDefinition = new ContentTypeDefinition(typeName, typeName); cdm.StoreTypeDefinition(contentTypeDefinition); // We should also create the definition for the part with the same name as the type cdm.AlterPartDefinition(typeName, builder => builder.Attachable()); } // We have to copy the variable like this, because the runtime is unable to // correctly serialize nested actions with parameters from different scopes var tName = typeName; var pName = partName; cdm.AlterTypeDefinition(typeName, cfg => cfg.WithPart(tName).WithPart(pName)); } }); }
public void WhenIHaveARoleWithPermissions(string roleName, string permissions) { var webApp = Binding<WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var roleService = environment.Resolve<IRoleService>(); roleService.CreateRole(roleName); foreach (var permissionName in permissions.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)) { roleService.CreatePermissionForRole(roleName, permissionName); } } }); }
public void GivenIHaveEnabled(string name) { var webApp = Binding <WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var descriptorManager = environment.Resolve <IShellDescriptorManager>(); var descriptor = descriptorManager.GetShellDescriptor(); descriptorManager.UpdateShellDescriptor( descriptor.SerialNumber, descriptor.Features.Concat(new[] { new ShellFeature { Name = name } }), descriptor.Parameters); } }); }
public void GivenIHaveCreatedAUser(string username, string roles) { var webApp = Binding<WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var memberShipService = environment.Resolve<IMembershipService>(); var roleService = environment.Resolve<IRoleService>(); var userRoleRepository = environment.Resolve<IRepository<UserRolesPartRecord>>(); var user = memberShipService.CreateUser(new CreateUserParams(username, "qwerty123!", username + "@foo.com", "", "", true)); foreach (var roleName in roles.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)) { var role = roleService.GetRoleByName(roleName); userRoleRepository.Create(new UserRolesPartRecord { UserId = user.Id, Role = role }); } } }); }
public void DefineDefaultCulture(string cultureName) { var webApp = Binding <WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var orchardServices = environment.Resolve <IOrchardServices>(); var cultureManager = environment.Resolve <ICultureManager>(); var currentCultures = cultureManager.ListCultures(); if (!currentCultures.Contains(cultureName)) { cultureManager.AddCulture(cultureName); } orchardServices.WorkContext.CurrentSite.SiteCulture = cultureName; } }); }
public void UserShouldNotBeAbleToForOthers(string username, string action, string contentType, string otherName) { var webApp = Binding <WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var memberShipService = environment.Resolve <IMembershipService>(); var athorizationService = environment.Resolve <IAuthorizationService>(); var contentManager = environment.Resolve <IContentManager>(); var contentItem = contentManager.Create(contentType); var user = memberShipService.GetUser(username); var otherUser = memberShipService.GetUser(otherName); contentItem.As <ICommonPart>().Owner = otherUser; Assert.That(athorizationService.TryCheckAccess(GetPermissionForAction(action), user, contentItem), Is.False); } }); }
public void GivenIHaveEnabled(string name) { var webApp = Binding <WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var descriptorManager = environment.Resolve <IShellDescriptorManager>(); var descriptor = descriptorManager.GetShellDescriptor(); descriptorManager.UpdateShellDescriptor( descriptor.SerialNumber, descriptor.Features.Concat(new[] { new ShellFeature { Name = name } }), descriptor.Parameters); } // this is needed to force the tenant to restart when a new feature is enabled, // as DefaultOrchardHost maintains this list in a thread context otherwise // and looses the information MvcApplication.RestartTenant("Default"); }); }
public void GivenIHaveAContainableContentType(string name) { var webApp = Binding <WebAppHosting>(); webApp.Host.Execute(() => { using (var environment = MvcApplication.CreateStandaloneEnvironment("Default")) { var cdm = environment.Resolve <IContentDefinitionManager>(); var contentTypeDefinition = new ContentTypeDefinition(name, name); cdm.StoreTypeDefinition(contentTypeDefinition); cdm.AlterTypeDefinition(name, cfg => cfg.WithPart("CommonPart").WithPart("BodyPart").WithPart("TitlePart").WithPart("ContainablePart").Creatable().Draftable()); cdm.AlterTypeDefinition(name, cfg => cfg.WithPart("AutoroutePart", builder => builder .WithSetting("AutorouteSettings.AllowCustomPattern", "true") .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false") .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-list'}]") .WithSetting("AutorouteSettings.DefaultPatternIndex", "0") )); } }); }