Get username from filepath. (#265)
This commit is contained in:
parent
b154c04178
commit
c59c72729b
3 changed files with 12 additions and 1 deletions
|
|
@ -164,7 +164,7 @@ class ExtensionViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
var decryptedPassword: Password?
|
var decryptedPassword: Password?
|
||||||
do {
|
do {
|
||||||
decryptedPassword = try self.passwordStore.decrypt(passwordEntity: passwordEntity, requestPGPKeyPassphrase: self.requestPGPKeyPassphrase)
|
decryptedPassword = try self.passwordStore.decrypt(passwordEntity: passwordEntity, requestPGPKeyPassphrase: self.requestPGPKeyPassphrase)
|
||||||
let username = decryptedPassword?.username ?? decryptedPassword?.login ?? ""
|
let username = decryptedPassword?.username ?? decryptedPassword?.login ?? decryptedPassword?.nameFromPath ?? ""
|
||||||
let password = decryptedPassword?.password ?? ""
|
let password = decryptedPassword?.password ?? ""
|
||||||
DispatchQueue.main.async {// prepare a dictionary to return
|
DispatchQueue.main.async {// prepare a dictionary to return
|
||||||
switch self.extensionAction {
|
switch self.extensionAction {
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,10 @@ public class Password {
|
||||||
return url.deletingPathExtension().path
|
return url.deletingPathExtension().path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var nameFromPath: String? {
|
||||||
|
return url.deletingPathExtension().path.split(separator: "/").last.map { String($0) }
|
||||||
|
}
|
||||||
|
|
||||||
public var password: String {
|
public var password: String {
|
||||||
return parser.firstLine
|
return parser.firstLine
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,13 @@ class PasswordTest: XCTestCase {
|
||||||
XCTAssert(MULTILINE_LINE_START.title => "" ∈ password)
|
XCTAssert(MULTILINE_LINE_START.title => "" ∈ password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testUsernameInPath() {
|
||||||
|
let password = getPasswordObjectWith(content: "", url: URL(fileURLWithPath: "exampleservice/exampleusername.pgp"))
|
||||||
|
|
||||||
|
XCTAssertEqual(password.nameFromPath, "exampleusername")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func testMultilineValues() {
|
func testMultilineValues() {
|
||||||
let lineBreakField = "with line breaks" => "|\n This is \n text spread over \n multiple lines! "
|
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!"
|
let noLineBreakField = "without line breaks" => " > \n This is \n text spread over\n multiple lines!"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue