예제 #1
0
        public static void VmAsserts(ApiResponseWrapper <List <SandboxResourceLight> > responseWrapper, bool vmDeleted, bool vmDeleteFinished, params string[] expectedVmNames)
        {
            ApiResponseBasicAsserts.ExpectSuccess <List <SandboxResourceLight> >(responseWrapper);

            var index = 0;

            foreach (var curResource in responseWrapper.Content)
            {
                if (index < 4)
                {
                    continue;
                }

                Assert.NotNull(curResource.Name);
                IsRequiredType(index, curResource, expectedVmNames);

                if (!vmDeleted)
                {
                    Assert.Contains(CloudResourceStatus.CREATING, curResource.Status);
                    Assert.Contains(CloudResourceStatus.IN_QUEUE, curResource.Status);
                }
                else if (vmDeleted && !vmDeleteFinished)
                {
                    Assert.Contains(CloudResourceStatus.DELETING, curResource.Status);
                    Assert.Contains(CloudResourceStatus.IN_QUEUE, curResource.Status);
                }
                else if (vmDeleteFinished)
                {
                    Assert.Contains(CloudResourceStatus.DELETING, curResource.Status);
                    Assert.Contains(CloudResourceStatus.IN_QUEUE, curResource.Status);
                }

                index++;
            }
        }
예제 #2
0
 public static void ExpectSuccess(DatasetCreateUpdateInputBaseDto createRequest, ApiResponseWrapper <DatasetDto> responseWrapper)
 {
     ApiResponseBasicAsserts.ExpectSuccess <DatasetDto>(responseWrapper);
     Assert.NotEqual <int>(0, responseWrapper.Content.Id);
     Assert.Equal(createRequest.Name, responseWrapper.Content.Name);
     Assert.Equal(createRequest.Classification, responseWrapper.Content.Classification);
 }
예제 #3
0
        public static async Task <ApiConversation <T> > ReadAndAssertExpectSuccess <T>(RestHelper restHelper, string url)
        {
            var conversation = await Read <T>(restHelper, url);

            ApiResponseBasicAsserts.ExpectSuccess(conversation.Response);
            return(conversation);
        }
예제 #4
0
        public static void SandboxResourceAsserts(ApiResponseWrapper <List <SandboxResourceLight> > responseWrapper, bool createFinished)
        {
            ApiResponseBasicAsserts.ExpectSuccess <List <SandboxResourceLight> >(responseWrapper);

            var index = 0;

            foreach (var curResource in responseWrapper.Content)
            {
                if (index > 4)
                {
                    break;
                }

                Assert.NotNull(curResource.Name);
                IsRequiredType(index, curResource);

                if (createFinished)
                {
                    Assert.Equal(CloudResourceStatus.OK, curResource.Status);
                }
                else
                {
                    Assert.Contains(CloudResourceStatus.CREATING, curResource.Status);
                    Assert.Contains(CloudResourceStatus.IN_QUEUE, curResource.Status);
                }

                index++;
            }
        }
예제 #5
0
        public static void NewlyCreatedExpectSuccess(SandboxCreateDto createRequest, ApiResponseWrapper <SandboxDetails> responseWrapper)
        {
            ApiResponseBasicAsserts.ExpectSuccess <SandboxDetails>(responseWrapper);

            Assert.NotEqual <int>(0, responseWrapper.Content.Id);
            Assert.Equal(createRequest.Name, responseWrapper.Content.Name);
            Assert.Equal(createRequest.Region, responseWrapper.Content.Region);
        }
        public static void ExpectSuccess(VirtualMachineCreateDto createRequest, string sandboxRegion, ApiResponseWrapper <VmDto> responseWrapper)
        {
            ApiResponseBasicAsserts.ExpectSuccess <VmDto>(responseWrapper);

            Assert.NotEqual <int>(0, responseWrapper.Content.Id);
            Assert.Contains(createRequest.Name, responseWrapper.Content.Name);
            Assert.Equal(createRequest.OperatingSystem, responseWrapper.Content.OperatingSystem);
            Assert.Equal(sandboxRegion, responseWrapper.Content.Region);//Same region as sandbox
        }
        public static void ExpectSuccess(ApiResponseWrapper <SandboxResourceLight> responseWrapper, string statusShouldContain)
        {
            ApiResponseBasicAsserts.ExpectSuccess <SandboxResourceLight>(responseWrapper);

            var sandboxResourceResponse = responseWrapper.Content;

            Assert.NotNull(sandboxResourceResponse.Name);
            Assert.Null(sandboxResourceResponse.RetryLink);
            Assert.Contains(statusShouldContain, sandboxResourceResponse.Status);
        }
        public static void AfterProvisioning(ApiResponseWrapper <List <VmDto> > responseWrapper, params string[] expectedVmNames)
        {
            ApiResponseBasicAsserts.ExpectSuccess <List <VmDto> >(responseWrapper);

            var sandboxResourceResponse = responseWrapper.Content;

            var index = 0;

            foreach (var curResource in sandboxResourceResponse)
            {
                Assert.NotNull(curResource.Name);
                Assert.Equal(CloudResourceStatus.OK, curResource.Status);
                index++;
            }
        }
        public static void ExpectSuccess(int datasetId, string datasetName, string classification, string totalClassification, ApiResponseWrapper <AvailableDatasets> responseWrapper)
        {
            ApiResponseBasicAsserts.ExpectSuccess <AvailableDatasets>(responseWrapper);

            Assert.NotEmpty(responseWrapper.Content.Datasets);
            Assert.Equal(totalClassification, responseWrapper.Content.Classification);

            var newlyAddedDataset = responseWrapper.Content.Datasets.SingleOrDefault(ds => ds.DatasetId == datasetId);

            Assert.NotNull(newlyAddedDataset);

            Assert.Equal(datasetId, newlyAddedDataset.DatasetId);
            Assert.Equal(datasetName, newlyAddedDataset.Name);
            Assert.Equal(classification, newlyAddedDataset.Classification);
            Assert.True(newlyAddedDataset.AddedToSandbox);
        }
        public static void BeforeProvisioning(ApiResponseWrapper <List <VmDto> > responseWrapper, params string[] expectedVmNames)
        {
            ApiResponseBasicAsserts.ExpectSuccess <List <VmDto> >(responseWrapper);

            var sandboxVmResponse = responseWrapper.Content;

            var index = 0;

            foreach (var curResource in sandboxVmResponse)
            {
                Assert.NotNull(curResource.Name);
                Assert.Contains(CloudResourceStatus.CREATING, curResource.Status);
                Assert.Contains(CloudResourceStatus.IN_QUEUE, curResource.Status);

                index++;
            }
        }
예제 #11
0
        public async Task Read_StudyList_ShouldOnlyContainRelevantRestrictedStudies(bool employee, string myRole)
        {
            SetScenario(isEmployee: employee);
            await WithUserSeeds();

            var studyThisUserShouldSee = await WithStudyCreatedByOtherUser(true, new List <string> {
                myRole
            });

            var studyThisUserShouldNotSee = await WithStudyCreatedByOtherUser(true);

            var studyReadConversation = await GenericReader.ReadExpectSuccess <List <StudyListItemDto> >(_restHelper, GenericReader.StudiesUrl());

            ApiResponseBasicAsserts.ExpectSuccess <List <StudyListItemDto> >(studyReadConversation.Response);
            Assert.NotEmpty(studyReadConversation.Response.Content);
            Assert.NotNull(studyReadConversation.Response.Content.FirstOrDefault(s => s.Id == studyThisUserShouldSee.Id));
            Assert.Null(studyReadConversation.Response.Content.FirstOrDefault(s => s.Id == studyThisUserShouldNotSee.Id));
        }
예제 #12
0
        public async Task Read_StudyList_WithoutRelevantRoles_ShouldFail(bool datasetAdmin)
        {
            SetScenario(isDatasetAdmin: datasetAdmin);
            await WithUserSeeds();

            _ = await WithStudyCreatedByCurrentUser(false);

            _ = await WithStudyCreatedByCurrentUser(true);

            _ = await WithStudyCreatedByOtherUser(false);

            _ = await WithStudyCreatedByOtherUser(true);

            var studyReadConversation = await GenericReader.ReadExpectSuccess <List <StudyListItemDto> >(_restHelper, GenericReader.StudiesUrl());

            ApiResponseBasicAsserts.ExpectSuccess <List <StudyListItemDto> >(studyReadConversation.Response);
            Assert.Empty(studyReadConversation.Response.Content);
        }
예제 #13
0
 public static void AfterPhaseShiftExpectSuccess(ApiResponseWrapper <SandboxDetails> responseWrapper)
 {
     ApiResponseBasicAsserts.ExpectSuccess <SandboxDetails>(responseWrapper);
     Assert.NotEqual <int>(0, responseWrapper.Content.Id);
     Assert.Equal(SandboxPhase.DataAvailable, responseWrapper.Content.CurrentPhase);
 }