async Task PerformTestsExpectSuccess(int sandboxId)
        {
            var sandboxDetailsConversation = await GenericReader.ReadAndAssertExpectSuccess <SandboxDetails>(_restHelper, GenericReader.SandboxUrl(sandboxId));

            SandboxDetailsAsserts.ReadyForPhaseShiftExpectSuccess(sandboxDetailsConversation.Response);

            var phaseShiftConversation = await GenericPoster.PostAndExpectSuccess <SandboxDetails>(_restHelper, GenericPoster.SandboxNextPhase(sandboxId));

            SandboxDetailsAsserts.AfterPhaseShiftExpectSuccess(phaseShiftConversation.Response);
        }
Exemple #2
0
        async Task ReadAllAndAssertExpectSuccess(CloudResource vm)
        {
            await GenericReader.ReadAndAssertExpectSuccess <StudyDetailsDto>(_restHelper, GenericReader.StudyUrl(vm.Sandbox.StudyId));

            await GenericReader.ReadAndAssertExpectSuccess <SandboxDetails>(_restHelper, GenericReader.SandboxUrl(vm.Sandbox.Id));

            await GenericReader.ReadAndAssertExpectSuccess <List <VmDto> >(_restHelper, GenericReader.SandboxVirtualMachines(vm.Sandbox.Id));

            await GenericReader.ReadAndAssertExpectSuccess <List <SandboxResourceLight> >(_restHelper, GenericReader.SandboxResources(vm.Sandbox.Id));

            await GenericReader.ReadAndAssertExpectSuccess <VmExtendedDto>(_restHelper, GenericReader.VirtualMachineExtendedInfo(vm.Id)); //Todo: Add this test, but remember to mock out azure vm service
        }
        public async Task Read_Study__ResultsAndLearnings_WithRelevantRoles_ShouldSucceed(bool studyCreatedByCurrentUser, bool restricted, bool employee, bool isAdmin, bool isSponsor, string studyRole = null)
        {
            SetScenario(isEmployee: employee, isAdmin, isSponsor);
            await WithUserSeeds();

            var createdStudy = await WithStudy(studyCreatedByCurrentUser, restricted, new List <string> {
                studyRole
            });

            var studyReadConversation = await GenericReader.ReadAndAssertExpectSuccess <StudyResultsAndLearningsDto>(_restHelper, GenericReader.StudyResultsAndLearningsUrl(createdStudy.Id));

            Assert.NotNull(studyReadConversation.Response.Content.ResultsAndLearnings);
        }
