Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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);
        }