Use SwiftFormat version 0.49.x and enable some new rules (#527)
This commit is contained in:
parent
b62c5fa2e5
commit
cdedff0d4d
32 changed files with 139 additions and 126 deletions
|
|
@ -88,7 +88,7 @@ class PGPAgentTest: XCTestCase {
|
|||
}
|
||||
|
||||
func testNoPrivateKey() throws {
|
||||
try KeyFileManager(keyType: PgpKey.PUBLIC, keyPath: "", keyHandler: keychain.add).importKey(from: RSA2048.publicKey)
|
||||
try KeyFileManager(keyType: PGPKey.PUBLIC, keyPath: "", keyHandler: keychain.add).importKey(from: RSA2048.publicKey)
|
||||
XCTAssertFalse(pgpAgent.isPrepared)
|
||||
XCTAssertThrowsError(try pgpAgent.initKeys()) {
|
||||
XCTAssertEqual($0 as! AppError, AppError.keyImport)
|
||||
|
|
@ -126,8 +126,8 @@ class PGPAgentTest: XCTestCase {
|
|||
try importKeys(ED25519.publicKey, ED25519.privateKey)
|
||||
XCTAssert(pgpAgent.isPrepared)
|
||||
XCTAssertEqual(try basicEncryptDecrypt(using: pgpAgent, keyID: ED25519.fingerprint), testData)
|
||||
keychain.removeContent(for: PgpKey.PUBLIC.getKeychainKey())
|
||||
keychain.removeContent(for: PgpKey.PRIVATE.getKeychainKey())
|
||||
keychain.removeContent(for: PGPKey.PUBLIC.getKeychainKey())
|
||||
keychain.removeContent(for: PGPKey.PRIVATE.getKeychainKey())
|
||||
XCTAssertThrowsError(try basicEncryptDecrypt(using: pgpAgent, keyID: ED25519.fingerprint)) {
|
||||
XCTAssertEqual($0 as! AppError, AppError.keyImport)
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ class PGPAgentTest: XCTestCase {
|
|||
}
|
||||
|
||||
private func importKeys(_ publicKey: String, _ privateKey: String) throws {
|
||||
try KeyFileManager(keyType: PgpKey.PUBLIC, keyPath: "", keyHandler: keychain.add).importKey(from: publicKey)
|
||||
try KeyFileManager(keyType: PgpKey.PRIVATE, keyPath: "", keyHandler: keychain.add).importKey(from: privateKey)
|
||||
try KeyFileManager(keyType: PGPKey.PUBLIC, keyPath: "", keyHandler: keychain.add).importKey(from: publicKey)
|
||||
try KeyFileManager(keyType: PGPKey.PRIVATE, keyPath: "", keyHandler: keychain.add).importKey(from: privateKey)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import XCTest
|
|||
|
||||
class KeyFileManagerTest: XCTestCase {
|
||||
private static let filePath = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("test.txt").path
|
||||
private static let keyFileManager = KeyFileManager(keyType: PgpKey.PUBLIC, keyPath: filePath) { _, _ in }
|
||||
private static let keyFileManager = KeyFileManager(keyType: PGPKey.PUBLIC, keyPath: filePath) { _, _ in }
|
||||
|
||||
override func tearDown() {
|
||||
try? FileManager.default.removeItem(atPath: Self.filePath)
|
||||
|
|
@ -22,39 +22,39 @@ class KeyFileManagerTest: XCTestCase {
|
|||
func testImportKeyFromFileSharing() throws {
|
||||
let fileContent = "content".data(using: .ascii)
|
||||
var storage: [String: String] = [:]
|
||||
let keyFileManager = KeyFileManager(keyType: PgpKey.PRIVATE, keyPath: Self.filePath) { storage[$1] = $0 }
|
||||
let keyFileManager = KeyFileManager(keyType: PGPKey.PRIVATE, keyPath: Self.filePath) { storage[$1] = $0 }
|
||||
|
||||
FileManager.default.createFile(atPath: Self.filePath, contents: fileContent, attributes: nil)
|
||||
try keyFileManager.importKeyFromFileSharing()
|
||||
|
||||
XCTAssertFalse(FileManager.default.fileExists(atPath: Self.filePath))
|
||||
XCTAssertEqual(storage[PgpKey.PRIVATE.getKeychainKey()], "content")
|
||||
XCTAssertEqual(storage[PGPKey.PRIVATE.getKeychainKey()], "content")
|
||||
}
|
||||
|
||||
func testErrorReadingFile() throws {
|
||||
XCTAssertThrowsError(try Self.keyFileManager.importKeyFromFileSharing())
|
||||
}
|
||||
|
||||
func testImportKeyFromUrl() throws {
|
||||
func testImportKeyFromURL() throws {
|
||||
let fileContent = "content".data(using: .ascii)
|
||||
let url = URL(fileURLWithPath: Self.filePath)
|
||||
var storage: [String: String] = [:]
|
||||
let keyFileManager = KeyFileManager(keyType: PgpKey.PRIVATE, keyPath: Self.filePath) { storage[$1] = $0 }
|
||||
let keyFileManager = KeyFileManager(keyType: PGPKey.PRIVATE, keyPath: Self.filePath) { storage[$1] = $0 }
|
||||
|
||||
FileManager.default.createFile(atPath: Self.filePath, contents: fileContent, attributes: nil)
|
||||
try keyFileManager.importKey(from: url)
|
||||
|
||||
XCTAssertEqual(storage[PgpKey.PRIVATE.getKeychainKey()], "content")
|
||||
XCTAssertEqual(storage[PGPKey.PRIVATE.getKeychainKey()], "content")
|
||||
}
|
||||
|
||||
func testImportKeyFromString() throws {
|
||||
let string = "content"
|
||||
var storage: [String: String] = [:]
|
||||
let keyFileManager = KeyFileManager(keyType: PgpKey.PRIVATE, keyPath: Self.filePath) { storage[$1] = $0 }
|
||||
let keyFileManager = KeyFileManager(keyType: PGPKey.PRIVATE, keyPath: Self.filePath) { storage[$1] = $0 }
|
||||
|
||||
try keyFileManager.importKey(from: string)
|
||||
|
||||
XCTAssertEqual(storage[PgpKey.PRIVATE.getKeychainKey()], string)
|
||||
XCTAssertEqual(storage[PGPKey.PRIVATE.getKeychainKey()], string)
|
||||
}
|
||||
|
||||
func testImportKeyFromNonAsciiString() throws {
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ class PasswordStoreTest: XCTestCase {
|
|||
}
|
||||
|
||||
let keychain = AppKeychain.shared
|
||||
try KeyFileManager(keyType: PgpKey.PUBLIC, keyPath: "", keyHandler: keychain.add).importKey(from: RSA2048_RSA4096.publicKeys)
|
||||
try KeyFileManager(keyType: PgpKey.PRIVATE, keyPath: "", keyHandler: keychain.add).importKey(from: RSA2048_RSA4096.privateKeys)
|
||||
try KeyFileManager(keyType: PGPKey.PUBLIC, keyPath: "", keyHandler: keychain.add).importKey(from: RSA2048_RSA4096.publicKeys)
|
||||
try KeyFileManager(keyType: PGPKey.PRIVATE, keyPath: "", keyHandler: keychain.add).importKey(from: RSA2048_RSA4096.privateKeys)
|
||||
try PGPAgent.shared.initKeys()
|
||||
|
||||
let personal = try decrypt(passwordStore: passwordStore, path: "personal/github.com.gpg", passphrase: "passforios")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import XCTest
|
|||
@testable import passKit
|
||||
|
||||
class PasswordTest: XCTestCase {
|
||||
func testUrl() {
|
||||
func testURL() {
|
||||
let password = getPasswordObjectWith(content: "")
|
||||
|
||||
XCTAssertEqual(password.url, PASSWORD_URL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue