mirror of https://github.com/Ombi-app/Ombi
#865 rework the backend data. Actually use real models rather than a JSON store.
parent
08e389f590
commit
2bc916998c
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||||
|
// Use hover for the description of the existing attributes
|
||||||
|
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": ".NET Core Launch (web)",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
// If you have changed target frameworks, make sure to update the program path.
|
||||||
|
"program": "${workspaceRoot}/Ombi/bin/Debug/netcoreapp1.1/Ombi.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceRoot}/Ombi",
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
|
"launchBrowser": {
|
||||||
|
"enabled": true,
|
||||||
|
"args": "${auto-detect-url}",
|
||||||
|
"windows": {
|
||||||
|
"command": "cmd.exe",
|
||||||
|
"args": "/C start ${auto-detect-url}"
|
||||||
|
},
|
||||||
|
"osx": {
|
||||||
|
"command": "open"
|
||||||
|
},
|
||||||
|
"linux": {
|
||||||
|
"command": "xdg-open"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"sourceFileMap": {
|
||||||
|
"/Views": "${workspaceRoot}/Views"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach",
|
||||||
|
"processId": "${command:pickProcess}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"version": "0.1.0",
|
||||||
|
"command": "dotnet",
|
||||||
|
"isShellCommand": true,
|
||||||
|
"args": [],
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"taskName": "build",
|
||||||
|
"args": [
|
||||||
|
"${workspaceRoot}/Ombi/Ombi.csproj"
|
||||||
|
],
|
||||||
|
"isBuildCommand": true,
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,89 +1,89 @@
|
|||||||
using System.Security.Principal;
|
//using System.Security.Principal;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
using Moq;
|
//using Moq;
|
||||||
using Ombi.Core.Claims;
|
//using Ombi.Core.Claims;
|
||||||
using Ombi.Core.Models.Requests;
|
//using Ombi.Core.Models.Requests;
|
||||||
using Ombi.Core.Rule.Rules;
|
//using Ombi.Core.Rule.Rules;
|
||||||
using Ombi.Core.Rule.Rules.Request;
|
//using Ombi.Core.Rule.Rules.Request;
|
||||||
using Xunit;
|
//using Xunit;
|
||||||
|
|
||||||
namespace Ombi.Core.Tests.Rule
|
//namespace Ombi.Core.Tests.Rule
|
||||||
{
|
//{
|
||||||
public class AutoApproveRuleTests
|
// public class AutoApproveRuleTests
|
||||||
{
|
// {
|
||||||
public AutoApproveRuleTests()
|
// public AutoApproveRuleTests()
|
||||||
{
|
// {
|
||||||
PrincipalMock = new Mock<IPrincipal>();
|
// PrincipalMock = new Mock<IPrincipal>();
|
||||||
Rule = new AutoApproveRule(PrincipalMock.Object);
|
// Rule = new AutoApproveRule(PrincipalMock.Object);
|
||||||
}
|
// }
|
||||||
|
|
||||||
private AutoApproveRule Rule { get; }
|
// private AutoApproveRule Rule { get; }
|
||||||
private Mock<IPrincipal> PrincipalMock { get; }
|
// private Mock<IPrincipal> PrincipalMock { get; }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnSuccess_WhenAdminAndRequestMovie()
|
// public async Task Should_ReturnSuccess_WhenAdminAndRequestMovie()
|
||||||
{
|
// {
|
||||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, true);
|
// Assert.Equal(result.Success, true);
|
||||||
Assert.Equal(request.Approved, true);
|
// Assert.Equal(request.Approved, true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnSuccess_WhenAdminAndRequestTV()
|
// public async Task Should_ReturnSuccess_WhenAdminAndRequestTV()
|
||||||
{
|
// {
|
||||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, true);
|
// Assert.Equal(result.Success, true);
|
||||||
Assert.Equal(request.Approved, true);
|
// Assert.Equal(request.Approved, true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnSuccess_WhenAutoApproveMovieAndRequestMovie()
|
// public async Task Should_ReturnSuccess_WhenAutoApproveMovieAndRequestMovie()
|
||||||
{
|
// {
|
||||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.AutoApproveMovie)).Returns(true);
|
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.AutoApproveMovie)).Returns(true);
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, true);
|
// Assert.Equal(result.Success, true);
|
||||||
Assert.Equal(request.Approved, true);
|
// Assert.Equal(request.Approved, true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnSuccess_WhenAutoApproveTVAndRequestTV()
|
// public async Task Should_ReturnSuccess_WhenAutoApproveTVAndRequestTV()
|
||||||
{
|
// {
|
||||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.AutoApproveTv)).Returns(true);
|
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.AutoApproveTv)).Returns(true);
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, true);
|
// Assert.Equal(result.Success, true);
|
||||||
Assert.Equal(request.Approved, true);
|
// Assert.Equal(request.Approved, true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnFail_WhenNoClaimsAndRequestMovie()
|
// public async Task Should_ReturnFail_WhenNoClaimsAndRequestMovie()
|
||||||
{
|
// {
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, true);
|
// Assert.Equal(result.Success, true);
|
||||||
Assert.Equal(request.Approved, false);
|
// Assert.Equal(request.Approved, false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnFail_WhenNoClaimsAndRequestTV()
|
// public async Task Should_ReturnFail_WhenNoClaimsAndRequestTV()
|
||||||
{
|
// {
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, true);
|
// Assert.Equal(result.Success, true);
|
||||||
Assert.Equal(request.Approved, false);
|
// Assert.Equal(request.Approved, false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,84 +1,84 @@
|
|||||||
using System.Security.Principal;
|
//using System.Security.Principal;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
using Moq;
|
//using Moq;
|
||||||
using Ombi.Core.Claims;
|
//using Ombi.Core.Claims;
|
||||||
using Ombi.Core.Models.Requests;
|
//using Ombi.Core.Models.Requests;
|
||||||
using Ombi.Core.Rule.Rules;
|
//using Ombi.Core.Rule.Rules;
|
||||||
using Xunit;
|
//using Xunit;
|
||||||
|
|
||||||
namespace Ombi.Core.Tests.Rule
|
//namespace Ombi.Core.Tests.Rule
|
||||||
{
|
//{
|
||||||
public class CanRequestRuleTests
|
// public class CanRequestRuleTests
|
||||||
{
|
// {
|
||||||
public CanRequestRuleTests()
|
// public CanRequestRuleTests()
|
||||||
{
|
// {
|
||||||
PrincipalMock = new Mock<IPrincipal>();
|
// PrincipalMock = new Mock<IPrincipal>();
|
||||||
Rule = new CanRequestRule(PrincipalMock.Object);
|
// Rule = new CanRequestRule(PrincipalMock.Object);
|
||||||
}
|
// }
|
||||||
|
|
||||||
private CanRequestRule Rule { get; }
|
// private CanRequestRule Rule { get; }
|
||||||
private Mock<IPrincipal> PrincipalMock { get; }
|
// private Mock<IPrincipal> PrincipalMock { get; }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnSuccess_WhenRequestingMovieWithMovieRole()
|
// public async Task Should_ReturnSuccess_WhenRequestingMovieWithMovieRole()
|
||||||
{
|
// {
|
||||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestMovie)).Returns(true);
|
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestMovie)).Returns(true);
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, true);
|
// Assert.Equal(result.Success, true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnFail_WhenRequestingMovieWithoutMovieRole()
|
// public async Task Should_ReturnFail_WhenRequestingMovieWithoutMovieRole()
|
||||||
{
|
// {
|
||||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestMovie)).Returns(false);
|
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestMovie)).Returns(false);
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, false);
|
// Assert.Equal(result.Success, false);
|
||||||
Assert.Equal(string.IsNullOrEmpty(result.Message), false);
|
// Assert.Equal(string.IsNullOrEmpty(result.Message), false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnSuccess_WhenRequestingMovieWithAdminRole()
|
// public async Task Should_ReturnSuccess_WhenRequestingMovieWithAdminRole()
|
||||||
{
|
// {
|
||||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.Movie };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, true);
|
// Assert.Equal(result.Success, true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnSuccess_WhenRequestingTVWithAdminRole()
|
// public async Task Should_ReturnSuccess_WhenRequestingTVWithAdminRole()
|
||||||
{
|
// {
|
||||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.Admin)).Returns(true);
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, true);
|
// Assert.Equal(result.Success, true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnSuccess_WhenRequestingTVWithTVRole()
|
// public async Task Should_ReturnSuccess_WhenRequestingTVWithTVRole()
|
||||||
{
|
// {
|
||||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestTv)).Returns(true);
|
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestTv)).Returns(true);
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, true);
|
// Assert.Equal(result.Success, true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task Should_ReturnFail_WhenRequestingTVWithoutTVRole()
|
// public async Task Should_ReturnFail_WhenRequestingTVWithoutTVRole()
|
||||||
{
|
// {
|
||||||
PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestTv)).Returns(false);
|
// PrincipalMock.Setup(x => x.IsInRole(OmbiClaims.RequestTv)).Returns(false);
|
||||||
var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
// var request = new BaseRequestModel() { Type = Store.Entities.RequestType.TvShow };
|
||||||
var result = await Rule.Execute(request);
|
// var result = await Rule.Execute(request);
|
||||||
|
|
||||||
Assert.Equal(result.Success, false);
|
// Assert.Equal(result.Success, false);
|
||||||
Assert.Equal(string.IsNullOrEmpty(result.Message), false);
|
// Assert.Equal(string.IsNullOrEmpty(result.Message), false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
Loading…
Reference in new issue