Ejemplo n.º 1
0
        public async Task Can_Modify_OversightDate()
        {
            //Arrange
            var name            = A <string>();
            var registrationDto = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, name).ConfigureAwait(false);

            var oversightDate   = A <DateTime>();
            var oversightRemark = A <string>();

            using var assignResponse = await DataProcessingRegistrationHelper.SendAssignOversightDateRequestAsync(registrationDto.Id, oversightDate, oversightRemark);

            Assert.Equal(HttpStatusCode.OK, assignResponse.StatusCode);
            var assignedOversightDate = await assignResponse.ReadResponseBodyAsKitosApiResponseAsync <DataProcessingRegistrationOversightDateDTO>();

            var newOversightDate   = A <DateTime>();
            var newOversightRemark = A <string>();

            //Act
            using var response = await DataProcessingRegistrationHelper.SendModifyOversightDateRequestAsync(registrationDto.Id, assignedOversightDate.Id, newOversightDate, newOversightRemark);

            //Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var dto = await DataProcessingRegistrationHelper.GetAsync(registrationDto.Id);

            var oversightDateRemark = Assert.Single(dto.OversightDates);

            Assert.Equal(newOversightDate, oversightDateRemark.OversightDate);
            Assert.Equal(newOversightRemark, oversightDateRemark.OversightRemark);
        }
Ejemplo n.º 2
0
        public async Task Can_Assign_And_Clear_BasisForTransfer()
        {
            //Arrange
            var registration = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, A <string>());

            var options      = (await DataProcessingRegistrationHelper.GetBasisForTransferOptionsAsync(TestEnvironment.DefaultOrganizationId)).ToList();
            var randomOption = options[Math.Abs(A <int>()) % options.Count];

            //Act - assign basis for transfer
            using var assignResponse = await DataProcessingRegistrationHelper.SendAssignBasisForTransferRequestAsync(registration.Id, randomOption.Id);

            //Assert - basis for transfer set
            Assert.Equal(HttpStatusCode.OK, assignResponse.StatusCode);
            var dto = await DataProcessingRegistrationHelper.GetAsync(registration.Id);

            Assert.NotNull(dto.BasisForTransfer);
            Assert.Equal(randomOption.Id, dto.BasisForTransfer.Id);
            Assert.Equal(randomOption.Name, dto.BasisForTransfer.Name);

            //Act - remove
            using var removeResponse = await DataProcessingRegistrationHelper.SendClearBasisForTransferRequestAsync(registration.Id);

            //Assert country removed again
            Assert.Equal(HttpStatusCode.OK, removeResponse.StatusCode);
            dto = await DataProcessingRegistrationHelper.GetAsync(registration.Id);

            Assert.Null(dto.BasisForTransfer);
        }
Ejemplo n.º 3
0
        public async Task Can_Assign_Role()
        {
            //Arrange
            var registration = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, A <string>());

            var businessRoleDtos = await DataProcessingRegistrationHelper.GetAvailableRolesAsync(registration.Id);

            var role           = businessRoleDtos.First();
            var availableUsers = await DataProcessingRegistrationHelper.GetAvailableUsersAsync(registration.Id, role.Id);

            var user = availableUsers.First();

            //Act
            using var response = await DataProcessingRegistrationHelper.SendAssignRoleRequestAsync(registration.Id, role.Id, user.Id);

            //Assert response
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            registration = await DataProcessingRegistrationHelper.GetAsync(registration.Id);

            //Assert role is in the DTO
            var assignedRoleDto = Assert.Single(registration.AssignedRoles);

            Assert.Equal(user.Id, assignedRoleDto.User.Id);
            Assert.Equal(role.Id, assignedRoleDto.Role.Id);

            //Assert query endpoint now excludes possible duplicate
            availableUsers = await DataProcessingRegistrationHelper.GetAvailableUsersAsync(registration.Id, role.Id);

            Assert.Empty(availableUsers.Where(x => x.Id == user.Id));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public async Task Can_Remove_Role()
        {
            //Arrange
            var registration = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, A <string>());

            var businessRoleDtos = await DataProcessingRegistrationHelper.GetAvailableRolesAsync(registration.Id);

            var role           = businessRoleDtos.First();
            var availableUsers = await DataProcessingRegistrationHelper.GetAvailableUsersAsync(registration.Id, role.Id);

            var user = availableUsers.First();

            using var response = await DataProcessingRegistrationHelper.SendAssignRoleRequestAsync(registration.Id, role.Id, user.Id);

            //Act
            using var removeResponse = await DataProcessingRegistrationHelper.SendRemoveRoleRequestAsync(registration.Id, role.Id, user.Id);

            //Assert response
            Assert.Equal(HttpStatusCode.OK, removeResponse.StatusCode);

            //Assert that the role is no longer in the DTO
            registration = await DataProcessingRegistrationHelper.GetAsync(registration.Id);

            Assert.Empty(registration.AssignedRoles);
        }
