summaryrefslogtreecommitdiff
path: root/SoraTests
diff options
context:
space:
mode:
Diffstat (limited to 'SoraTests')
-rw-r--r--SoraTests/ViewDerivedDataTests.swift26
1 files changed, 20 insertions, 6 deletions
diff --git a/SoraTests/ViewDerivedDataTests.swift b/SoraTests/ViewDerivedDataTests.swift
index f844a7c..28fd59e 100644
--- a/SoraTests/ViewDerivedDataTests.swift
+++ b/SoraTests/ViewDerivedDataTests.swift
@@ -1094,6 +1094,10 @@ final class ViewDerivedDataTests: XCTestCase { // swiftlint:disable:this type_b
named: "private static func resolvedUserAgent(",
from: source
)
+ let refererResolverSection = try extractFunction(
+ named: "private static func baseReferer(for domain: String) -> String",
+ from: source
+ )
let requestURLSection = try extractFunction(
named: "func requestURL(_ url: URL) async throws -> Data",
from: source
@@ -1106,12 +1110,16 @@ final class ViewDerivedDataTests: XCTestCase { // swiftlint:disable:this type_b
matching: #"customUserAgent\.trimmingCharacters"#,
in: userAgentResolverSection
)
- let optionalHeaderMappingCount = tokenCount(
- matching: #"userAgent\.map"#,
+ let refererFormatCount = tokenCount(
+ matching: #""https://\\\#\(domain\)/""#,
+ in: refererResolverSection
+ )
+ let refererHeaderCount = tokenCount(
+ matching: #"HTTPHeader\(name:\s*"Referer",\s*value:\s*referer\)"#,
in: requestURLSection
)
let explicitUserAgentHeaderCount = tokenCount(
- matching: #"HTTPHeader\(name:\s*"User-Agent",\s*value:\s*value\)"#,
+ matching: #"headers\.add\(name:\s*"User-Agent",\s*value:\s*userAgent\)"#,
in: requestURLSection
)
@@ -1135,15 +1143,21 @@ final class ViewDerivedDataTests: XCTestCase { // swiftlint:disable:this type_b
)
// swiftlint:disable:next prefer_nimble
XCTAssertGreaterThan(
- optionalHeaderMappingCount,
+ refererFormatCount,
+ 0,
+ "BooruManager should derive booru Referer headers from the provider base URL with a trailing slash."
+ )
+ // swiftlint:disable:next prefer_nimble
+ XCTAssertGreaterThan(
+ refererHeaderCount,
0,
- "BooruManager should only attach request headers when a User-Agent is available."
+ "BooruManager should always attach a Referer header for booru requests."
)
// swiftlint:disable:next prefer_nimble
XCTAssertGreaterThan(
explicitUserAgentHeaderCount,
0,
- "BooruManager should keep using the User-Agent header name for booru requests."
+ "BooruManager should continue attaching the User-Agent header only when available."
)
}