mirror of
https://github.com/shadowsocks/ShadowsocksX-NG.git
synced 2026-11-08 10:54:50 +00:00
Six sites re-asserted the predicate waitUntilRuntimeSettles already checks, with no suspension point in between, so they could never fail; their intent messages are folded into comments where one was not already stated. Two commit-failure cases asserted the fake's bookkeeping (updateCalls stays empty) which the fake guarantees by throwing before recording; the outcome and committed-snapshot assertions already prove the real behavior. Also drop a no-op loop that mutated a discarded struct copy, a duplicated isWellFormed line, two WorkspaceRoute cases subsumed by the constructor and the publish-count case, a duplicated presentation-message assertion, and the round-trip halves of two payload-shape cases already covered case-by-case. Co-Authored-By: DeepSeek Harness <noreply@deepseek.com>
60 lines
1.8 KiB
Swift
60 lines
1.8 KiB
Swift
import Foundation
|
|
import XCTest
|
|
|
|
@testable import ShadowsocksX_NG2
|
|
|
|
/// 订阅刷新失败的 durable seam:只观察可演进的安全事实,不观察文案或
|
|
/// transient Error 的实现细节。
|
|
final class SubscriptionRefreshFailureTests: XCTestCase {
|
|
func testAllDurableFailureFactsRoundTrip() throws {
|
|
let failures: [SubscriptionRefreshFailure] = [
|
|
.invalidURL,
|
|
.unsupportedScheme,
|
|
.insecureRedirect,
|
|
.transport(.timedOut),
|
|
.transport(.tls),
|
|
.transport(.connection),
|
|
.transport(.unknown),
|
|
.httpStatus(code: 503),
|
|
.contentType(.missing),
|
|
.contentType(.unsupported),
|
|
.decodingFailure,
|
|
.unsupportedSchemaVersion,
|
|
.missingServers,
|
|
.recordValidation(index: 3, field: .address),
|
|
.recordValidation(index: 3, field: .port),
|
|
.recordValidation(index: 3, field: .method),
|
|
.recordValidation(index: 3, field: .password),
|
|
.recordValidation(index: 3, field: .identity),
|
|
.duplicateIdentity,
|
|
.commit,
|
|
.unknown,
|
|
]
|
|
|
|
for failure in failures {
|
|
let data = try JSONEncoder().encode(failure)
|
|
XCTAssertEqual(try JSONDecoder().decode(SubscriptionRefreshFailure.self, from: data), failure)
|
|
}
|
|
}
|
|
|
|
func testHTTPStatusFailurePayloadOmitsInternalReason() throws {
|
|
let failure = SubscriptionRefreshFailure.httpStatus(code: 503)
|
|
|
|
let data = try JSONEncoder().encode(failure)
|
|
|
|
let json = String(bytes: data, encoding: .utf8) ?? ""
|
|
XCTAssertFalse(json.contains("reason"))
|
|
}
|
|
|
|
func testPartialRollbackIsCoarseAndContainsNoCredentialReferences() throws {
|
|
let failure = SubscriptionRefreshFailure.commit
|
|
|
|
let data = try JSONEncoder().encode(failure)
|
|
|
|
let json = String(bytes: data, encoding: .utf8) ?? ""
|
|
XCTAssertFalse(json.contains("credential"))
|
|
XCTAssertFalse(json.contains("reference"))
|
|
}
|
|
|
|
}
|