public override bool Execute(KitosContext context) { var commonOrg = context.GetOrganization(TestOrganizations.CommonOrg); var globalAdmin = context.GetGlobalAdmin(); var projectWithName = context.ItProjects.AsNoTracking().FirstOrDefault(x => x.Name == _name); if (projectWithName != null) { Console.Out.WriteLine($"Existing ItProject with name {_name} already exists in the database."); return(false); } var project = ItProjectFactory.Create(_name, commonOrg.Id); var entities = new List <IEntity>(); entities.Add(project); entities.Add(project.GoalStatus); entities.Add(project.Handover); entities.AddRange(project.EconomyYears); entities.ForEach(entity => { entity.ObjectOwner = globalAdmin; entity.LastChangedByUser = globalAdmin; entity.LastChanged = DateTime.Now; }); context.ItProjects.Add(project); context.SaveChanges(); return(true); }
public override bool Execute(KitosContext context) { var commonOrg = context.GetOrganization(TestOrganizations.CommonOrg); var globalAdmin = context.GetGlobalAdmin(); var existing = context.Reports.AsNoTracking().FirstOrDefault(x => x.Name == _name); if (existing != null) { Console.Out.WriteLine($"Existing Report with name {_name} already exists in the database."); return(false); } var entity = new Report() { Name = _name, ObjectOwnerId = globalAdmin.Id, OrganizationId = commonOrg.Id, LastChangedByUserId = globalAdmin.Id, Description = "Test rapport oprettet til accessibility tests" }; context.Reports.Add(entity); context.SaveChanges(); return(true); }
public override bool Execute(KitosContext context) { var globalAdmin = context.GetGlobalAdmin(); var organization = new Organization { Name = _orgName, AccessModifier = AccessModifier.Public, TypeId = _organizationType, ObjectOwnerId = globalAdmin.Id, LastChangedByUserId = globalAdmin.Id, Config = Config.Default(globalAdmin) }; organization.OrgUnits.Add(new OrganizationUnit() { Name = organization.Name, ObjectOwnerId = globalAdmin.Id, LastChangedByUserId = globalAdmin.Id }); context.Organizations.Add(organization); context.SaveChanges(); return(true); }
public override bool Execute(KitosContext context) { var commonOrg = context.GetOrganization(TestOrganizations.CommonOrg); var globalAdmin = context.GetGlobalAdmin(); var systemWithSameName = context.ItContracts.AsNoTracking().FirstOrDefault(x => x.Name == _name); if (systemWithSameName != null) { Console.Out.WriteLine($"Existing ItContract with name {_name} already exists in the database."); return(false); } var itContract = new ItContract { Name = _name, ObjectOwnerId = globalAdmin.Id, OrganizationId = commonOrg.Id, LastChangedByUserId = globalAdmin.Id, }; context.ItContracts.Add(itContract); context.SaveChanges(); return(true); }
/// <summary> /// Adds the default option types which are used for testing. /// </summary> /// <param name="dbContext"></param> /// <returns></returns> public override bool Execute(KitosContext dbContext) { var globalAdmin = dbContext.GetGlobalAdmin(); var ownerId = globalAdmin.Id; //Oversight options dbContext.DataProcessingOversightOptions.Add(BuildOption(new DataProcessingOversightOption(), "Egen kontrol", 0, ownerId)); dbContext.DataProcessingOversightOptions.Add(BuildOption(new DataProcessingOversightOption(), "Ledelseserklæring", 1, ownerId)); dbContext.DataProcessingOversightOptions.Add(BuildOption(new DataProcessingOversightOption(), "ISAE 3000", 2, ownerId)); dbContext.DataProcessingOversightOptions.Add(BuildOption(new DataProcessingOversightOption(), "ISAE 3402 type 1", 3, ownerId)); dbContext.DataProcessingOversightOptions.Add(BuildOption(new DataProcessingOversightOption(), "ISAE 3402 type 2", 4, ownerId)); dbContext.DataProcessingOversightOptions.Add(BuildOption(new DataProcessingOversightOption(), "Skriftlig kontrol", 5, ownerId)); dbContext.DataProcessingOversightOptions.Add(BuildOption(new DataProcessingOversightOption(), "Fysisk tilsyn", 6, ownerId)); //Oversight options dbContext.DataProcessingDataResponsibleOptions.Add(BuildOption(new DataProcessingDataResponsibleOption(), "Leverandøren er databehandler", 0, ownerId, "(Det er vurderet at leverandøren behandler persondata på instruks fra kommunen og der skal indgås en databehandleraftale)")); dbContext.DataProcessingDataResponsibleOptions.Add(BuildOption(new DataProcessingDataResponsibleOption(), "Leverandøren behandler ikke personoplysninger", 1, ownerId, "(Og derfor skal der ikke indgås en databehandleraftale)")); dbContext.DataProcessingDataResponsibleOptions.Add(BuildOption(new DataProcessingDataResponsibleOption(), "Leverandøren er selvstændig dataansvarlig", 2, ownerId, "(Deres anvendelse af data er ikke noget vi har indflydelse på)")); dbContext.DataProcessingDataResponsibleOptions.Add(BuildOption(new DataProcessingDataResponsibleOption(), "Fællesdataansvar ", 3, ownerId, "(Der skal typisk indgås en anden type aftale – fortrolighedserklæring eller…)")); dbContext.DataProcessingDataResponsibleOptions.Add(BuildOption(new DataProcessingDataResponsibleOption(), "Kommunen er selv dataansvarlig", 4, ownerId)); //data transfer options dbContext.DataProcessingBasisForTransferOptions.Add(BuildOption(new DataProcessingBasisForTransferOption(), "EU og EØS", 0, ownerId)); dbContext.DataProcessingBasisForTransferOptions.Add(BuildOption(new DataProcessingBasisForTransferOption(), "EU's standard kontrakt /standard contract clauses", 1, ownerId)); dbContext.DataProcessingBasisForTransferOptions.Add(BuildOption(new DataProcessingBasisForTransferOption(), "Binding corporate rules / BCR", 2, ownerId)); dbContext.DataProcessingBasisForTransferOptions.Add(BuildOption(new DataProcessingBasisForTransferOption(), "Intet", 3, ownerId)); dbContext.DataProcessingBasisForTransferOptions.Add(BuildOption(new DataProcessingBasisForTransferOption(), "Andet", 4, ownerId)); //cointries dbContext.DataProcessingCountryOptions.Add(BuildOption(new DataProcessingCountryOption(), "Danmark", 0, ownerId)); dbContext.DataProcessingCountryOptions.Add(BuildOption(new DataProcessingCountryOption(), "EU", 1, ownerId)); dbContext.SaveChanges(); return(true); }
public override bool Execute(KitosContext context) { var organization = context.GetOrganization(_organizationName); var globalAdmin = context.GetGlobalAdmin(); //Create the new it system var systemWithSameName = GetItSystemnByName(context); if (systemWithSameName != null) { Console.Out.WriteLine($"Existing ITSystem with name {_name} already exists in the database."); return(false); } var itSystem = new ItSystem { Name = _name, ObjectOwnerId = globalAdmin.Id, OrganizationId = organization.Id, LastChangedByUserId = globalAdmin.Id, Uuid = Guid.NewGuid(), ParentId = _parentId }; context.ItSystems.Add(itSystem); context.SaveChanges(); //Enable usage of the system var itSystemUsage = new ItSystemUsage { ItSystemId = itSystem.Id, OrganizationId = organization.Id, ObjectOwnerId = globalAdmin.Id, LastChangedByUserId = globalAdmin.Id }; itSystemUsage.ResponsibleUsage = new ItSystemUsageOrgUnitUsage { ItSystemUsage = itSystemUsage, ItSystemUsageId = itSystemUsage.Id, OrganizationUnit = organization.OrgUnits.First(), OrganizationUnitId = organization.Id }; context.ItSystemUsages.Add(itSystemUsage); context.SaveChanges(); var pendingReadModelUpdate = PendingReadModelUpdate.Create(itSystemUsage, PendingReadModelUpdateSourceCategory.ItSystemUsage); context.PendingReadModelUpdates.Add(pendingReadModelUpdate); context.SaveChanges(); return(true); }
private void AssignOrganizationRole(KitosContext context, User newUser, string orgName) { var globalAdmin = context.GetGlobalAdmin(); var org = context.GetOrganization(orgName); var newRight = new OrganizationRight { UserId = newUser.Id, Role = _role, OrganizationId = org.Id, ObjectOwnerId = globalAdmin.Id, LastChangedByUserId = globalAdmin.Id }; context.OrganizationRights.Add(newRight); context.SaveChanges(); }
public override bool Execute(KitosContext context) { var globalAdmin = context.GetGlobalAdmin(); var sensitiveDataType = new SensitivePersonalDataType() { Name = _name, IsLocallyAvailable = true, IsObligatory = true, IsEnabled = true, LastChanged = DateTime.Now, LastChangedByUserId = globalAdmin.Id }; context.SensitivePersonalDataTypes.Add(sensitiveDataType); context.SaveChanges(); return(true); }
public override bool Execute(KitosContext dbContext) { var commonOrg = dbContext.GetOrganization(TestOrganizations.CommonOrg); var globalAdmin = dbContext.GetGlobalAdmin(); var agreement = new DataProcessingRegistration() { Name = _name, ObjectOwnerId = globalAdmin.Id, OrganizationId = commonOrg.Id, LastChangedByUserId = globalAdmin.Id }; agreement = dbContext.DataProcessingRegistrations.Add(agreement); dbContext.SaveChanges(); var readModel = new DataProcessingRegistrationReadModel(); var update = new DataProcessingRegistrationReadModelUpdate( new GenericRepository <DataProcessingRegistrationRoleAssignmentReadModel>(dbContext), new OptionsService <DataProcessingRegistration, DataProcessingBasisForTransferOption, LocalDataProcessingBasisForTransferOption> ( new GenericRepository <LocalDataProcessingBasisForTransferOption>(dbContext), new GenericRepository <DataProcessingBasisForTransferOption>(dbContext) ), new OptionsService <DataProcessingRegistration, DataProcessingDataResponsibleOption, LocalDataProcessingDataResponsibleOption> ( new GenericRepository <LocalDataProcessingDataResponsibleOption>(dbContext), new GenericRepository <DataProcessingDataResponsibleOption>(dbContext) ), new OptionsService <DataProcessingRegistration, DataProcessingOversightOption, LocalDataProcessingOversightOption> ( new GenericRepository <LocalDataProcessingOversightOption>(dbContext), new GenericRepository <DataProcessingOversightOption>(dbContext) ) ); update.Apply(agreement, readModel); dbContext.DataProcessingRegistrationReadModels.Add(readModel); dbContext.SaveChanges(); return(true); }
public override bool Execute(KitosContext context) { var organization = context.GetOrganization(_organizationName); var globalAdmin = context.GetGlobalAdmin(); var taskRef = new TaskRef() { Uuid = new Guid(), Type = "TestKLEType", TaskKey = "TestKLEKey", Description = "Test task ref", OwnedByOrganizationUnitId = organization.Id, ObjectOwnerId = globalAdmin.Id, LastChanged = DateTime.Now, LastChangedByUserId = globalAdmin.Id }; context.TaskRefs.Add(taskRef); context.SaveChanges(); return(true); }
private User CreateUser(KitosContext context) { var globalAdmin = context.GetGlobalAdmin(); var apiUser = "******"; var newUser = new User { Name = "Automatisk oprettet testbruger", LastName = $"({((_apiAccess) ? apiUser : "")}{_role:G})", Salt = _salt, Email = _email, ObjectOwnerId = globalAdmin.Id, LastChangedByUserId = globalAdmin.Id, IsGlobalAdmin = _role == OrganizationRole.GlobalAdmin, HasApiAccess = _apiAccess }; newUser.SetPassword(_password); context.Users.AddOrUpdate(x => x.Email, newUser); context.SaveChanges(); return(newUser); }