Ejemplo n.º 6
0
        public async Task Can_Assign_And_Remove_OversightOption()
        {
            //Arrange
            var registration = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, A <string>());

            var dataOptions = await DataProcessingRegistrationHelper.GetAvailableOptionsRequestAsync(TestEnvironment.DefaultOrganizationId);

            var randomOversightOption = dataOptions.OversightOptions.ToArray()[Math.Abs(A <int>()) % dataOptions.OversightOptions.Count()];

            //Act - add oversight option
            using var assignResponse = await DataProcessingRegistrationHelper.SendAssignOversightOptionRequestAsync(registration.Id, randomOversightOption.Id);

            using var duplicateResponse = await DataProcessingRegistrationHelper.SendAssignOversightOptionRequestAsync(registration.Id, randomOversightOption.Id);

            //Assert - oversight option added
            Assert.Equal(HttpStatusCode.OK, assignResponse.StatusCode);
            Assert.Equal(HttpStatusCode.Conflict, duplicateResponse.StatusCode);
            var dto = await DataProcessingRegistrationHelper.GetAsync(registration.Id);

            var oversightOption = Assert.Single(dto.OversightOptions.Value);

            Assert.Equal(randomOversightOption.Id, oversightOption.Id);
            Assert.Equal(randomOversightOption.Name, oversightOption.Name);

            //Act - remove
            using var removeResponse = await DataProcessingRegistrationHelper.SendRemoveOversightOptionRequestAsync(registration.Id, randomOversightOption.Id);

            //Assert oversight option removed again
            Assert.Equal(HttpStatusCode.OK, removeResponse.StatusCode);
            dto = await DataProcessingRegistrationHelper.GetAsync(registration.Id);

            Assert.Empty(dto.OversightOptions.Value);
        }
Ejemplo n.º 7
0
        public async Task LatestDate_IsResetToNull_WhenIsCompletedNotYes()
        {
            //Arrange
            var name            = A <string>();
            var registrationDto = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, name).ConfigureAwait(false);

            var oversightDate   = A <DateTime>();
            var oversightRemark = A <string>();

            using var isCompletedYesResponse = await DataProcessingRegistrationHelper.SendChangeIsOversightCompletedRequestAsync(registrationDto.Id, YesNoUndecidedOption.Yes);

            Assert.Equal(HttpStatusCode.OK, isCompletedYesResponse.StatusCode);
            using var oversightDateResponse = await DataProcessingRegistrationHelper.SendAssignOversightDateRequestAsync(registrationDto.Id, oversightDate, oversightRemark);

            Assert.Equal(HttpStatusCode.OK, oversightDateResponse.StatusCode);
            var dtoWithDate = await DataProcessingRegistrationHelper.GetAsync(registrationDto.Id);

            var oversightDateRemark = Assert.Single(dtoWithDate.OversightDates);

            Assert.Equal(oversightDate, oversightDateRemark.OversightDate);
            Assert.Equal(oversightRemark, oversightDateRemark.OversightRemark);

            //Act
            using var isCompletedNoResponse = await DataProcessingRegistrationHelper.SendChangeIsOversightCompletedRequestAsync(registrationDto.Id, YesNoUndecidedOption.No);


            //Assert
            Assert.Equal(HttpStatusCode.OK, isCompletedNoResponse.StatusCode);
            var dtoWithNoOversightDates = await DataProcessingRegistrationHelper.GetAsync(registrationDto.Id);

            Assert.Empty(dtoWithNoOversightDates.OversightDates);
        }
Ejemplo n.º 8
0
        public async Task Can_Get()
        {
            //Arrange
            var name = A <string>();
            var dto  = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, name).ConfigureAwait(false);

            //Act
            var gotten = await DataProcessingRegistrationHelper.GetAsync(dto.Id);

            //Assert
            Assert.NotNull(gotten);
            dto.ToExpectedObject().ShouldMatch(gotten);
        }
