Add description field to OtpType
This commit is contained in:
parent
469451b7b7
commit
cfb50276bc
4 changed files with 43 additions and 14 deletions
|
|
@ -298,6 +298,29 @@ class PasswordTest: XCTestCase {
|
|||
XCTAssertEqual(password.changed, 3)
|
||||
}
|
||||
|
||||
func testOtpStringsNoOtpToken() {
|
||||
let password = getPasswordObjectWith(content: "")
|
||||
let otpStrings = password.getOtpStrings()
|
||||
|
||||
XCTAssertNil(otpStrings)
|
||||
}
|
||||
|
||||
func testOtpStringsTotpToken() {
|
||||
let password = getPasswordObjectWith(content: TOTP_URL)
|
||||
let otpStrings = password.getOtpStrings()
|
||||
|
||||
XCTAssertNotNil(otpStrings)
|
||||
XCTAssertTrue(otpStrings!.description.hasPrefix("time-based (expires in"))
|
||||
}
|
||||
|
||||
func testOtpStringsHotpToken() {
|
||||
let password = getPasswordObjectWith(content: HOTP_URL)
|
||||
let otpStrings = password.getOtpStrings()
|
||||
|
||||
XCTAssertNotNil(otpStrings)
|
||||
XCTAssertEqual(otpStrings!.description, "HMAC-based")
|
||||
}
|
||||
|
||||
private func getPasswordObjectWith(content: String, url: URL? = nil) -> Password {
|
||||
return Password(name: "password", url: url ?? PASSWORD_URL, plainText: content)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,4 +36,10 @@ class OtpTypeTest: XCTestCase {
|
|||
XCTAssertEqual(OtpType(name: ""), .none)
|
||||
XCTAssertEqual(OtpType(name: "something"), .none)
|
||||
}
|
||||
|
||||
func testDescription() {
|
||||
XCTAssertEqual(OtpType(name: "totp").description, "time-based")
|
||||
XCTAssertEqual(OtpType(name: "hotp").description, "HMAC-based")
|
||||
XCTAssertEqual(OtpType(name: nil).description, "none")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue