support reading several key IDs in .gpg-id files
This commit is contained in:
parent
566b7253f5
commit
77f85ccdd1
8 changed files with 19 additions and 9 deletions
|
|
@ -410,7 +410,7 @@ public class PasswordStore {
|
|||
}
|
||||
if Defaults.isEnableGPGIDOn {
|
||||
let encryptedDataPath = password.fileURL(in: storeURL)
|
||||
return [findGPGID(from: encryptedDataPath)]
|
||||
return findGPGIDs(from: encryptedDataPath)
|
||||
}
|
||||
return []
|
||||
}()
|
||||
|
|
@ -461,7 +461,7 @@ extension PasswordStore {
|
|||
}
|
||||
}
|
||||
|
||||
func findGPGID(from url: URL) -> String {
|
||||
func findGPGIDs(from url: URL) -> [String] {
|
||||
var path = url
|
||||
while !FileManager.default.fileExists(atPath: path.appendingPathComponent(".gpg-id").path),
|
||||
path.path != "file:///" {
|
||||
|
|
@ -469,5 +469,9 @@ func findGPGID(from url: URL) -> String {
|
|||
}
|
||||
path = path.appendingPathComponent(".gpg-id")
|
||||
|
||||
return (try? String(contentsOf: path))?.trimmed ?? ""
|
||||
let allKeysSeparatedByNewline = (try? String(contentsOf: path)) ?? ""
|
||||
return allKeysSeparatedByNewline
|
||||
.split(separator: "\n")
|
||||
.map { String($0).trimmed }
|
||||
.filter { !$0.isEmpty }
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
xÌ1€ @k^áBˆI(9BíŒÿïÔj»]÷³öl›EUM×™C{ÏlDˆ+=r¢ŠÚKd¬8.4†u Ùy: nç—ˆKyº1F
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
x<01>ŽAjÄ0sÖ+æbF#Y¶ „< Ç|@òŒm‘]ÙHrÀy}ÌB><3E>C_
|
||||
º»¦í~O
ÒS+"@ÆÚyÔÚ…h}`ƒÌÞ±'1èEGãEöP$7ðÔKÄÙEíi¤ØÏyÄñŠ£h£8f«ƒ
|
||||
G[·g
9Ãg ù{;ä^oòÞþH'Çèa0d{DϨÕôðlòÿU×K™<4B>S<EFBFBD>5T ø’³BÊÐ-ûò’BfHÂ’ÚzÄ9ÝRÉS9÷vÕã qk«úõ–cJ
|
||||
|
|
@ -0,0 +1 @@
|
|||
c7c52ac6962d08d69e5651eedd6cbaf2f8bd05c3
|
||||
|
|
@ -32,7 +32,7 @@ final class PasswordStoreTest: XCTestCase {
|
|||
try cloneRepository(.withGPGID)
|
||||
|
||||
XCTAssertEqual(passwordStore.numberOfPasswords, 4)
|
||||
XCTAssertEqual(passwordStore.numberOfCommits, 16)
|
||||
XCTAssertEqual(passwordStore.numberOfCommits, 17)
|
||||
XCTAssertEqual(passwordStore.numberOfLocalCommits, 0)
|
||||
|
||||
let entity = passwordStore.fetchPasswordEntity(with: "personal/github.com.gpg")
|
||||
|
|
@ -319,11 +319,12 @@ final class PasswordStoreTest: XCTestCase {
|
|||
Defaults.isEnableGPGIDOn = true
|
||||
|
||||
[
|
||||
("work/github.com", "4712286271220DB299883EA7062E678DA1024DAE"),
|
||||
("personal/github.com", "787EAE1A5FA3E749AA34CC6AA0645EBED862027E"),
|
||||
].forEach { path, id in
|
||||
let keyID = findGPGID(from: localRepoURL.appendingPathComponent(path))
|
||||
XCTAssertEqual(keyID, id)
|
||||
("work/github.com", ["4712286271220DB299883EA7062E678DA1024DAE"]),
|
||||
("personal/github.com", ["787EAE1A5FA3E749AA34CC6AA0645EBED862027E"]),
|
||||
("shared/github.com", ["4712286271220DB299883EA7062E678DA1024DAE", "787EAE1A5FA3E749AA34CC6AA0645EBED862027E"]),
|
||||
].forEach { path, keyIDs in
|
||||
let foundKeyIDs = findGPGIDs(from: localRepoURL.appendingPathComponent(path))
|
||||
XCTAssertEqual(foundKeyIDs, keyIDs)
|
||||
}
|
||||
|
||||
let personal = try decrypt(path: "personal/github.com.gpg")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue