mirror of https://github.com/Ombi-app/Ombi
parent
c6865d9dcc
commit
263240c648
@ -1,89 +1,86 @@
|
||||
//using System.Security.Principal;
|
||||
//using System.Threading.Tasks;
|
||||
//using Moq;
|
||||
//using Ombi.Core.Claims;
|
||||
//using Ombi.Core.Models.Requests;
|
||||
//using Ombi.Core.Rule.Rules;
|
||||
//using Ombi.Core.Rule.Rules.Request;
|
||||
//using Xunit;
|
||||
|
||||
//namespace Ombi.Core.Tests.Rule
|
||||
//{
|
||||
// public class AutoApproveRuleTests
|
||||
// {
|
||||
// public AutoApproveRuleTests()
|
||||
// {
|
||||
// PrincipalMock = new Mock<IPrincipal>();
|
||||
// Rule = new AutoApproveRule(PrincipalMock.Object);
|
||||
// }
|
||||
|
||||
// private AutoApproveRule Rule { get; }
|
||||
// private Mock<IPrincipal> PrincipalMock { get; }
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnSuccess_WhenAdminAndRequestMovie()
|
||||
// {
|
||||
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||
// var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, true);
|
||||
// Assert.Equal(request.Approved, true);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnSuccess_WhenAdminAndRequestTV()
|
||||
// {
|
||||
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||
// var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, true);
|
||||
// Assert.Equal(request.Approved, true);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnSuccess_WhenAutoApproveMovieAndRequestMovie()
|
||||
// {
|
||||
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.AutoApproveMovie)).Returns(true);
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||
// var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, true);
|
||||
// Assert.Equal(request.Approved, true);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnSuccess_WhenAutoApproveTVAndRequestTV()
|
||||
// {
|
||||
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.AutoApproveTv)).Returns(true);
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||
// var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, true);
|
||||
// Assert.Equal(request.Approved, true);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnFail_WhenNoClaimsAndRequestMovie()
|
||||
// {
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||
// var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, true);
|
||||
// Assert.Equal(request.Approved, false);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnFail_WhenNoClaimsAndRequestTV()
|
||||
// {
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||
// var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, true);
|
||||
// Assert.Equal(request.Approved, false);
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
//}
|
||||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using Ombi.Core.Claims;
|
||||
using Ombi.Core.Rule.Rules.Request;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Xunit;
|
||||
|
||||
namespace Ombi.Core.Tests.Rule.Request
|
||||
{
|
||||
public class AutoApproveRuleTests
|
||||
{
|
||||
public AutoApproveRuleTests()
|
||||
{
|
||||
PrincipalMock = new Mock<IPrincipal>();
|
||||
Rule = new AutoApproveRule(PrincipalMock.Object);
|
||||
}
|
||||
|
||||
private AutoApproveRule Rule { get; }
|
||||
private Mock<IPrincipal> PrincipalMock { get; }
|
||||
|
||||
[Fact]
|
||||
public async Task Should_ReturnSuccess_WhenAdminAndRequestMovie()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.Movie };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
Assert.Equal(result.Success, true);
|
||||
Assert.Equal(request.Approved, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Should_ReturnSuccess_WhenAdminAndRequestTV()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.TvShow };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
Assert.Equal(result.Success, true);
|
||||
Assert.Equal(request.Approved, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Should_ReturnSuccess_WhenAutoApproveMovieAndRequestMovie()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.AutoApproveMovie)).Returns(true);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.Movie };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
Assert.Equal(result.Success, true);
|
||||
Assert.Equal(request.Approved, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Should_ReturnSuccess_WhenAutoApproveTVAndRequestTV()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.AutoApproveTv)).Returns(true);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.TvShow };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
Assert.Equal(result.Success, true);
|
||||
Assert.Equal(request.Approved, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Should_ReturnFail_WhenNoClaimsAndRequestMovie()
|
||||
{
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.Movie };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
Assert.Equal(result.Success, true);
|
||||
Assert.Equal(request.Approved, false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Should_ReturnFail_WhenNoClaimsAndRequestTV()
|
||||
{
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.TvShow };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
Assert.Equal(result.Success, true);
|
||||
Assert.Equal(request.Approved, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,84 +1,85 @@
|
||||
//using System.Security.Principal;
|
||||
//using System.Threading.Tasks;
|
||||
//using Moq;
|
||||
//using Ombi.Core.Claims;
|
||||
//using Ombi.Core.Models.Requests;
|
||||
//using Ombi.Core.Rule.Rules;
|
||||
//using Xunit;
|
||||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using Ombi.Core.Claims;
|
||||
using Ombi.Core.Models.Requests;
|
||||
using Ombi.Core.Rule.Rules;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Xunit;
|
||||
|
||||
//namespace Ombi.Core.Tests.Rule
|
||||
//{
|
||||
// public class CanRequestRuleTests
|
||||
// {
|
||||
// public CanRequestRuleTests()
|
||||
// {
|
||||
// PrincipalMock = new Mock<IPrincipal>();
|
||||
// Rule = new CanRequestRule(PrincipalMock.Object);
|
||||
// }
|
||||
namespace Ombi.Core.Tests.Rule
|
||||
{
|
||||
public class CanRequestRuleTests
|
||||
{
|
||||
public CanRequestRuleTests()
|
||||
{
|
||||
PrincipalMock = new Mock<IPrincipal>();
|
||||
Rule = new CanRequestRule(PrincipalMock.Object);
|
||||
}
|
||||
|
||||
// private CanRequestRule Rule { get; }
|
||||
// private Mock<IPrincipal> PrincipalMock { get; }
|
||||
private CanRequestRule Rule { get; }
|
||||
private Mock<IPrincipal> PrincipalMock { get; }
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnSuccess_WhenRequestingMovieWithMovieRole()
|
||||
// {
|
||||
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestMovie)).Returns(true);
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||
// var result = await Rule.Execute(request);
|
||||
[Fact]
|
||||
public async Task Should_ReturnSuccess_WhenRequestingMovieWithMovieRole()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestMovie)).Returns(true);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.Movie };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, true);
|
||||
// }
|
||||
Assert.Equal(result.Success, true);
|
||||
}
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnFail_WhenRequestingMovieWithoutMovieRole()
|
||||
// {
|
||||
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestMovie)).Returns(false);
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||
// var result = await Rule.Execute(request);
|
||||
[Fact]
|
||||
public async Task Should_ReturnFail_WhenRequestingMovieWithoutMovieRole()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestMovie)).Returns(false);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.Movie };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, false);
|
||||
// Assert.Equal(string.IsNullOrEmpty(result.Message), false);
|
||||
// }
|
||||
Assert.Equal(result.Success, false);
|
||||
Assert.Equal(string.IsNullOrEmpty(result.Message), false);
|
||||
}
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnSuccess_WhenRequestingMovieWithAdminRole()
|
||||
// {
|
||||
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||
// var result = await Rule.Execute(request);
|
||||
[Fact]
|
||||
public async Task Should_ReturnSuccess_WhenRequestingMovieWithAdminRole()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.Movie };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, true);
|
||||
// }
|
||||
Assert.Equal(result.Success, true);
|
||||
}
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnSuccess_WhenRequestingTVWithAdminRole()
|
||||
// {
|
||||
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||
// var result = await Rule.Execute(request);
|
||||
[Fact]
|
||||
public async Task Should_ReturnSuccess_WhenRequestingTVWithAdminRole()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.TvShow };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, true);
|
||||
// }
|
||||
Assert.Equal(result.Success, true);
|
||||
}
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnSuccess_WhenRequestingTVWithTVRole()
|
||||
// {
|
||||
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestTv)).Returns(true);
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||
// var result = await Rule.Execute(request);
|
||||
[Fact]
|
||||
public async Task Should_ReturnSuccess_WhenRequestingTVWithTVRole()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestTv)).Returns(true);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.TvShow };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, true);
|
||||
// }
|
||||
Assert.Equal(result.Success, true);
|
||||
}
|
||||
|
||||
// [Fact]
|
||||
// public async Task Should_ReturnFail_WhenRequestingTVWithoutTVRole()
|
||||
// {
|
||||
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestTv)).Returns(false);
|
||||
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||
// var result = await Rule.Execute(request);
|
||||
[Fact]
|
||||
public async Task Should_ReturnFail_WhenRequestingTVWithoutTVRole()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestTv)).Returns(false);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.TvShow };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
// Assert.Equal(result.Success, false);
|
||||
// Assert.Equal(string.IsNullOrEmpty(result.Message), false);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Assert.Equal(result.Success, false);
|
||||
Assert.Equal(string.IsNullOrEmpty(result.Message), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue