public async Task Should_throw_for_single_content_if_no_permission() { SetupClaims(false, false); SetupSchemaFound(); var ctx = context; await Assert.ThrowsAsync <DomainForbiddenException>(() => sut.FindContentAsync(ctx, schemaId.Name, contentId)); }
public async Task Should_return_content_from_repository_and_transform() { A.CallTo(() => appProvider.GetSchemaAsync(appId, schemaId, false)) .Returns(schema); A.CallTo(() => contentRepository.FindContentAsync(app, schema, contentId)) .Returns(content); A.CallTo(() => schema.ScriptQuery) .Returns("<script-query>"); A.CallTo(() => scriptEngine.Transform(A <ScriptContext> .That.Matches(x => x.User == user && x.ContentId == contentId && ReferenceEquals(x.Data, contentData)), "<query-script>")) .Returns(contentTransformed); var result = await sut.FindContentAsync(app, schemaId.ToString(), user, contentId); Assert.Equal(contentTransformed, result.Data); Assert.Equal(content.Id, result.Id); }
public async Task Should_return_content_from_repository_and_transform(bool isFrontend, params Status[] status) { var contentId = Guid.NewGuid(); var content = CreateContent(contentId); SetupClaims(isFrontend); SetupScripting(contentId); A.CallTo(() => appProvider.GetSchemaAsync(appId, schemaId, false)) .Returns(schema); A.CallTo(() => contentRepository.FindContentAsync(app, schema, A <Status[]> .That.IsSameSequenceAs(status), contentId)) .Returns(content); var result = await sut.FindContentAsync(context.WithSchemaId(schemaId), contentId); Assert.Equal(contentTransformed, result.Data); Assert.Equal(content.Id, result.Id); }
public async Task Should_return_content_from_repository_and_transform(bool isFrontend, params Status[] status) { SetupClaims(isFrontend); A.CallTo(() => appProvider.GetSchemaAsync(appId, schemaId, false)) .Returns(schema); A.CallTo(() => contentRepository.FindContentAsync(app, schema, A <Status[]> .That.IsSameSequenceAs(status), contentId)) .Returns(content); A.CallTo(() => schema.ScriptQuery) .Returns("<script-query>"); A.CallTo(() => scriptEngine.Transform(A <ScriptContext> .That.Matches(x => x.User == user && x.ContentId == contentId && ReferenceEquals(x.Data, contentData)), "<query-script>")) .Returns(contentTransformed); var result = await sut.FindContentAsync(context.WithSchemaId(schemaId), contentId); Assert.Equal(contentTransformed, result.Data); Assert.Equal(content.Id, result.Id); }