diff options
| author | Fuwn <[email protected]> | 2026-02-23 08:20:28 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-23 08:21:50 -0800 |
| commit | 13762193cf21624e6bab5e8f3c12ace320e39661 (patch) | |
| tree | b99599caa5062c2bf2f363168262e41ebc26b788 /SoraTests | |
| parent | chore: deduplicate project build settings in xcodegen spec (diff) | |
| download | sora-testing-13762193cf21624e6bab5e8f3c12ace320e39661.tar.xz sora-testing-13762193cf21624e6bab5e8f3c12ace320e39661.zip | |
fix: use Danbooru login/api_key query auth
Diffstat (limited to 'SoraTests')
| -rw-r--r-- | SoraTests/ViewDerivedDataTests.swift | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/SoraTests/ViewDerivedDataTests.swift b/SoraTests/ViewDerivedDataTests.swift index bc3a998..ed83654 100644 --- a/SoraTests/ViewDerivedDataTests.swift +++ b/SoraTests/ViewDerivedDataTests.swift @@ -1,6 +1,6 @@ import XCTest -final class ViewDerivedDataTests: XCTestCase { +final class ViewDerivedDataTests: XCTestCase { // swiftlint:disable:this type_body_length func testGenericListViewDerivedCollectionsAreReferencedOncePerRenderPass() throws { let source = try loadSource(at: "Sora/Views/Generic/GenericListView.swift") let normalizedSource = strippingCommentsAndStrings(from: source) @@ -267,6 +267,35 @@ final class ViewDerivedDataTests: XCTestCase { ) } + func testBooruManagerDanbooruPostsUseQueryParamAuthentication() throws { + let source = try loadSource(at: "Sora/Data/Booru/BooruManager.swift") + let urlBuilderSection = try extractFunction( + named: "func url(forPosts page: Int, limit: Int, tags: [String]) -> URL?", + from: source + ) + let danbooruLoginQueryCount = tokenCount( + matching: #"case\s+\.danbooru[\s\S]*URLQueryItem\(name:\s*"login""#, + in: urlBuilderSection + ) + let danbooruAPIKeyQueryCount = tokenCount( + matching: #"case\s+\.danbooru[\s\S]*URLQueryItem\(name:\s*"api_key""#, + in: urlBuilderSection + ) + + // swiftlint:disable:next prefer_nimble + XCTAssertGreaterThan( + danbooruLoginQueryCount, + 0, + "Danbooru requests should authenticate with a `login` query parameter." + ) + // swiftlint:disable:next prefer_nimble + XCTAssertGreaterThan( + danbooruAPIKeyQueryCount, + 0, + "Danbooru requests should authenticate with an `api_key` query parameter." + ) + } + func testThumbnailGridViewAvoidsDirectColumnArrayIndexing() throws { let source = try loadSource(at: "Sora/Views/Shared/ThumbnailGridView.swift") let normalizedSource = strippingCommentsAndStrings(from: source) |