2020-11-26 21:08:53 +00:00
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.Datastore
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class SortKeyValidationFixture : DbTest
|
|
|
|
{
|
|
|
|
[TestCase("amissingcolumn")]
|
|
|
|
[TestCase("amissingtable.id")]
|
|
|
|
[TestCase("table.table.column")]
|
|
|
|
[TestCase("column; DROP TABLE Commands;--")]
|
|
|
|
public void should_return_false_for_invalid_sort_key(string sortKey)
|
|
|
|
{
|
|
|
|
TableMapping.Mapper.IsValidSortKey(sortKey).Should().BeFalse();
|
|
|
|
}
|
|
|
|
|
2022-11-22 01:51:00 +00:00
|
|
|
// [TestCase("artists.sortName")] TODO: Figure out why Artists table properties don't get mapped
|
2020-11-26 21:08:53 +00:00
|
|
|
[TestCase("Id")]
|
|
|
|
[TestCase("id")]
|
|
|
|
[TestCase("commands.id")]
|
|
|
|
public void should_return_true_for_valid_sort_key(string sortKey)
|
|
|
|
{
|
|
|
|
TableMapping.Mapper.IsValidSortKey(sortKey).Should().BeTrue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|