feat(ios): unify list cards and loading states
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import XCTest
|
||||
|
||||
@testable import MultiSimAdmin
|
||||
|
||||
final class FileCredentialStoreTests: XCTestCase {
|
||||
func testSavesReadsAndRemovesPasswordInSandboxFile() throws {
|
||||
let location = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("credential-store-\(UUID().uuidString).json")
|
||||
let store = FileCredentialStore(location: location)
|
||||
let instanceID = UUID()
|
||||
|
||||
XCTAssertNil(try store.get(instanceID: instanceID))
|
||||
|
||||
try store.set(instanceID: instanceID, password: "sandbox-secret")
|
||||
XCTAssertEqual(try store.get(instanceID: instanceID), "sandbox-secret")
|
||||
XCTAssertTrue(FileManager.default.fileExists(atPath: location.path))
|
||||
|
||||
try store.remove(instanceID: instanceID)
|
||||
XCTAssertNil(try store.get(instanceID: instanceID))
|
||||
}
|
||||
|
||||
func testCredentialFileIsPrivate() throws {
|
||||
let location = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("credential-store-\(UUID().uuidString).json")
|
||||
let store = FileCredentialStore(location: location)
|
||||
|
||||
try store.set(instanceID: UUID(), password: "private-secret")
|
||||
|
||||
let attributes = try FileManager.default.attributesOfItem(atPath: location.path)
|
||||
XCTAssertEqual(attributes[.posixPermissions] as? Int, 0o600)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user