Refactor core data classes (#671)
This commit is contained in:
parent
ab453580ad
commit
d1de81d919
24 changed files with 605 additions and 433 deletions
|
|
@ -16,7 +16,8 @@ final class PasswordStoreTest: XCTestCase {
|
|||
private let remoteRepoURL = URL(string: "https://github.com/mssun/passforios-password-store.git")!
|
||||
|
||||
func testCloneAndDecryptMultiKeys() throws {
|
||||
let url = URL(fileURLWithPath: "\(Globals.repositoryPath)-test")
|
||||
let url = Globals.sharedContainerURL.appendingPathComponent("Library/password-store-test/")
|
||||
|
||||
Defaults.isEnableGPGIDOn = true
|
||||
let passwordStore = PasswordStore(url: url)
|
||||
try passwordStore.cloneRepository(remoteRepoURL: remoteRepoURL, branchName: "master")
|
||||
|
|
@ -42,7 +43,7 @@ final class PasswordStoreTest: XCTestCase {
|
|||
let work = try decrypt(passwordStore: passwordStore, path: "work/github.com.gpg", passphrase: "passforios")
|
||||
XCTAssertEqual(work.plainText, "passwordforwork\n")
|
||||
|
||||
let testPassword = Password(name: "test", url: URL(string: "test.gpg")!, plainText: "testpassword")
|
||||
let testPassword = Password(name: "test", path: "test.gpg", plainText: "testpassword")
|
||||
let testPasswordEntity = try passwordStore.add(password: testPassword)!
|
||||
let testPasswordPlain = try passwordStore.decrypt(passwordEntity: testPasswordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||
XCTAssertEqual(testPasswordPlain.plainText, "testpassword")
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ final class PasswordTest: XCTestCase {
|
|||
func testURL() {
|
||||
let password = getPasswordObjectWith(content: "")
|
||||
|
||||
XCTAssertEqual(password.url, PASSWORD_URL)
|
||||
XCTAssertEqual(password.path, PASSWORD_PATH)
|
||||
XCTAssertEqual(password.namePath, PASSWORD_PATH)
|
||||
}
|
||||
|
||||
|
|
@ -242,11 +242,17 @@ final class PasswordTest: XCTestCase {
|
|||
}
|
||||
|
||||
func testUsernameInPath() {
|
||||
let password = getPasswordObjectWith(content: "", url: URL(fileURLWithPath: "exampleservice/exampleusername.pgp"))
|
||||
let password = getPasswordObjectWith(content: "", path: "exampleservice/exampleusername.pgp")
|
||||
|
||||
XCTAssertEqual(password.nameFromPath, "exampleusername")
|
||||
}
|
||||
|
||||
func testDotInFilename() {
|
||||
let password = getPasswordObjectWith(content: "", path: "exampleservice/..pgp")
|
||||
|
||||
XCTAssertEqual(password.nameFromPath, ".")
|
||||
}
|
||||
|
||||
func testMultilineValues() {
|
||||
let lineBreakField = "with line breaks" => "|\n This is \n text spread over \n multiple lines! "
|
||||
let noLineBreakField = "without line breaks" => " > \n This is \n text spread over\n multiple lines!"
|
||||
|
|
@ -283,16 +289,16 @@ final class PasswordTest: XCTestCase {
|
|||
let password = getPasswordObjectWith(content: "")
|
||||
XCTAssertEqual(password.changed, 0)
|
||||
|
||||
password.updatePassword(name: "password", url: PASSWORD_URL, plainText: "")
|
||||
password.updatePassword(name: "password", path: PASSWORD_PATH, plainText: "")
|
||||
XCTAssertEqual(password.changed, 0)
|
||||
|
||||
password.updatePassword(name: "", url: PASSWORD_URL, plainText: "a")
|
||||
password.updatePassword(name: "", path: PASSWORD_PATH, plainText: "a")
|
||||
XCTAssertEqual(password.changed, 2)
|
||||
|
||||
password.updatePassword(name: "", url: URL(fileURLWithPath: "/some/path/"), plainText: "a")
|
||||
password.updatePassword(name: "", path: "/some/path/", plainText: "a")
|
||||
XCTAssertEqual(password.changed, 3)
|
||||
|
||||
password.updatePassword(name: "", url: PASSWORD_URL, plainText: "")
|
||||
password.updatePassword(name: "", path: PASSWORD_PATH, plainText: "")
|
||||
XCTAssertEqual(password.changed, 3)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue