public void DelegateAccessReturnsTokens() { var administrator = new PersonBuilder(this.Session).WithUserName("administrator").Build(); var administrators = new UserGroups(this.Session).Administrators; administrators.AddMember(administrator); var accessClass = new AccessClassBuilder(this.Session).Build(); this.Session.Derive(); this.Session.Commit(); var defaultSecurityToken = new SecurityTokens(this.Session).DefaultSecurityToken; var dstAcs = defaultSecurityToken.AccessControls.Where(v => v.EffectiveUsers.Contains(administrator)); var dstAcs2 = defaultSecurityToken.AccessControls.Where(v => v.SubjectGroups.Contains(administrators)); var acs = new AccessControls(this.Session).Extent().Where(v => v.EffectiveUsers.Contains(administrator)); var acs2 = new AccessControls(this.Session).Extent().Where(v => v.SubjectGroups.Contains(administrators)); var acl = new AccessControlLists(administrator)[accessClass]; Assert.True(acl.CanRead(M.AccessClass.Property)); Assert.True(acl.CanWrite(M.AccessClass.Property)); Assert.True(acl.CanRead(M.AccessClass.Property)); Assert.True(acl.CanWrite(M.AccessClass.Property)); }
public void GivenAWorkspaceAccessControlListsThenAWorkspaceDeniedPermissionsIsNotPresent() { var administrator = new PersonBuilder(this.Session).WithUserName("administrator").Build(); var administrators = new UserGroups(this.Session).Administrators; administrators.AddMember(administrator); this.Session.Derive(); this.Session.Commit(); var workspacePermissions = new Permissions(this.Session).Extent().Where(v => v.OperandType.Equals(M.Person.WorkspaceField)); var workspaceReadPermission = workspacePermissions.First(v => v.Operation == Operations.Read); administrator.AddDeniedPermission(workspaceReadPermission); var workspaceAccessControlLists = new WorkspaceAccessControlLists(administrator); var acl = workspaceAccessControlLists[administrator]; var deniedWorkspacePermissions = acl.DeniedPermissionIds; Assert.Contains(workspaceReadPermission.Id, deniedWorkspacePermissions); }
public static void Setup(IDatabase database, Config config) { CultureInfo.CurrentCulture = new CultureInfo("en-GB"); CultureInfo.CurrentUICulture = new CultureInfo("en-GB"); using (var session = database.CreateSession()) { new Setup(session, config).Apply(); var administrator = new PersonBuilder(session).WithUserName("administrator").Build(); new UserGroups(session).Administrators.AddMember(administrator); session.SetUser(administrator); session.Derive(); session.Commit(); var singleton = session.GetSingleton(); var belgium = new Countries(session).CountryByIsoCode["BE"]; var euro = belgium.Currency; var bank = new BankBuilder(session).WithCountry(belgium).WithName("ING Belgiƫ").WithBic("BBRUBEBB").Build(); var ownBankAccount = new OwnBankAccountBuilder(session) .WithBankAccount(new BankAccountBuilder(session).WithBank(bank) .WithCurrency(euro) .WithIban("BE68539007547034") .WithNameOnAccount("Koen") .Build()) .WithDescription("Main bank account") .Build(); var postalAddress = new PostalAddressBuilder(session) .WithAddress1("Kleine Nieuwedijkstraat 2") .WithLocality("Mechelen") .WithCountry(belgium) .Build(); var internalOrganisation = new OrganisationBuilder(session) .WithIsInternalOrganisation(true) .WithDoAccounting(false) .WithName("internalOrganisation") .WithPreferredCurrency(new Currencies(session).CurrencyByCode["EUR"]) .WithIncomingShipmentNumberPrefix("incoming shipmentno: ") .WithPurchaseInvoiceNumberPrefix("incoming invoiceno: ") .WithPurchaseOrderNumberPrefix("purchase orderno: ") .WithDefaultCollectionMethod(ownBankAccount) .WithSubAccountCounter(new CounterBuilder(session).WithUniqueId(Guid.NewGuid()).WithValue(0).Build()) .Build(); internalOrganisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(session) .WithUseAsDefault(true) .WithContactMechanism(postalAddress) .WithContactPurpose(new ContactMechanismPurposes(session).GeneralCorrespondence) .WithContactPurpose(new ContactMechanismPurposes(session).BillingAddress) .WithContactPurpose(new ContactMechanismPurposes(session).ShippingAddress) .Build()); var facility = new FacilityBuilder(session) .WithFacilityType(new FacilityTypes(session).Warehouse) .WithName("facility") .WithOwner(internalOrganisation) .Build(); singleton.Settings.DefaultFacility = facility; var collectionMethod = new PaymentMethods(session).Extent().First; new StoreBuilder(session) .WithName("store") .WithBillingProcess(new BillingProcesses(session).BillingForShipmentItems) .WithInternalOrganisation(internalOrganisation) .WithOutgoingShipmentNumberPrefix("shipmentno: ") .WithSalesInvoiceNumberPrefix("invoiceno: ") .WithSalesOrderNumberPrefix("orderno: ") .WithDefaultShipmentMethod(new ShipmentMethods(session).Ground) .WithDefaultCarrier(new Carriers(session).Fedex) .WithCreditLimit(500) .WithPaymentGracePeriod(10) .WithDefaultCollectionMethod(collectionMethod) .WithIsImmediatelyPicked(false) .WithAutoGenerateShipmentPackage(false) .WithIsImmediatelyPacked(true) .Build(); new ProductCategoryBuilder(session).WithName("Primary Category").Build(); internalOrganisation.CreateB2BCustomer(session.Faker()); internalOrganisation.CreateB2CCustomer(session.Faker()); internalOrganisation.CreateSupplier(session.Faker()); internalOrganisation.CreateSubContractor(session.Faker()); var purchaser = new PersonBuilder(session).WithFirstName("The").WithLastName("purchaser").WithUserName("purchaser").Build(); var orderProcessor = new PersonBuilder(session).WithFirstName("The").WithLastName("orderProcessor").WithUserName("orderProcessor").Build(); // Adding newly created persons to EmployeeUserGroup as employees do not have any permission when created var employeesUserGroup = new UserGroups(session).Employees; employeesUserGroup.AddMember(purchaser); employeesUserGroup.AddMember(orderProcessor); employeesUserGroup.AddMember(administrator); new UserGroups(session).Creators.AddMember(purchaser); new UserGroups(session).Creators.AddMember(orderProcessor); new UserGroups(session).Creators.AddMember(administrator); new EmploymentBuilder(session).WithFromDate(session.Now()).WithEmployee(purchaser).WithEmployer(internalOrganisation).Build(); new EmploymentBuilder(session).WithFromDate(session.Now()).WithEmployee(orderProcessor).WithEmployer(internalOrganisation).Build(); var good1 = new NonUnifiedGoodBuilder(session) .WithProductIdentification(new ProductNumberBuilder(session) .WithIdentification("1") .WithProductIdentificationType(new ProductIdentificationTypes(session).Good).Build()) .WithName("good1") .WithUnitOfMeasure(new UnitsOfMeasure(session).Piece) .WithPart(new NonUnifiedPartBuilder(session) .WithProductIdentification(new PartNumberBuilder(session) .WithIdentification("1") .WithProductIdentificationType(new ProductIdentificationTypes(session).Part).Build()) .WithInventoryItemKind(new InventoryItemKinds(session).NonSerialised).Build()) .Build(); var good2 = new NonUnifiedGoodBuilder(session) .WithProductIdentification(new ProductNumberBuilder(session) .WithIdentification("2") .WithProductIdentificationType(new ProductIdentificationTypes(session).Good).Build()) .WithName("good2") .WithUnitOfMeasure(new UnitsOfMeasure(session).Piece) .WithPart(new NonUnifiedPartBuilder(session) .WithProductIdentification(new PartNumberBuilder(session) .WithIdentification("2") .WithProductIdentificationType(new ProductIdentificationTypes(session).Part).Build()) .WithInventoryItemKind(new InventoryItemKinds(session).NonSerialised).Build()) .Build(); var good3 = new NonUnifiedGoodBuilder(session) .WithProductIdentification(new ProductNumberBuilder(session) .WithIdentification("3") .WithProductIdentificationType(new ProductIdentificationTypes(session).Good).Build()) .WithName("good3") .WithUnitOfMeasure(new UnitsOfMeasure(session).Piece) .WithPart(new NonUnifiedPartBuilder(session) .WithProductIdentification(new PartNumberBuilder(session) .WithIdentification("3") .WithProductIdentificationType(new ProductIdentificationTypes(session).Part).Build()) .WithInventoryItemKind(new InventoryItemKinds(session).NonSerialised).Build()) .Build(); var catMain = new ProductCategoryBuilder(session).WithName("main cat").Build(); var cat1 = new ProductCategoryBuilder(session) .WithName("cat for good1") .WithPrimaryParent(catMain) .WithProduct(good1) .Build(); var cat2 = new ProductCategoryBuilder(session) .WithName("cat for good2") .WithPrimaryParent(catMain) .WithProduct(good2) .WithProduct(good3) .Build(); session.Derive(); session.Commit(); } }
public void SetUp() { var configuration = new Configuration { ObjectFactory = Config.ObjectFactory }; Config.Default = new Database(configuration); Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); var database = Config.Default; database.Init(); using (var session = database.CreateSession()) { try { new Setup(session, null).Apply(); session.Commit(); using (var stringWriter = new StringWriter()) { using (var writer = new XmlTextWriter(stringWriter)) { database.Save(writer); MinimalXml = stringWriter.ToString(); } } var singleton = Singleton.Instance(session); singleton.Guest = new PersonBuilder(session) .WithUserName(Users.GuestUserName) .WithLastName("Guest") .WithCreationDate(DateTime.MinValue) .WithLastModifiedDate(DateTime.UtcNow) .Build(); singleton.DefaultLocale = new Locales(session).FindBy(Locales.Meta.Name, "nl-NL"); var administrator = new PersonBuilder(session) .WithUserName(Users.AdministratorUserName) .WithLastName("Administrator") .WithCreationDate(DateTime.MinValue) .WithLastModifiedDate(DateTime.UtcNow) .Build(); session.Derive(true); var administrators = new UserGroups(session).Administrators; administrators.AddMember(administrator); session.Derive(true); session.Commit(); using (var stringWriter = new StringWriter()) { using (var writer = new XmlTextWriter(stringWriter)) { database.Save(writer); DefaultXml = stringWriter.ToString(); } } } catch (Exception e) { Debug.WriteLine(e.StackTrace); throw; } } }
private void CustomOnPostSetup() { var passwordService = this.session.ServiceProvider.GetRequiredService <IPasswordService>(); var jane = new PersonBuilder(this.session) .WithUserEmail("*****@*****.**") .WithUserName("*****@*****.**") .WithFirstName("Jane") .WithMiddleName("Joanne") .WithLastName("Doe") .WithAddress(new AddressBuilder(this.session).WithCity("Mechelen").Build()) .Build(); var jenny = new PersonBuilder(this.session) .WithUserEmail("*****@*****.**") .WithUserName("*****@*****.**") .WithFirstName("Jenny") .WithLastName("Doe") .WithAddress(new AddressBuilder(this.session).WithCity("Antwerp").Build()) .Build(); var john = new PersonBuilder(this.session) .WithUserEmail("*****@*****.**") .WithUserName("*****@*****.**") .WithFirstName("John") .WithLastName("Doe") .WithAddress(new AddressBuilder(this.session).WithCity("Brussels").Build()) .Build(); var jubayer = new PersonBuilder(this.session) .WithUserEmail("*****@*****.**") .WithUserName("*****@*****.**") .WithFirstName("Sharif") .WithMiddleName("Jubayer") .WithLastName("Arefin") .WithAddress(new AddressBuilder(this.session).WithCity("Dhaka").Build()) .WithCalendar( //Setup Calendar new CalendarBuilder(this.session) .WithScheduleStart( DateTimeFactory.CreateDateTime(2019, 9, 25, 9, 0, 0, 0) ) .WithScheduleEnd( DateTimeFactory.CreateDateTime(2019, 9, 25, 20, 0, 0, 0) ) //Setup GymMembership .WithGymMembership( new GymMembershipBuilder(this.session) .WithName("Gold's GYM") .WithStartTime( DateTimeFactory.CreateDateTime(2019, 9, 25, 18, 30, 0, 0) ) .WithEndTime( DateTimeFactory.CreateDateTime(2019, 9, 25, 20, 0, 0, 0) ) .WithAddress(new AddressBuilder(this.session).WithCity("Cox's Bazaar").Build()) .Build() ) //Setup Work .WithWork( new WorkBuilder(this.session) .WithName("Allors") .WithStartTime( DateTimeFactory.CreateDateTime(2019, 9, 25, 9, 0, 0, 0) ) .WithEndTime( DateTimeFactory.CreateDateTime(2019, 9, 25, 18, 0, 0, 0) ) .WithAddress(new AddressBuilder(this.session).WithCity("Cox's Bazaar").Build()) .Build() ) .Build() ) .Build(); jane.UserPasswordHash = passwordService.HashPassword(jane.UserName, "jane"); jenny.UserPasswordHash = passwordService.HashPassword(jenny.UserName, "jenny"); john.UserPasswordHash = passwordService.HashPassword(john.UserName, "john"); jubayer.UserPasswordHash = passwordService.HashPassword(jubayer.UserName, "jubayer"); var administrators = new UserGroups(this.session).Administrators; var creators = new UserGroups(this.session).Creators; var employees = new UserGroups(this.session).Employees; administrators.AddMember(jane); administrators.AddMember(jubayer); creators.AddMember(jane); creators.AddMember(jenny); creators.AddMember(john); creators.AddMember(jubayer); employees.AddMember(jane); employees.AddMember(jenny); }