Ejemplo n.º 9
0
        public async Task Can_Change_OversightOptionRemark()
        {
            //Arrange
            var registration = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, A <string>()).ConfigureAwait(false);

            var remark = A <string>();

            //Act
            using var response = await DataProcessingRegistrationHelper.SendUpdateOversightOptionRemarkRequestAsync(registration.Id, remark);

            //Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var updateRegistrationDto = await DataProcessingRegistrationHelper.GetAsync(registration.Id);

            Assert.Equal(remark, updateRegistrationDto.OversightOptions.Remark);
        }
Ejemplo n.º 10
0
        public async Task Can_Change_IsAgreementConcludedRemark()
        {
            //Arrange
            var name            = A <string>();
            var registrationDto = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, name).ConfigureAwait(false);

            var remark = A <string>();

            //Act
            using var response = await DataProcessingRegistrationHelper.SendChangeAgreementConcludedRemarkRequestAsync(registrationDto.Id, remark);

            //Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var updateRegistrationDto = await DataProcessingRegistrationHelper.GetAsync(registrationDto.Id);

            Assert.Equal(remark, updateRegistrationDto.AgreementConcluded.Remark);
        }
Ejemplo n.º 11
0
        public async Task Can_Change_Oversight_Option_Remark()
        {
            //Arrange
            var name   = A <string>();
            var dprDTO = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, name);

            var oversightRemark = A <string>();

            //Act
            using var response = await DataProcessingRegistrationHelper.SendChangeOversightIntervalOptionRemarkRequestAsync(dprDTO.Id, oversightRemark);

            //Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var dto = await DataProcessingRegistrationHelper.GetAsync(dprDTO.Id);

            Assert.Equal(dto.OversightInterval.Remark, oversightRemark);
        }
Ejemplo n.º 12
0
        public async Task Can_Create_Reference_In_DataProcessingRegistration()
        {
            //Arrange
            var dpa = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, A <string>());

            //Act - create two similar references... we expect the first one to be the master
            var expectedMasterReference = await ReferencesHelper.CreateReferenceAsync(_title, _externalReferenceId, _referenceUrl, _display, dto => dto.DataProcessingRegistration_Id = dpa.Id);

            await ReferencesHelper.CreateReferenceAsync(_title, _externalReferenceId, _referenceUrl, _display, dto => dto.DataProcessingRegistration_Id = dpa.Id);

            //Assert
            AssertCreatedReference(_title, expectedMasterReference, _externalReferenceId, _referenceUrl, _display);
            dpa = await DataProcessingRegistrationHelper.GetAsync(dpa.Id);

            Assert.Equal(2, dpa.References.Length);
            Assert.Equal(expectedMasterReference.Id, dpa.References.FirstOrDefault(x => x.MasterReference).FromNullable().Select(x => x.Id).GetValueOrFallback(-1)); //First reference must be marked as "the reference"
        }
Ejemplo n.º 13
0
        public async Task Can_Change_IsOversightCompleted()
        {
            //Arrange
            var name            = A <string>();
            var registrationDto = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, name).ConfigureAwait(false);

            var yesNoUndecidedOption = A <YesNoUndecidedOption>();

            //Act
            using var response = await DataProcessingRegistrationHelper.SendChangeIsOversightCompletedRequestAsync(registrationDto.Id, yesNoUndecidedOption);

            //Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var dto = await DataProcessingRegistrationHelper.GetAsync(registrationDto.Id);

            Assert.Equal(dto.OversightCompleted.Value, yesNoUndecidedOption);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        public async Task Can_Change_DataResponsible()
        {
            //Arrange
            var name            = A <string>();
            var registrationDto = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, name).ConfigureAwait(false);

            var dataOptions = await DataProcessingRegistrationHelper.GetAvailableOptionsRequestAsync(registrationDto.Id);

            var dataResponsibleOption = dataOptions.DataResponsibleOptions.First();

            //Act
            using var response = await DataProcessingRegistrationHelper.SendAssignDataResponsibleRequestAsync(registrationDto.Id, dataResponsibleOption.Id);

            //Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var updateRegistrationDto = await DataProcessingRegistrationHelper.GetAsync(registrationDto.Id);

            Assert.Equal(dataResponsibleOption.Id, updateRegistrationDto.DataResponsible.Value.Id);
        }
