feat: improve runtime setup and guidance

This commit is contained in:
xweiba
2026-08-08 15:18:40 +08:00
parent 3499f080d7
commit b07fa61195
54 changed files with 1794 additions and 325 deletions
@@ -0,0 +1,72 @@
import XCTest
@testable import PaopaoLocationSpoofer
final class AppRemoteConfigurationTests: XCTestCase {
func testDecodesReadableJSONAndClientPromptSwitches() throws {
let data = """
{
"latestVersion": "1.2.0",
"minimumSupportedVersion": "1.1.0",
"communityPromptClients": ["surge", "loon"]
}
""".data(using: .utf8)!
let configuration = try AppRemoteConfiguration.decode(data)
XCTAssertEqual(configuration.latestVersion, "1.2.0")
XCTAssertTrue(configuration.requestsCommunityPrompt(for: .surge))
XCTAssertTrue(configuration.requestsCommunityPrompt(for: .loon))
XCTAssertFalse(configuration.requestsCommunityPrompt(for: .stash))
XCTAssertFalse(configuration.requestsCommunityPrompt(for: .shadowrocket))
}
func testVersionPolicyDistinguishesRequiredRecommendedAndCurrent() throws {
let configuration = AppRemoteConfiguration(
latestVersion: "1.2.0",
minimumSupportedVersion: "1.1.0",
communityPromptClients: []
)
XCTAssertEqual(
configuration.updatePrompt(currentVersion: "1.0.9")?.requirement,
.required
)
XCTAssertEqual(
configuration.updatePrompt(currentVersion: "1.1.0")?.requirement,
.recommended
)
XCTAssertNil(configuration.updatePrompt(currentVersion: "1.2.0"))
XCTAssertNil(configuration.updatePrompt(currentVersion: "1.2.0.0"))
}
func testRejectsInvalidVersionsAndUnknownClients() {
let invalidVersion = """
{
"latestVersion": "1.0.0",
"minimumSupportedVersion": "2.0.0",
"communityPromptClients": []
}
""".data(using: .utf8)!
XCTAssertThrowsError(try AppRemoteConfiguration.decode(invalidVersion))
let invalidClient = """
{
"latestVersion": "2.0.0",
"minimumSupportedVersion": "1.0.0",
"communityPromptClients": ["unknown"]
}
""".data(using: .utf8)!
XCTAssertThrowsError(try AppRemoteConfiguration.decode(invalidClient))
}
func testFallbackMatchesCurrentProjectPolicy() {
let configuration = AppRemoteConfiguration.fallback
XCTAssertEqual(configuration.latestVersion, "1.0.2")
XCTAssertEqual(configuration.minimumSupportedVersion, "1.0.0")
XCTAssertFalse(configuration.requestsCommunityPrompt(for: .shadowrocket))
for client in ThirdPartyProxyClient.allCases where client != .shadowrocket {
XCTAssertTrue(configuration.requestsCommunityPrompt(for: client))
}
}
}
@@ -97,6 +97,28 @@ final class CertificateAuthorityStoreTests: XCTestCase {
XCTAssertTrue(FileManager.default.fileExists(atPath: directory.appendingPathComponent("ca-key.pem").path))
}
func testResetRemovesKeychainAndLegacyAuthority() throws {
let directory = try makeLegacyDirectory(authority: validAuthority)
let keychain = InMemoryCertificateAuthorityKeychain()
keychain.stored = validAuthority
let store = makeStore(directory: directory, keychain: keychain) { self.validAuthority }
try store.reset()
XCTAssertNil(keychain.stored)
XCTAssertFalse(FileManager.default.fileExists(atPath: directory.path))
}
func testResetFailurePreservesKeychainAuthority() {
let keychain = InMemoryCertificateAuthorityKeychain()
keychain.stored = validAuthority
keychain.shouldFailRemove = true
let store = makeStore(keychain: keychain) { self.validAuthority }
XCTAssertThrowsError(try store.reset())
XCTAssertEqual(keychain.stored, validAuthority)
}
private func makeStore(
directory: URL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString),
keychain: InMemoryCertificateAuthorityKeychain,
@@ -121,11 +143,13 @@ final class CertificateAuthorityStoreTests: XCTestCase {
private enum CertificateAuthorityStoreTestError: Error {
case saveFailed
case removeFailed
}
private final class InMemoryCertificateAuthorityKeychain: CertificateAuthorityKeychain {
var stored: CertificateAuthority?
var shouldFailSave = false
var shouldFailRemove = false
func load() throws -> CertificateAuthority? { stored }
@@ -135,6 +159,7 @@ private final class InMemoryCertificateAuthorityKeychain: CertificateAuthorityKe
}
func remove() throws {
guard !shouldFailRemove else { throw CertificateAuthorityStoreTestError.removeFailed }
stored = nil
}
}
@@ -5,16 +5,52 @@ import XCTest
final class ProxyRuntimeModeTests: XCTestCase {
func testDefaultsToLocalWiFiAndPersistsThirdPartyMode() {
let suiteName = "ProxyRuntimeModeTests.\(UUID().uuidString)"
let legacySuiteName = "ProxyRuntimeModeLegacyTests.\(UUID().uuidString)"
let defaults = UserDefaults(suiteName: suiteName)!
defer { defaults.removePersistentDomain(forName: suiteName) }
let legacyDefaults = UserDefaults(suiteName: legacySuiteName)!
defer {
defaults.removePersistentDomain(forName: suiteName)
legacyDefaults.removePersistentDomain(forName: legacySuiteName)
}
let initial = ProxyRuntimeModeStore(defaults: defaults)
let initial = ProxyRuntimeModeStore(defaults: defaults, legacyDefaults: legacyDefaults)
XCTAssertEqual(initial.mode, .localWiFi)
XCTAssertFalse(initial.hasSelectedMode)
XCTAssertFalse(initial.isInitialized(.localWiFi))
XCTAssertFalse(initial.isInitialized(.thirdParty))
initial.setMode(.thirdParty)
let restored = ProxyRuntimeModeStore(defaults: defaults)
initial.markInitialized(.thirdParty)
let restored = ProxyRuntimeModeStore(defaults: defaults, legacyDefaults: legacyDefaults)
XCTAssertEqual(restored.mode, .thirdParty)
XCTAssertTrue(restored.hasSelectedMode)
XCTAssertFalse(restored.isInitialized(.localWiFi))
XCTAssertTrue(restored.isInitialized(.thirdParty))
restored.resetInitialization(.thirdParty)
XCTAssertFalse(restored.isInitialized(.thirdParty))
}
func testMigratesOnlyCurrentLegacyCompletedMode() {
let suiteName = "ProxyRuntimeModeMigrationTests.\(UUID().uuidString)"
let legacySuiteName = "ProxyRuntimeModeMigrationLegacyTests.\(UUID().uuidString)"
let defaults = UserDefaults(suiteName: suiteName)!
let legacyDefaults = UserDefaults(suiteName: legacySuiteName)!
defer {
defaults.removePersistentDomain(forName: suiteName)
legacyDefaults.removePersistentDomain(forName: legacySuiteName)
}
defaults.set(ProxyRuntimeMode.thirdParty.rawValue, forKey: "proxyRuntimeMode")
defaults.set(true, forKey: "hasSelectedProxyRuntimeMode")
legacyDefaults.set(true, forKey: "setupCompleted")
let migrated = ProxyRuntimeModeStore(defaults: defaults, legacyDefaults: legacyDefaults)
XCTAssertFalse(migrated.isInitialized(.localWiFi))
XCTAssertTrue(migrated.isInitialized(.thirdParty))
migrated.setMode(.localWiFi)
XCTAssertFalse(migrated.isInitialized(.localWiFi))
XCTAssertTrue(migrated.isInitialized(.thirdParty))
}
}
@@ -33,16 +33,50 @@ final class SetupCoordinatorTests: XCTestCase {
XCTAssertEqual(coordinator.setupStep, .proxy)
}
func testWiFiChangeMapsLocalProxyStartFailureToProxyReminder() {
XCTAssertEqual(VerificationResult.proxyNotRunning.wifiChangeReminderTipKind, .proxySetup)
func testExplicitCertificateRequestRoutesToCertificateStep() {
let coordinator = SetupCoordinator()
coordinator.requestCertificateSetup()
XCTAssertTrue(coordinator.needsSetup)
XCTAssertEqual(coordinator.setupStep, .cert)
}
func testWiFiChangeDoesNotPresentFailureForConcurrentVerification() {
XCTAssertNil(VerificationResult.verificationInProgress.wifiChangeReminderTipKind)
func testThirdPartyFailureRequestPreservesErrorAndRoutesToImportGuide() {
let coordinator = SetupCoordinator()
coordinator.requestThirdPartySetup(message: "模块未连接")
XCTAssertTrue(coordinator.needsSetup)
XCTAssertEqual(coordinator.setupStep, .thirdPartyImport)
XCTAssertEqual(coordinator.message, "模块未连接")
}
func testWiFiChangeCertificateFailureDoesNotUseGenericReminder() {
XCTAssertNil(VerificationResult.certNotTrusted.wifiChangeReminderTipKind)
XCTAssertNil(VerificationResult.certNotTrusted.tipKind)
func testThirdPartyOnboardingStartsWithClientSelection() {
let coordinator = SetupCoordinator()
coordinator.requestThirdPartyOnboarding()
XCTAssertTrue(coordinator.needsSetup)
XCTAssertEqual(coordinator.setupStep, .thirdPartyClient)
XCTAssertTrue(coordinator.message.isEmpty)
}
func testProxyFailurePreservesResultForPresentedGuide() {
let coordinator = SetupCoordinator()
coordinator.applyVerificationResult(.proxyNotRunning)
XCTAssertEqual(coordinator.lastVerificationResult, .proxyNotRunning)
XCTAssertTrue(coordinator.needsSetup)
XCTAssertEqual(coordinator.setupStep, .proxy)
}
func testConcurrentVerificationDoesNotOpenGuide() {
let coordinator = SetupCoordinator()
coordinator.applyVerificationResult(.verificationInProgress)
XCTAssertFalse(coordinator.needsSetup)
}
}
@@ -0,0 +1,50 @@
import XCTest
@testable import PaopaoLocationSpoofer
final class ThirdPartyCommunityPromptPreferencesTests: XCTestCase {
private var suites: [String] = []
override func tearDown() {
for suite in suites {
UserDefaults.standard.removePersistentDomain(forName: suite)
}
suites.removeAll()
super.tearDown()
}
func testSuppressionBecomesAvailableOnThirdPresentation() {
let preferences = ThirdPartyCommunityPromptPreferences(defaults: makeDefaults())
XCTAssertEqual(preferences.recordPresentation(), 1)
XCTAssertFalse(preferences.canSuppress())
XCTAssertEqual(preferences.recordPresentation(), 2)
XCTAssertFalse(preferences.canSuppress())
XCTAssertEqual(preferences.recordPresentation(), 3)
XCTAssertTrue(preferences.canSuppress())
}
func testEarlySuppressionIsIgnoredAndThirdPresentationCanPersistIt() {
let defaults = makeDefaults()
let preferences = ThirdPartyCommunityPromptPreferences(defaults: defaults)
preferences.recordPresentation()
preferences.suppress()
XCTAssertTrue(preferences.shouldPresent())
preferences.recordPresentation()
preferences.recordPresentation()
preferences.suppress()
XCTAssertFalse(preferences.shouldPresent())
let restored = ThirdPartyCommunityPromptPreferences(defaults: defaults)
XCTAssertFalse(restored.shouldPresent())
}
private func makeDefaults() -> UserDefaults {
let suite = "ThirdPartyCommunityPromptPreferencesTests.\(UUID().uuidString)"
suites.append(suite)
let defaults = UserDefaults(suiteName: suite)!
defaults.removePersistentDomain(forName: suite)
return defaults
}
}
@@ -66,8 +66,8 @@ final class ThirdPartyProxyManagerTests: XCTestCase {
}
func testClientLinksUseOfficialUpstreamModulesAndVerificationLabels() {
XCTAssertEqual(ThirdPartyProxyClient.shadowrocket.verificationText, "当前可测试")
XCTAssertTrue(ThirdPartyProxyClient.surge.verificationText.contains("尚未验证"))
XCTAssertNil(ThirdPartyProxyClient.shadowrocket.verificationText)
XCTAssertTrue(ThirdPartyProxyClient.surge.verificationText?.contains("尚未验证") == true)
XCTAssertEqual(ThirdPartyProxyClient.egern.subscriptionURL, ThirdPartyProxyClient.surge.subscriptionURL)
XCTAssertTrue(ThirdPartyProxyClient.stash.subscriptionURL.absoluteString.hasSuffix("/modules/wloc.stoverride"))
XCTAssertTrue(ThirdPartyProxyClient.shadowrocket.subscriptionURL.absoluteString.hasSuffix("/modules/wloc.module"))
+28
View File
@@ -8,6 +8,34 @@ fail() { echo "FAIL: $*" >&2; exit 1; }
test -f "$ROOT/App/ProxyManager.swift" || fail "ProxyManager must exist"
test -f "$ROOT/Shared/RuntimeLog.swift" || fail "RuntimeLog must exist"
test -f "$ROOT/App/RealtimeLocationManager.swift" || fail "RealtimeLocationManager must exist"
grep -q 'Location Spoofer CA' "$ROOT/App/FirstSetupView.swift" || fail "certificate setup must use the stable app-branded CA name"
! grep -q 'WLOC CA' "$ROOT/App/FirstSetupView.swift" || fail "certificate setup must not show the legacy dated CA name"
grep -q 'localWiFiRuntimeModeInitialized' "$ROOT/Shared/ProxyRuntimeMode.swift" || fail "APP mode initialization must persist independently"
grep -q 'thirdPartyRuntimeModeInitialized' "$ROOT/Shared/ProxyRuntimeMode.swift" || fail "third-party mode initialization must persist independently"
! grep -q 'runVerificationTest' "$ROOT/App/ContentView.swift" || fail "normal app startup must not run the environment verification test"
grep -q '重置证书' "$ROOT/App/SettingsView.swift" || fail "APP mode settings must expose certificate reset"
grep -q 'certificateStore.reset()' "$ROOT/App/SettingsView.swift" || fail "certificate reset must remove the persisted app CA"
grep -q 'requestCertificateSetup()' "$ROOT/App/SettingsView.swift" || fail "certificate reset must open the certificate setup flow"
grep -q 'requestThirdPartySetup(message:' "$ROOT/App/SettingsView.swift" || fail "third-party settings failures must open the setup guide"
grep -q 'SFSafariViewController' "$ROOT/App/SafariView.swift" || fail "certificate download must use an in-app Safari service"
grep -q 'prepareCertificateDownloadURL' "$ROOT/App/FirstSetupView.swift" || fail "certificate setup must prepare an in-app download URL"
! grep -q 'UIApplication.shared.open(url' "$ROOT/App/ProxyManager.swift" || fail "certificate download must not force an external browser"
grep -q 'AppModeWiFiProxy' "$ROOT/App/FirstSetupView.swift" || fail "APP proxy setup must show the Wi-Fi screenshot"
grep -q 'AppModeCertificateInstall' "$ROOT/App/FirstSetupView.swift" || fail "certificate install setup must show its screenshot"
grep -q 'AppModeCertificateTrust' "$ROOT/App/FirstSetupView.swift" || fail "certificate trust setup must show its screenshot"
grep -q 'UIImage(named: assetName)' "$ROOT/App/FirstSetupView.swift" || fail "missing screenshots must fall back to text without breaking setup"
for asset in AppModeWiFiProxy AppModeCertificateInstall AppModeCertificateTrust; do
test -s "$ROOT/Resources/Assets.xcassets/$asset.imageset/Contents.json" \
|| fail "missing APP onboarding image asset: $asset"
grep -q '\.jpg' "$ROOT/Resources/Assets.xcassets/$asset.imageset/Contents.json" \
|| fail "APP onboarding derivatives must use an Asset Catalog-supported JPEG: $asset"
done
test -s "$ROOT/docs/onboarding-screenshots/app-mode/app-mode-wifi-proxy.jpg" \
|| fail "unannotated APP-mode source screenshots must be retained by mode"
test -s "$ROOT/docs/app-icon-source.svg" || fail "the optimized app icon must retain an editable vector source"
test -s "$ROOT/Resources/Assets.xcassets/AppIcon.appiconset/AppIcon.png" \
|| fail "the optimized 1024px app icon is missing"
# VPNManager and Tunnel must NOT exist
test ! -f "$ROOT/App/VPNManager.swift" || fail "VPNManager must be removed"
+13 -3
View File
@@ -4,6 +4,12 @@ set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
fail() { echo "FAIL: $*" >&2; exit 1; }
TIP_VIEWS="$ROOT/App/TipViews.swift"
grep -Fq 'Label("还是无法生效?"' "$TIP_VIEWS" || fail "activation help must use the requested retry heading"
grep -Fq 'Label("还是无法取消?"' "$TIP_VIEWS" || fail "deactivation help must use a mode-specific retry heading"
grep -q 'frame(maxWidth: .infinity, alignment: .leading)' "$TIP_VIEWS" \
|| fail "tip detail copy must align to the leading edge"
MAP_HOME="$ROOT/App/MapHomeView.swift"
MAP_STATE="$ROOT/App/MapLocationState.swift"
MAP_BRIDGE="$ROOT/App/MapViewRepresentable.swift"
@@ -91,11 +97,15 @@ grep -q '地图创建前请求实时定位' "$CONTENT" || fail "fresh realtime p
grep -q 'minimumCountForSuppression = 3' Shared/AppGroup.swift || fail "automatic tip suppression must require three successful operations"
grep -q 'activeTip = .deactivation' "$MAP_HOME" || fail "manual deactivation help must use the non-suppressible generic tip sheet"
grep -q 'stabilizationNanoseconds: UInt64 = 3_000_000_000' "$MAP_HOME" || fail "Wi-Fi changes must wait three seconds before environment verification"
grep -q 'result.wifiChangeReminderTipKind' "$MAP_HOME" || fail "Wi-Fi proxy failures must use the background reminder mapping"
grep -q 'if result == .certNotTrusted' "$MAP_HOME" || fail "Wi-Fi certificate failures must enter certificate setup"
grep -q 'setup.applyVerificationResult(result)' "$MAP_HOME" || fail "Wi-Fi certificate failures must use the setup routing reducer"
! grep -q 'wifiChangeReminderTipKind' "$MAP_HOME" || fail "Wi-Fi failures must not use a duplicate reminder mapping"
grep -q 'setup.requestSetup(message:' "$MAP_HOME" || fail "missing Wi-Fi must enter the reusable proxy setup guide"
test "$(grep -c 'setup.applyVerificationResult(result)' "$MAP_HOME")" -ge 2 \
|| fail "activation and Wi-Fi-change verification failures must use the shared setup reducer"
! grep -q 'activeTip = \.proxySetup' "$MAP_HOME" || fail "proxy failures must not use a duplicate tip sheet"
! grep -q 'case certificate' "$ROOT/App/TipViews.swift" || fail "generic certificate tip must not coexist with certificate setup"
! grep -q 'CertificateTipContent' "$ROOT/App/TipViews.swift" || fail "certificate failures must use the complete setup flow"
! grep -q 'case proxySetup' "$ROOT/App/TipViews.swift" || fail "proxy failures must use the complete setup flow"
! grep -q 'case rewriteFailed' "$ROOT/App/TipViews.swift" || fail "rewrite failures must use the complete setup flow"
! grep -q 'onChange(of: net.isAirplaneMode)' "$MAP_HOME" || fail "airplane recovery must not race the Wi-Fi change verifier"
grep -q 'hasReceivedInitialPath' "$NETWORK_MONITOR" || fail "initial network path must not be reported as a Wi-Fi switch"
grep -q 'lastKnownSSID' "$NETWORK_MONITOR" || fail "SSID polling must preserve a baseline across temporary nil readings"
+8
View File
@@ -52,6 +52,14 @@ test "$(grep -c '^## ' "$ZH")" -eq "$(grep -c '^## ' "$EN")" \
! grep -Eq '^## (许可证|License)$' "$ZH" "$EN" || fail "README must not claim a repository license"
grep -q '当前项目不支持在 Windows 上直接构建 iOS 应用' "$ZH" || fail "Chinese README must reject Windows source builds"
grep -q 'Building the iOS app directly on Windows is not supported' "$EN" || fail "English README must reject Windows source builds"
grep -q 'docs/COMMUNITY_TUTORIALS.md' "$ZH" || fail "Chinese README must link the community tutorial submission guide"
grep -q '除敏感信息遮挡外,不要自行添加箭头、编号、边框、说明文字或其他标注' \
"$ROOT/docs/COMMUNITY_TUTORIALS.md" \
|| fail "tutorial submissions must keep source screenshots free of non-privacy annotations"
grep -q '同一张截图可以对应多个步骤' "$ROOT/docs/COMMUNITY_TUTORIALS.md" \
|| fail "tutorial submissions must explain multi-step screenshot handling"
grep -q '不得覆盖上述原图' "$ROOT/docs/COMMUNITY_TUTORIALS.md" \
|| fail "annotated app assets must not replace categorized source screenshots"
if grep -Rnw --include='*.md' --include='*.sh' \
"$ROOT/build.sh" "$ROOT/README.md" "$ROOT/README.en.md" "$ROOT/docs" "$ROOT/Scripts" \
+61 -2
View File
@@ -18,10 +18,12 @@ grep -q 'guard runtimeMode.hasSelectedMode else' "$CONTENT" || fail "mode select
grep -q 'phase = .setup' "$CONTENT" || fail "first launch must enter setup before map construction"
grep -q 'case thirdPartyClient' "$SETUP" || fail "third-party client selection step is missing"
grep -q 'case thirdPartyImport' "$SETUP" || fail "third-party import step is missing"
grep -q 'case thirdPartyTest' "$SETUP" || fail "third-party connection test step is missing"
! grep -q 'case thirdPartyTest' "$SETUP" || fail "third-party connection test must be part of the import page"
! grep -q '生成并导入配置文件' "$SETUP" || fail "setup must not offer file generation/import"
grep -q '复制订阅地址' "$SETUP" || fail "subscription URL copy action is missing"
grep -q '复制模块订阅地址' "$SETUP" || fail "module subscription URL copy action is missing"
grep -Fq 'Label("打开 \(client.name)"' "$SETUP" || fail "setup must expose a client launch action"
grep -Fq 'Label("打开 \(client.name)"' "$SETUP" \
|| fail "the import page must expose the selected client launch action"
grep -Fq 'Label("打开 \(thirdPartyClient.selectedClient.name)"' "$SETTINGS" || fail "Settings must expose a client launch action"
! grep -q '在浏览器打开模块文件' "$SETTINGS" || fail "Settings must not open the module URL as the primary client action"
grep -q 'requestThirdPartySetup' "$SETTINGS" || fail "Settings must reopen third-party setup"
@@ -39,6 +41,63 @@ done
grep -q '复制解密域名' "$SETUP" || fail "Shadowrocket MITM hostname copy action is missing"
grep -q '配置 → 模块' "$SETUP" || fail "Shadowrocket module import guidance is missing"
grep -q 'HTTPS 解密' "$SETUP" || fail "Shadowrocket HTTPS decryption guidance is missing"
! grep -q '当前可测试' "$SETUP" || fail "Shadowrocket must not show the obsolete current-test label"
! grep -q '当前可测试' "$SETTINGS" || fail "Settings must not show the obsolete current-test label"
grep -q 'thirdPartyTestFailure = ThirdPartyConnectionTestFailure' "$SETUP" \
|| fail "third-party connection failures must render inline on the import page"
grep -q 'testResultView(' "$SETUP" || fail "APP and third-party tests must share the same result component"
grep -q 'showsVerificationResult = false' "$SETUP" \
|| fail "switching setup pages must hide the shared APP verification result"
grep -q 'showsThirdPartyFailureLog = false' "$SETUP" \
|| fail "switching setup pages must hide the shared third-party test log"
grep -q 'Label("查看诊断日志"' "$SETUP" \
|| fail "third-party connection failure must expose the diagnostics action"
! grep -q 'setupActionError = error.localizedDescription' "$SETUP" \
|| fail "third-party connection failure must not use the generic failure alert"
grep -q 'let response = try await thirdPartyProxy.query()' "$SETUP" \
|| fail "the import page must query the third-party module"
grep -A15 'let response = try await thirdPartyProxy.query()' "$SETUP" | grep -q 'onComplete()' \
|| fail "a successful third-party connection test must close setup immediately"
! grep -q 'thirdPartyTestResult?.success' "$SETUP" \
|| fail "a successful third-party test must not leave a separate completion state"
grep -q 'setupStep = \.thirdPartyImport' "$ROOT/App/SetupCoordinator.swift" \
|| fail "third-party runtime failures must route directly to the import guide"
grep -q 'setup.requestThirdPartySetup(message: error.localizedDescription)' "$ROOT/App/MapHomeView.swift" \
|| fail "third-party coordinate sync failures must open the import guide"
grep -q '检测到第三方代理连接异常,请检查模块、MITM 和代理连接后重新检测' "$SETUP" \
|| fail "runtime repair must explain why the import guide opened"
test "$(grep -c 'title: \"接口连接失败\"' "$SETUP")" -eq 1 \
|| fail "third-party failure details must render in one shared result area"
grep -Fq '当前客户端:\(client.name)' "$SETUP" \
|| fail "third-party failure logs must identify the selected client"
grep -q 'HStack(spacing: 12)' "$SETUP" || fail "setup footer actions must share one horizontal row"
grep -q 'Spacer(minLength: 12)' "$SETUP" || fail "setup footer actions must stay at opposite edges"
grep -q 'ScrollViewReader' "$SETUP" || fail "setup must keep failure results reachable after insertion"
grep -q 'scrollProxy.scrollTo("thirdPartyFailureLog"' "$SETUP" \
|| fail "third-party failure must scroll to the detailed log"
grep -q '======== 第三方代理连接检测 ========' "$SETUP" \
|| fail "third-party inline diagnostics must include a structured test log"
grep -Fq 'Label("第 2 步:完成 \(client.name) 配置"' "$SETUP" \
|| fail "unverified clients must use a two-step import and configuration guide"
grep -Fq 'Text("请在 \(client.name) 中完成相应配置。")' "$SETUP" \
|| fail "unverified client configuration guidance must avoid unverified menu details"
! grep -q '进入模块、重写或覆写订阅入口' "$SETUP" \
|| fail "unverified clients must not claim untested menu locations"
grep -q '"当前客户端": client.name' "$SETUP" \
|| fail "third-party runtime diagnostics must identify the selected client"
for asset in ShadowrocketModuleImport ShadowrocketConfigDetails ShadowrocketHTTPSDecryption ShadowrocketHTTPSCA; do
test -s "$ROOT/Resources/Assets.xcassets/$asset.imageset/Contents.json" \
|| fail "missing Shadowrocket onboarding image asset: $asset"
grep -q '\.jpg' "$ROOT/Resources/Assets.xcassets/$asset.imageset/Contents.json" \
|| fail "Shadowrocket onboarding derivatives must use an Asset Catalog-supported JPEG: $asset"
grep -q "$asset" "$SETUP" || fail "setup does not reference onboarding image asset: $asset"
done
config_line="$(grep -n 'assetName: "ShadowrocketConfigDetails"' "$SETUP" | head -n 1 | cut -d: -f1)"
module_line="$(grep -n 'assetName: "ShadowrocketModuleImport"' "$SETUP" | head -n 1 | cut -d: -f1)"
test "$config_line" -lt "$module_line" || fail "Shadowrocket setup must show the configuration page before the module page"
! grep -q 'GeometryReader' "$SETUP" || fail "onboarding image markers must be baked into assets, not positioned at runtime"
test -s "$ROOT/docs/onboarding-screenshots/shadowrocket/shadowrocket-module-import.jpg" \
|| fail "unannotated Shadowrocket source screenshots must be retained by client"
! grep -q 'ToolbarItem(placement: .navigationBarLeading)' "$SETUP" || fail "setup must not show a top-left navigation action"
grep -q 'presentSuccessfulOperationTip(.activation)' "$ROOT/App/MapHomeView.swift" || fail "third-party save must present the activation tip"
grep -q 'presentSuccessfulOperationTip(.deactivation)' "$ROOT/App/MapHomeView.swift" || fail "third-party clear must present the deactivation tip"
@@ -0,0 +1,83 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CONFIG="$ROOT/Shared/AppRemoteConfiguration.swift"
CONTENT="$ROOT/App/ContentView.swift"
MAP="$ROOT/App/MapHomeView.swift"
SETUP="$ROOT/App/FirstSetupView.swift"
SETTINGS="$ROOT/App/SettingsView.swift"
fail() {
echo "FAIL: $1" >&2
exit 1
}
python3 - "$ROOT/version.txt" <<'PY' || exit 1
import json
import sys
with open(sys.argv[1], encoding="utf-8") as handle:
config = json.load(handle)
assert config["latestVersion"] == "1.0.2"
assert config["minimumSupportedVersion"] == "1.0.0"
assert "shadowrocket" not in config["communityPromptClients"]
assert set(config["communityPromptClients"]) == {
"surge", "quantumultX", "loon", "stash", "egern"
}
PY
grep -q 'static let fallback = AppRemoteConfiguration' "$CONFIG" \
|| fail "the app must ship a built-in remote-configuration fallback"
grep -q 'timeoutIntervalForRequest = 1.5' "$CONFIG" \
|| fail "remote configuration requests must use a short timeout"
grep -q 'timeoutIntervalForResource = 2' "$CONFIG" \
|| fail "remote configuration resource loading must use a short timeout"
! grep -q 'data.count' "$CONFIG" \
|| fail "the client must not impose a remote configuration file-size limit"
grep -q 'docs/releases/v\\(version).md' "$CONFIG" \
|| fail "update notes must come from the archived release document"
grep -q '/releases/latest' "$CONFIG" \
|| fail "missing release notes must fall back to the latest Release page"
grep -q '.task { await checkForUpdates() }' "$CONTENT" \
|| fail "update detection must run asynchronously outside bootstrap"
! grep -A90 'private func bootstrap() async' "$CONTENT" | grep -q 'fetch()' \
|| fail "remote configuration must not block the startup gate"
grep -q '社区分享成功配置?' "$MAP" \
|| fail "non-Shadowrocket success must offer community contribution"
grep -q 'Button("去提交")' "$MAP" \
|| fail "community contribution prompt must expose the submit action"
grep -q 'Button("复制模板")' "$MAP" \
|| fail "community contribution prompt must expose an explicit copy action"
grep -q 'Button("取消", role: .cancel)' "$MAP" \
|| fail "the first community prompts must expose cancel"
grep -q 'Button("不再提示", role: .cancel)' "$MAP" \
|| fail "the third community prompt must allow permanent suppression"
grep -q '匿名收录,不在 README 展示投稿账号' "$MAP" \
|| fail "the contribution template must offer anonymous README attribution"
grep -q 'community-config,client-\\(client.rawValue)' "$MAP" \
|| fail "community submissions must be categorized by client labels"
grep -q 'UIPasteboard.general.string = communityContributionIssueBody' "$MAP" \
|| fail "the explicit copy action must copy the issue template"
! grep -A25 'private func openCommunityContributionIssue' "$MAP" | grep -q 'UIPasteboard.general.string' \
|| fail "opening GitHub must not copy the template automatically"
for obsolete in \
'我已配置,开始检测' \
'确认完成,重新检测' \
'下一步:导入配置' \
'我已导入,检测接口连接'; do
! grep -q "$obsolete" "$SETUP" \
|| fail "setup footer must not retain dynamic label: $obsolete"
done
test "$(grep -c 'actionLabel("完成")' "$SETUP")" -eq 4 \
|| fail "all setup footer primary actions must use the fixed 完成 label"
application_line="$(grep -n 'Section("应用")' "$SETTINGS" | head -n 1 | cut -d: -f1)"
certificate_line="$(grep -n 'Section("证书")' "$SETTINGS" | head -n 1 | cut -d: -f1)"
test "$application_line" -lt "$certificate_line" \
|| fail "the APP certificate reset section must appear below the application section"
echo "PASS: update and community contribution contract"