Exemple #4
0
        //[InlineData(false, true)]
        //[InlineData(true, true)]
        public async Task AddStudyAndSandboxAndVm_WithRequiredRole_ShouldSucceed(bool isAdmin, bool isSponsor)
        {
            Trace.WriteLine("START AddStudyAndSandboxAndVm_WithRequiredRole_ShouldSucceed");
            await WithBasicSeeds();

            SetScenario(isEmployee: true, isAdmin: isAdmin, isSponsor: isSponsor);

            //CREATE STUDY
            var studyCreateConversation = await StudyCreator.CreateAndExpectSuccess(_restHelper);
            CreateStudyAsserts.ExpectSuccess(studyCreateConversation.Request, studyCreateConversation.Response);

            //CREATE STUDY SPECIFIC DATASET
            var datasetSeedResponse = await DatasetCreator.Create(_restHelper, studyCreateConversation.Response.Content.Id);
            var datasetCreateRequest = datasetSeedResponse.Request;
            var datasetResponseWrapper = datasetSeedResponse.Response;
            CreateDatasetAsserts.ExpectSuccess(datasetCreateRequest, datasetResponseWrapper);

            var createDatasetResponse = datasetResponseWrapper.Content;

            //CREATE SANDBOX
            var sandboxSeedResponse = await SandboxCreator.CreateAndExpectSuccess(_restHelper, studyCreateConversation.Response.Content.Id);
            var sandboxCreateRequest = sandboxSeedResponse.Request;
            var sandboxResponseWrapper = sandboxSeedResponse.Response;

            SandboxDetailsAsserts.NewlyCreatedExpectSuccess(sandboxCreateRequest, sandboxResponseWrapper);

            var sandboxResponse = sandboxResponseWrapper.Content;

            //ADD DATASET TO SANDBOX
            var addDatasetToSandboxResponse = await SandboxOperations.AddDataset(_restHelper, sandboxResponse.Id, createDatasetResponse.Id);
            var sandboxDatasetResponseWrapper = addDatasetToSandboxResponse.Response;
            AddDatasetToSandboxAsserts.ExpectSuccess(createDatasetResponse.Id, createDatasetResponse.Name, createDatasetResponse.Classification, "Open", sandboxDatasetResponseWrapper);

            //CREATE VM
            var virtualMachineSeedResponse = await VirtualMachineCreator.Create(_restHelper, sandboxResponse.Id);
            var virtualMachineCreateRequest = virtualMachineSeedResponse.Request;
            var virtualMachineResponseWrapper = virtualMachineSeedResponse.Response;

            CreateVirtualMachineAsserts.ExpectSuccess(virtualMachineCreateRequest, sandboxResponse.Region, virtualMachineResponseWrapper);

            //GET SANDBOX RESOURCE LIST AND ASSERT RESULT BEFORE CREATION
            var sandboxResourcesPreProvisioningResponseWrapper = await _restHelper.Get<List<SandboxResourceLight>>($"api/sandboxes/{sandboxResponse.Id}/resources");
            SandboxResourceListAsserts.BeforeProvisioning(sandboxResourcesPreProvisioningResponseWrapper, virtualMachineResponseWrapper.Content.Name);

            //GET SANDBOX VM LIST AND ASSERT RESULT BEFORE CREATION
            var virtualMachinesPreProvisioningResponseWrapper = await GenericReader.ReadAndAssertExpectSuccess<List<VmDto>>(_restHelper, GenericReader.SandboxVirtualMachines(sandboxResponse.Id));
            SandboxVirtualMachineAsserts.BeforeProvisioning(virtualMachinesPreProvisioningResponseWrapper.Response, virtualMachineResponseWrapper.Content.Name);

            //SETUP INFRASTRUCTURE BY RUNNING A METHOD ON THE API            
            var processWorkQueueResponse = await ProcessWorkQueue();

            //GET SANDBOX RESOURCE LIST AND ASSERT RESULT
            var sandboxResourcesResponseWrapper = await _restHelper.Get<List<SandboxResourceLight>>($"api/sandboxes/{sandboxResponse.Id}/resources");
            SandboxResourceListAsserts.AfterProvisioning(sandboxResourcesResponseWrapper, virtualMachineResponseWrapper.Content.Name);

            //TODO: GET SANDBOX VM LIST AND ASSERT RESULT
            var virtualMachinesAfterProvisioningResponseWrapper = await GenericReader.ReadAndAssertExpectSuccess<List<VmDto>>(_restHelper, GenericReader.SandboxVirtualMachines(sandboxResponse.Id));
            SandboxVirtualMachineAsserts.AfterProvisioning(virtualMachinesAfterProvisioningResponseWrapper.Response, virtualMachineResponseWrapper.Content.Name);

            //Add some participants

            var studyParticipantResponse = await StudyParticipantAdderAndRemover.AddAndExpectSuccess(_restHelper, studyCreateConversation.Response.Content.Id, StudyRoles.SponsorRep,
                StudyParticipantAdderAndRemover.CreateParticipantLookupDto());

            var getStudy = await _restHelper.Get<StudyDetailsDto>($"api/studies/{studyCreateConversation.Response.Content.Id}");

            var studyParticipant = getStudy.Content.Participants.Find(x => x.UserId == studyParticipantResponse.Response.Content.UserId);

            AddStudyParticipantsAsserts.ExpectSuccess(StudyRoles.SponsorRep, studyParticipant, studyParticipantResponse.Response);

            var vmRuleExtended = await _restHelper.Get<VmRuleDto>($"api/virtualmachines/{virtualMachineResponseWrapper.Content.Id}/extended");

            //OPEN INTERNET
            var openInternetResponse = await SandboxOperations.OpenInternetForVm<VmRuleDto>(_restHelper, virtualMachineResponseWrapper.Content.Id);

            SandboxVirtualMachineRuleAsserts.ExpectSuccess(openInternetResponse.Response.Content, vmRuleExtended.Content);

            await SandboxOperations.CloseInternetForVm<VmRuleDto>(_restHelper, virtualMachineResponseWrapper.Content.Id);

            //MOVE TO NEXT PHASE
            var sandboxAfterMovingToNextPhase = await SandboxOperations.MoveToNextPhase<SandboxDetails>(_restHelper, sandboxResponseWrapper.Content.Id);

            SandboxDetailsAsserts.AfterPhaseShiftExpectSuccess(sandboxAfterMovingToNextPhase.Response);
            
            //DELETE VM
            var deleteVmConversation = await SandboxOperations.DeleteVm(_restHelper, virtualMachineResponseWrapper.Content.Id);
            ApiResponseBasicAsserts.ExpectNoContent(deleteVmConversation.Response);

            //RUN WORKER
            await ProcessWorkQueue();

            //ASSERT THAT VM DISSAPEARS
            var sandboxVmsAfterDelete = await _restHelper.Get<List<VmDto>>($"api/virtualmachines/forsandbox/{sandboxResponseWrapper.Content.Id}");

            SandboxVirtualMachineAsserts.AfterProvisioning(sandboxVmsAfterDelete, "vm-studyname-sandboxnam-integrationtest");

            //TRY TO DELETE STUDY, GET ERROR
            await StudyDeleter.DeleteAndExpectFailure(_restHelper, studyCreateConversation.Response.Content.Id);

            //DELETE SANDBOX
            await SandboxDeleter.DeleteAndExpectSuccess(_restHelper, sandboxResponseWrapper.Content.Id);

            //DELETE STUDY

            await StudyDeleter.DeleteAndExpectSuccess(_restHelper, studyCreateConversation.Response.Content.Id);
            Trace.WriteLine("START AddStudyAndSandboxAndVm_WithRequiredRole_ShouldSucceed");
        }