-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allowed direct links to dash videos hosted on v.redd.it through.
- Loading branch information
1 parent
af70844
commit c5850eb
Showing
13 changed files
with
172 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using DiscordBot.Filters; | ||
using DiscordBot.Models; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace DiscordBot.Test; | ||
|
||
[TestClass] | ||
public class DomainBlacklistFilterTest | ||
{ | ||
[TestMethod] | ||
public async Task EnsureDirectDashLinksAreAllowed() | ||
{ | ||
var filter = new DomainBlacklistFilter(new UnitTestLogger<DomainBlacklistFilter>()); | ||
|
||
var shouldAllow = new SearchResult | ||
{ | ||
Url = "https://v.redd.it/123/DASH_720.mp4" | ||
}; | ||
var shouldDisallow = new SearchResult | ||
{ | ||
Url = "https://v.redd.it/123/" | ||
}; | ||
|
||
var allowed = await filter.Filter(new[] { shouldAllow }.ToAsyncEnumerable()).ToListAsync(); | ||
Assert.AreEqual(1, allowed.Count); | ||
|
||
var disallowed = await filter.Filter(new[] { shouldDisallow }.ToAsyncEnumerable()).ToListAsync(); | ||
Assert.AreEqual(0, disallowed.Count); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
|
||
namespace DiscordBot.Test; | ||
|
||
internal class UnitTestLogger<T> : ILogger<T> | ||
{ | ||
public void Log<TState>( | ||
LogLevel logLevel, | ||
EventId eventId, | ||
TState state, | ||
Exception? exception, | ||
Func<TState, Exception?, string> formatter) | ||
{ | ||
Console.WriteLine(formatter(state, exception)); | ||
} | ||
|
||
public bool IsEnabled(LogLevel logLevel) | ||
{ | ||
return true; | ||
} | ||
|
||
public IDisposable BeginScope<TState>(TState state) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// ReSharper disable UnusedMember.Global | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace DiscordBot.Pushshift.Models; | ||
|
||
public class Preview | ||
{ | ||
[JsonPropertyName("enabled")] | ||
public bool? Enabled { get; set; } | ||
[JsonPropertyName("reddit_video_preview")] | ||
public RedditVideoPreview? RedditVideoPreview { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace DiscordBot.Pushshift.Models; | ||
|
||
public class RedditVideoPreview | ||
{ | ||
[JsonPropertyName("fallback_url")] | ||
public string? FallbackUrl { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters