示例#1
0
        public async Task FindContentAsync_should_throw_exception_if_user_has_no_permission()
        {
            var ctx = CreateContext(isFrontend: false, allowSchema: false);

            A.CallTo(() => contentRepository.FindContentAsync(ctx.App, schema, contentId, A <SearchScope> ._))
            .Returns(CreateContent(contentId));

            await Assert.ThrowsAsync <DomainForbiddenException>(() => sut.FindAsync(ctx, schemaId.Name, contentId));
        }
        public async Task Should_throw_permission_exception_if_content_to_find_is_restricted()
        {
            var requestContext = CreateContext(allowSchema: false);

            var content = CreateContent(DomainId.NewGuid());

            A.CallTo(() => contentRepository.FindContentAsync(requestContext.App, schema, content.Id, A <SearchScope> ._))
            .Returns(CreateContent(DomainId.NewGuid()));

            await Assert.ThrowsAsync <DomainForbiddenException>(() => sut.FindAsync(requestContext, schemaId.Name, content.Id));
        }