Ejemplo n.º 16
0
        public async Task Can_Assign_And_Remove_System()
        {
            //Arrange
            var       systemPrefix   = A <Guid>().ToString("N");
            const int organizationId = TestEnvironment.DefaultOrganizationId;
            var       system1Name    = $"{systemPrefix}{1}";
            var       registration   = await DataProcessingRegistrationHelper.CreateAsync(organizationId, A <string>());

            var system = await ItSystemHelper.CreateItSystemInOrganizationAsync(system1Name, organizationId, AccessModifier.Public);

            var usage = await ItSystemHelper.TakeIntoUseAsync(system.Id, organizationId);

            //Act - Add
            using var assignResponse = await DataProcessingRegistrationHelper.SendAssignSystemRequestAsync(registration.Id, usage.Id);

            using var duplicateResponse = await DataProcessingRegistrationHelper.SendAssignSystemRequestAsync(registration.Id, usage.Id);

            //Assert
            Assert.Equal(HttpStatusCode.OK, assignResponse.StatusCode);
            Assert.Equal(HttpStatusCode.Conflict, duplicateResponse.StatusCode);
            var dto = await DataProcessingRegistrationHelper.GetAsync(registration.Id);

            var systemDTO = Assert.Single(dto.ItSystems);

            Assert.Equal(usage.Id, systemDTO.Id);
            Assert.Equal(system.Name, systemDTO.Name);

            //Act - remove
            using var removeResponse = await DataProcessingRegistrationHelper.SendRemoveSystemRequestAsync(registration.Id, usage.Id);

            using var duplicateRemoveResponse = await DataProcessingRegistrationHelper.SendRemoveSystemRequestAsync(registration.Id, usage.Id);

            //Assert
            Assert.Equal(HttpStatusCode.OK, removeResponse.StatusCode);
            Assert.Equal(HttpStatusCode.BadRequest, duplicateRemoveResponse.StatusCode);
            dto = await DataProcessingRegistrationHelper.GetAsync(registration.Id);

            Assert.Empty(dto.ItSystems);
        }
Ejemplo n.º 17
0
        public async Task Can_Assign_And_Remove_InsecureThirdCountry()
        {
            //Arrange
            var registration = await DataProcessingRegistrationHelper.CreateAsync(TestEnvironment.DefaultOrganizationId, A <string>());

            var countries     = (await DataProcessingRegistrationHelper.GetCountryOptionsAsync(TestEnvironment.DefaultOrganizationId)).ToList();
            var randomCountry = countries[Math.Abs(A <int>()) % countries.Count];

            using var setStateRequest = await DataProcessingRegistrationHelper.SendSetUseTransferToInsecureThirdCountriesStateRequestAsync(registration.Id, YesNoUndecidedOption.Yes);

            Assert.Equal(HttpStatusCode.OK, setStateRequest.StatusCode);

            //Act - add country
            using var assignResponse = await DataProcessingRegistrationHelper.SendAssignInsecureThirdCountryRequestAsync(registration.Id, randomCountry.Id);

            using var duplicateResponse = await DataProcessingRegistrationHelper.SendAssignInsecureThirdCountryRequestAsync(registration.Id, randomCountry.Id);

            //Assert - country added
            Assert.Equal(HttpStatusCode.OK, assignResponse.StatusCode);
            Assert.Equal(HttpStatusCode.Conflict, duplicateResponse.StatusCode);
            var dto = await DataProcessingRegistrationHelper.GetAsync(registration.Id);

            Assert.Equal(YesNoUndecidedOption.Yes, dto.TransferToInsecureThirdCountries);
            var country = Assert.Single(dto.InsecureThirdCountries);

            Assert.Equal(randomCountry.Id, country.Id);
            Assert.Equal(randomCountry.Name, country.Name);

            //Act - remove
            using var removeResponse = await DataProcessingRegistrationHelper.SendRemoveInsecureThirdCountryRequestAsync(registration.Id, randomCountry.Id);

            //Assert country removed again
            Assert.Equal(HttpStatusCode.OK, removeResponse.StatusCode);
            dto = await DataProcessingRegistrationHelper.GetAsync(registration.Id);

            Assert.Empty(dto.InsecureThirdCountries);
        }