|
|
|
@ -3,6 +3,7 @@ using System.Threading.Tasks; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using NSubstitute; |
|
|
|
using Shouldly; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Users; |
|
|
|
using Volo.CmsKit.Public.Comments; |
|
|
|
using Xunit; |
|
|
|
@ -62,6 +63,23 @@ public class CommentPublicAppService_Tests : CmsKitApplicationTestBase |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task CreateAsync_ShouldThrowUserFriendlyException_If_Url_UnAllowed() |
|
|
|
{ |
|
|
|
_currentUser.Id.Returns(_cmsKitTestData.User2Id); |
|
|
|
|
|
|
|
await Should.ThrowAsync<UserFriendlyException>(async () => |
|
|
|
await _commentAppService.CreateAsync( |
|
|
|
_cmsKitTestData.EntityType1, |
|
|
|
_cmsKitTestData.EntityId1, |
|
|
|
new CreateCommentInput { |
|
|
|
RepliedCommentId = null, |
|
|
|
Text = "[ABP Community](https://community.abp.io/)", //not allowed URL
|
|
|
|
AllowExternalUrls = false |
|
|
|
} |
|
|
|
)); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task UpdateAsync() |
|
|
|
{ |
|
|
|
@ -80,6 +98,21 @@ public class CommentPublicAppService_Tests : CmsKitApplicationTestBase |
|
|
|
comment.Text.ShouldBe("I'm Updated"); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task UpdateAsync_ShouldThrowUserFriendlyException_If_Url_UnAllowed() |
|
|
|
{ |
|
|
|
_currentUser.Id.Returns(_cmsKitTestData.User2Id); |
|
|
|
|
|
|
|
await Should.ThrowAsync<UserFriendlyException>(async () => |
|
|
|
await _commentAppService.UpdateAsync( |
|
|
|
_cmsKitTestData.CommentWithChildId, |
|
|
|
new UpdateCommentInput { |
|
|
|
Text = "[ABP Community - Update](https://community.abp.io/)", //not allowed URL
|
|
|
|
AllowExternalUrls = false |
|
|
|
} |
|
|
|
)); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task DeleteAsync() |
|
|
|
|