mirror of
https://github.com/luxfi/safe-ios.git
synced 2026-10-30 15:19:20 +00:00
- Added new SecureConfig package that encrypts/decrypts configuration in a JSON-based file - Added tooling to the project to read the encrypted config files at runtime - Documented how to add the config files in README - Removed variables from .xcconfig files and from info.plist - Replaced info.plist-based variables with protected config variables - Removed unused 'enfroce ssl pinning' build variable - Temporary enabled archiving to test the pipeline
26 lines
837 B
Swift
26 lines
837 B
Swift
import XCTest
|
|
@testable import SecureConfig
|
|
|
|
final class SecureConfigTests: XCTestCase {
|
|
func testIntegration() throws {
|
|
continueAfterFailure = false
|
|
|
|
let config = SecureConfig()
|
|
let plain = SecureConfig.PlainFile(["a": "b"])
|
|
let sealed = try config.encrypt(file: plain)
|
|
|
|
let dir = NSTemporaryDirectory()
|
|
try config.save(filename: dir + "/sealedbox", contents: sealed.file)
|
|
|
|
let file: SecureConfig.SealedFile = try config.load(filename: dir + "/sealedbox")
|
|
|
|
let keytext = config.string(from: sealed.key)
|
|
guard let key = config.key(from: keytext) else {
|
|
XCTFail("key conversion failed")
|
|
return
|
|
}
|
|
let derived = try config.decrypt(file: file, key: key)
|
|
XCTAssertEqual(derived, plain)
|
|
}
|
|
}
|