Files
Qiu YuzhouandDeepSeek Harness e7116a5ebd test: merge duplicated cases into the stronger one
Every case here restates a rule another test already pins with the same or a
wider input class:

- the activation group case is byte-identical to its neighbour, minus an extra
  assertion; the rule snapshot version guard is re-driven with a second value
  of the same schemaVersion check; the global-mode deployment-failure case is
  a mode-literal copy of the strictly stronger direct-mode one; the clear-
  failure case duplicates the deferred-retry sibling
- two RuntimeDocument projection cases only re-map locals, already asserted as
  full array equality; the IPv6-LAN endpoint case repeats the direct-mode case
  (the derivation reads only ports)
- the three HTTP export cases varied only listenerMode while the derivation
  ignores it and one name contradicted its own expectation; one loop over all
  listener modes now states the real rule
- the 0700/0600 permission baseline is one AtomicFileWriter behavior and stays
  pinned through RuntimeFileStoreTests, which also covers self-heal and atomic
  replace

The command-boundary case keeps its mixed-scenario isolation check (four
commands, four independent adapter counters) and drops only its unfalsifiable
queriedTargetIDs claim.

Co-Authored-By: DeepSeek Harness <noreply@deepseek.com>
2026-10-21 01:46:29 +08:00

51 lines
1.8 KiB
Swift

import Foundation
import XCTest
@testable import ShadowsocksX_NG2
/// Built-in modes keep a stable selector order and project local proxy settings.
final class ProxyModeAvailabilityTests: XCTestCase {
func testBuiltInModesAreAlwaysAvailableInProductOrder() {
XCTAssertEqual(
ProxyMode.availableModes.map(\.kind),
[.rule, .global, .direct])
}
func testDirectModeUsesLocalSOCKSAndIncludesFixedBypasses() {
let document = SslocalRuntimeDocument(servers: [], listen: ProxyListeningConfiguration())
let configuration = ProxyMode.direct.systemProxyConfiguration(for: document)
XCTAssertEqual(
configuration.socks,
.init(host: "127.0.0.1", port: ProxyListeningConfiguration.defaultSocksPort))
XCTAssertEqual(
configuration.http,
.init(host: "127.0.0.1", port: ProxyListeningConfiguration.defaultHTTPPort))
XCTAssertEqual(
configuration.exceptions,
FixedLocalProxyRanges.systemProxyExceptions)
}
/// 全局模式:系统 SOCKS/HTTP 投影 + 固定本地例外,与直连共用
/// 同一安全范围;公网路由由 ACL 决定,不由系统例外决定。
func testGlobalModeUsesLocalSOCKSAndIncludesFixedBypasses() {
let document = SslocalRuntimeDocument(servers: [], listen: ProxyListeningConfiguration())
let configuration = ProxyMode.global.systemProxyConfiguration(for: document)
XCTAssertEqual(
configuration.socks,
.init(host: "127.0.0.1", port: ProxyListeningConfiguration.defaultSocksPort))
XCTAssertEqual(
configuration.http,
.init(host: "127.0.0.1", port: ProxyListeningConfiguration.defaultHTTPPort))
XCTAssertEqual(
configuration.exceptions,
FixedLocalProxyRanges.systemProxyExceptions)
XCTAssertFalse(
configuration.exceptions.contains("100.64.0.0/10"),
"不加入 CGNAT")
}
}