public async Task Can_Assign_SubDataProcessors() { //Arrange const int organizationId = TestEnvironment.DefaultOrganizationId; var organization = await OrganizationHelper.CreateOrganizationAsync(organizationId, A <string>(), "87654321", OrganizationTypeKeys.Virksomhed, AccessModifier.Public); var registration = await DataProcessingRegistrationHelper.CreateAsync(organizationId, A <string>()); using var setStateRequest = await DataProcessingRegistrationHelper.SendSetUseSubDataProcessorsStateRequestAsync(registration.Id, YesNoUndecidedOption.Yes); Assert.Equal(HttpStatusCode.OK, setStateRequest.StatusCode); //Act using var assignResponse = await DataProcessingRegistrationHelper.SendAssignSubDataProcessorRequestAsync(registration.Id, organization.Id); using var duplicateResponse = await DataProcessingRegistrationHelper.SendAssignSubDataProcessorRequestAsync(registration.Id, organization.Id); //Assert Assert.Equal(HttpStatusCode.OK, assignResponse.StatusCode); Assert.Equal(HttpStatusCode.Conflict, duplicateResponse.StatusCode); var dto = await DataProcessingRegistrationHelper.GetAsync(registration.Id); var processor = Assert.Single(dto.SubDataProcessors); Assert.Equal(organization.Id, processor.Id); Assert.Equal(organization.Name, processor.Name); Assert.Equal(organization.Cvr, processor.CvrNumber); }
private async Task <Organization> CreateOrganizationAsync() { var organizationName = CreateName(); var organization = await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, organizationName, "11224455", OrganizationTypeKeys.Virksomhed, AccessModifier.Public); return(organization); }
public async Task Can_Get_Available_SubDataProcessors() { //Arrange const int organizationId = TestEnvironment.DefaultOrganizationId; var orgPrefix = A <string>(); var orgName = $"{orgPrefix}_{A<int>()}"; var organization = await OrganizationHelper.CreateOrganizationAsync(organizationId, orgName, "87654321", OrganizationTypeKeys.Virksomhed, AccessModifier.Public); var registration = await DataProcessingRegistrationHelper.CreateAsync(organizationId, A <string>()); //Act var processors = await DataProcessingRegistrationHelper.GetAvailableSubDataProcessors(registration.Id, orgPrefix); //Assert Assert.Contains(processors, x => x.Id == organization.Id); }
public async Task Can_Create_Organization_Of_Type(OrganizationRole role, OrganizationTypeKeys organizationType) { //Arrange var login = await HttpApi.GetCookieAsync(role); var name = A <string>(); var cvr = (A <int>() % 9999999999).ToString("D10"); const AccessModifier accessModifier = AccessModifier.Public; //Act - perform the action with the actual role var result = await OrganizationHelper.CreateOrganizationAsync(TestEnvironment.DefaultOrganizationId, name, cvr, organizationType, accessModifier, login); //Assert Assert.Equal(accessModifier, result.AccessModifier); Assert.Equal(name, (string)result.Name); Assert.Equal(cvr, (string)result.Cvr); }
public async Task Can_Remove_DataProcessors() { //Arrange const int organizationId = TestEnvironment.DefaultOrganizationId; var organization = await OrganizationHelper.CreateOrganizationAsync(organizationId, A <string>(), "87654321", OrganizationTypeKeys.Virksomhed, AccessModifier.Public); var registration = await DataProcessingRegistrationHelper.CreateAsync(organizationId, A <string>()); using var assignResponse = await DataProcessingRegistrationHelper.SendAssignDataProcessorRequestAsync(registration.Id, organization.Id); //Act using var removeResponse = await DataProcessingRegistrationHelper.SendRemoveDataProcessorRequestAsync(registration.Id, organization.Id); //Assert Assert.Equal(HttpStatusCode.OK, removeResponse.StatusCode); var dto = await DataProcessingRegistrationHelper.GetAsync(registration.Id); Assert.Empty(dto.DataProcessors); }
public async Task ReadModels_Contain_Correct_Content() { //Arrange var name = A <string>(); var dpName = $"Dp:{name}"; var subDpName = $"Sub_Dp:{name}"; var systemName = $"SYSTEM:{name}"; var contractName = $"CONTRACT:{name}"; var refName = $"REF:{name}"; var refUserAssignedId = $"REF:{name}EXT_ID"; var refUrl = $"https://www.test-rm{A<uint>()}.dk"; var refDisp = A <Display>(); var organizationId = TestEnvironment.DefaultOrganizationId; var isAgreementConcluded = A <YesNoIrrelevantOption>(); var oversightInterval = A <YearMonthIntervalOption>(); var oversightCompleted = A <YesNoUndecidedOption>(); var oversightDate = A <DateTime>(); var oversightRemark = A <string>(); Console.Out.WriteLine($"Testing in the context of DPR with name:{name}"); var dataProcessor = await OrganizationHelper.CreateOrganizationAsync(organizationId, dpName, "22334455", OrganizationTypeKeys.Virksomhed, AccessModifier.Public); var subDataProcessor = await OrganizationHelper.CreateOrganizationAsync(organizationId, subDpName, "22314455", OrganizationTypeKeys.Virksomhed, AccessModifier.Public); var registration = await DataProcessingRegistrationHelper.CreateAsync(organizationId, name); await DataProcessingRegistrationHelper.SendChangeOversightIntervalOptionRequestAsync(registration.Id, oversightInterval); await DataProcessingRegistrationHelper.SendChangeIsOversightCompletedRequestAsync(registration.Id, oversightCompleted); var businessRoleDtos = await DataProcessingRegistrationHelper.GetAvailableRolesAsync(registration.Id); var role = businessRoleDtos.First(); var availableUsers = await DataProcessingRegistrationHelper.GetAvailableUsersAsync(registration.Id, role.Id); var user = availableUsers.First(); _testOutputHelper.WriteLine($"Attempting to assign user {user.Id}:{user.Email} as role {role.Id}:{role.Name} in dpr {registration.Id}:{registration.Name}"); using var response = await DataProcessingRegistrationHelper.SendAssignRoleRequestAsync(registration.Id, role.Id, user.Id); Assert.Equal(HttpStatusCode.OK, response.StatusCode); //Basis for transfer var options = (await DataProcessingRegistrationHelper.GetBasisForTransferOptionsAsync(TestEnvironment.DefaultOrganizationId)).ToList(); var basisForTransfer = options[Math.Abs(A <int>()) % options.Count]; using var assignResponse = await DataProcessingRegistrationHelper.SendAssignBasisForTransferRequestAsync(registration.Id, basisForTransfer.Id); Assert.Equal(HttpStatusCode.OK, assignResponse.StatusCode); //Enable and set third country var transferToThirdCountries = A <YesNoUndecidedOption>(); using var setInsecureCountryStateResponse = await DataProcessingRegistrationHelper.SendSetUseTransferToInsecureThirdCountriesStateRequestAsync(registration.Id, transferToThirdCountries); Assert.Equal(HttpStatusCode.OK, setInsecureCountryStateResponse.StatusCode); //Set data responsible var dataOptions = await DataProcessingRegistrationHelper.GetAvailableOptionsRequestAsync(organizationId); var dataResponsibleOption = dataOptions.DataResponsibleOptions.First(); using var setDataResponsibleResponse = await DataProcessingRegistrationHelper.SendAssignDataResponsibleRequestAsync(registration.Id, dataResponsibleOption.Id); Assert.Equal(HttpStatusCode.OK, setDataResponsibleResponse.StatusCode); //Set oversight option var oversightOption = dataOptions.OversightOptions.First(); using var setOversightOptionResponse = await DataProcessingRegistrationHelper.SendAssignOversightOptionRequestAsync(registration.Id, oversightOption.Id); Assert.Equal(HttpStatusCode.OK, setDataResponsibleResponse.StatusCode); //Enable and set sub processors using var setStateRequest = await DataProcessingRegistrationHelper.SendSetUseSubDataProcessorsStateRequestAsync(registration.Id, YesNoUndecidedOption.Yes); Assert.Equal(HttpStatusCode.OK, setStateRequest.StatusCode); using var sendAssignDataProcessorRequestAsync = await DataProcessingRegistrationHelper.SendAssignDataProcessorRequestAsync(registration.Id, dataProcessor.Id); Assert.Equal(HttpStatusCode.OK, sendAssignDataProcessorRequestAsync.StatusCode); using var sendAssignSubDataProcessorRequestAsync = await DataProcessingRegistrationHelper.SendAssignSubDataProcessorRequestAsync(registration.Id, subDataProcessor.Id); Assert.Equal(HttpStatusCode.OK, sendAssignSubDataProcessorRequestAsync.StatusCode); //Concluded state await DataProcessingRegistrationHelper.SendChangeIsAgreementConcludedRequestAsync(registration.Id, isAgreementConcluded); //Latest oversight date await DataProcessingRegistrationHelper.SendAssignOversightDateRequestAsync(registration.Id, oversightDate, oversightRemark); //References await ReferencesHelper.CreateReferenceAsync(refName, refUserAssignedId, refUrl, refDisp, dto => dto.DataProcessingRegistration_Id = registration.Id); //Systems var itSystemDto = await ItSystemHelper.CreateItSystemInOrganizationAsync(systemName, organizationId, AccessModifier.Public); var usage = await ItSystemHelper.TakeIntoUseAsync(itSystemDto.Id, organizationId); using var assignSystemResponse = await DataProcessingRegistrationHelper.SendAssignSystemRequestAsync(registration.Id, usage.Id); Assert.Equal(HttpStatusCode.OK, assignSystemResponse.StatusCode); //Contracts var contractDto = await ItContractHelper.CreateContract(contractName, organizationId); using var assignDataProcessingResponse = await ItContractHelper.SendAssignDataProcessingRegistrationAsync(contractDto.Id, registration.Id); Assert.Equal(HttpStatusCode.OK, assignDataProcessingResponse.StatusCode); //Wait for read model to rebuild (wait for the LAST mutation) await WaitForReadModelQueueDepletion(); Console.Out.WriteLine("Read models are up to date"); //Act var readModels = (await DataProcessingRegistrationHelper.QueryReadModelByNameContent(organizationId, name, 1, 0)).ToList(); //Assert var readModel = Assert.Single(readModels); Console.Out.WriteLine("Read model found"); Assert.Equal(name, readModel.Name); Assert.Equal(registration.Id, readModel.SourceEntityId); Assert.Equal(refName, readModel.MainReferenceTitle); Assert.Equal(refUrl, readModel.MainReferenceUrl); Assert.Equal(refUserAssignedId, readModel.MainReferenceUserAssignedId); Assert.Equal(oversightInterval, readModel.OversightInterval); Assert.Equal(oversightCompleted, readModel.IsOversightCompleted); Assert.Equal(dataProcessor.Name, readModel.DataProcessorNamesAsCsv); Assert.Equal(subDataProcessor.Name, readModel.SubDataProcessorNamesAsCsv); Assert.Equal(isAgreementConcluded, readModel.IsAgreementConcluded); Assert.Equal(transferToThirdCountries, readModel.TransferToInsecureThirdCountries); Assert.Equal(basisForTransfer.Name, readModel.BasisForTransfer); Assert.Equal(dataResponsibleOption.Name, readModel.DataResponsible); Assert.Equal(oversightOption.Name, readModel.OversightOptionNamesAsCsv); Assert.Equal(contractName, readModel.ContractNamesAsCsv); Assert.Equal(systemName, readModel.SystemNamesAsCsv); Assert.Equal(oversightDate, readModel.LatestOversightDate); Console.Out.WriteLine("Flat values asserted"); Console.Out.WriteLine("Asserting role assignments"); var roleAssignment = Assert.Single(readModel.RoleAssignments); Console.Out.WriteLine("Found one role assignment as expected"); Assert.Equal(role.Id, roleAssignment.RoleId); Assert.Equal(user.Id, roleAssignment.UserId); Assert.Equal(user.Name, roleAssignment.UserFullName); Console.Out.WriteLine("Role data verified"); //Assert that the source object can be deleted and that the readmodel is gone now var deleteResponse = await DataProcessingRegistrationHelper.SendDeleteRequestAsync(registration.Id); Assert.Equal(HttpStatusCode.OK, deleteResponse.StatusCode); readModels = (await DataProcessingRegistrationHelper.QueryReadModelByNameContent(organizationId, name, 1, 0)).ToList(); Assert.Empty(readModels); }