Skip to content

Commit

Permalink
Rewrite new beta auth
Browse files Browse the repository at this point in the history
  • Loading branch information
ImoutoChan committed Oct 3, 2023
1 parent 3a1dda2 commit b579e0b
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ public class SankakuLoaderFixture
private readonly IOptions<SankakuSettings> _authorizedOptions = Options.Create(
new SankakuSettings
{
SaveTokensCallbackAsync = tokens =>
{
Console.WriteLine($"new token: {tokens.AccessToken}, {tokens.RefreshToken}");
return Task.CompletedTask;
},
PauseBetweenRequestsInMs = 1,
Login = "testuser159",
//PassHash = "69f56a924a71774358c31e9233fc8e3c9a1b7d55",
Password = "testuser159"
});

Expand Down
52 changes: 45 additions & 7 deletions Imouto.BooruParser.Tests/Loaders/SankakuLoaderTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FluentAssertions;
using Imouto.BooruParser.Extensions;
using Imouto.BooruParser.Implementations;
using Imouto.BooruParser.Implementations.Sankaku;
using Imouto.BooruParser.Tests.Loaders.Fixtures;
using Xunit;

Expand Down Expand Up @@ -113,6 +114,43 @@ public async Task ShouldGetPostByMd5Async()
post.FileSizeInBytes.Should().Be(617163);
post.UgoiraFrameDelays.Should().BeEmpty();
}

[Fact]
public async Task ShouldGetPostByMd5Async_2a00599e108817e0d9a4eb2e3f353abb()
{
var loader = _loaderFixture.GetLoaderWithAuth();

var post = await loader.GetPostByMd5Async("dc9da74597ecd47b2848fb4d68fce77a");

post.Should().NotBeNull();
post!.OriginalUrl.Should().StartWith("https://v.sankakucomplex.com/data/dc/9d/dc9da74597ecd47b2848fb4d68fce77a.mp4");
post.Id.Id.Should().Be(34486935);
post.Id.Md5Hash.Should().Be("dc9da74597ecd47b2848fb4d68fce77a");
post.Notes.Should().BeEmpty();
post.Tags.Should().HaveCount(75);

foreach (var postTag in post.Tags)
{
postTag.Name.Should().NotBeNullOrWhiteSpace();
postTag.Type.Should().NotBeNullOrWhiteSpace();
postTag.Type.Should().BeOneOf(new[] { "meta", "general", "copyright", "character", "circle", "artist", "medium", "genre" });
}

post.Parent.Should().BeNull();
post.Pools.Should().HaveCount(0);
post.Rating.Should().Be(Rating.Explicit);
post.RatingSafeLevel.Should().Be(RatingSafeLevel.None);
post.Source.Should().Be("");
post.ChildrenIds.Should().BeEmpty();
post.ExistState.Should().Be(ExistState.Exist);
post.FileResolution.Should().Be(new Size(1644, 1862));
post.PostedAt.Should().Be(new DateTimeOffset(2023, 09, 29, 5, 54, 09, 0, TimeSpan.Zero));
post.SampleUrl.Should().StartWith("https://v.sankakucomplex.com/data/dc/9d/dc9da74597ecd47b2848fb4d68fce77a.mp4");
post.UploaderId.Id.Should().Be(568254);
post.UploaderId.Name.Should().Be("Just_some_guy");
post.FileSizeInBytes.Should().Be(22152413);
post.UgoiraFrameDelays.Should().BeEmpty();
}

[Fact]
public async Task ShouldContainLinkWithoutAmp()
Expand Down Expand Up @@ -176,7 +214,7 @@ public GetTagHistoryFirstPageAsyncMethod(SankakuLoaderFixture loaderFixture)
{
}

[Fact(Skip = "only local invokation")]
[Fact]
public void ShouldThrowWithoutCredentials()
{
var loader = _loaderFixture.GetLoaderWithoutAuth();
Expand All @@ -186,7 +224,7 @@ public void ShouldThrowWithoutCredentials()
action.Should().ThrowAsync<HttpRequestException>();
}

[Fact(Skip = "only local invokation")]
[Fact]
public async Task ShouldReturnWithCredentials()
{
var loader = _loaderFixture.GetLoaderWithAuth();
Expand All @@ -204,7 +242,7 @@ public GetTagHistoryToDateTimeAsyncMethod(SankakuLoaderFixture loaderFixture)
{
}

[Fact(Skip = "only local invokation")]
[Fact]
public void ShouldNotLoadTagsHistoryToDateWithoutCredentials()
{
var loader = _loaderFixture.GetLoaderWithoutAuth();
Expand All @@ -215,7 +253,7 @@ public void ShouldNotLoadTagsHistoryToDateWithoutCredentials()
action.Should().ThrowAsync<HttpRequestException>();
}

[Fact(Skip = "only local invokation")]
[Fact]
public async Task ShouldLoadTagsHistoryToDateWithCredentials()
{
var loader = _loaderFixture.GetLoaderWithAuth();
Expand All @@ -232,7 +270,7 @@ public GetTagHistoryFromIdToPresentAsyncMethod(SankakuLoaderFixture loaderFixtur
{
}

[Fact(Skip = "only local invokation")]
[Fact]
public async Task ShouldLoadTagsHistoryFromIdWithCredentials()
{
var loader = _loaderFixture.GetLoaderWithAuth();
Expand All @@ -244,7 +282,7 @@ public async Task ShouldLoadTagsHistoryFromIdWithCredentials()
notesHistory.Should().NotBeEmpty();
}

[Fact(Skip = "only local invokation")]
[Fact]
public async Task ShouldLoadTagsHistoryFromIdAndHaveAllDataWithCredentials()
{
var loader = _loaderFixture.GetLoaderWithAuth();
Expand Down Expand Up @@ -398,7 +436,7 @@ public FavoritePostAsyncMethod(SankakuLoaderFixture loaderFixture)
{
}

[Fact(Skip = "Auth is required")]
[Fact]
public async Task ShouldFavoritePost()
{
var api = _loaderFixture.GetAccessorWithAuth();
Expand Down
138 changes: 0 additions & 138 deletions Imouto.BooruParser.Tests/SankakuAuthManagerTests.cs

This file was deleted.

Loading

0 comments on commit b579e0b

Please sign in to comment.