Support Steam OTP (#505)
This commit is contained in:
parent
06d2ef1d09
commit
f2ab400f4b
8 changed files with 85 additions and 34 deletions
|
|
@ -317,4 +317,14 @@ class PasswordTest: XCTestCase {
|
|||
XCTAssertNotNil(otpStrings)
|
||||
XCTAssertEqual(otpStrings!.description, "HmacBased".localize())
|
||||
}
|
||||
|
||||
func testSteamOtpStringsToken() {
|
||||
let password = getPasswordObjectWith(content: STEAM_TOTP_URL)
|
||||
let otpStrings = password.getOtpStrings()
|
||||
let otpDescription = otpStrings!.description
|
||||
|
||||
XCTAssertNotNil(otpStrings)
|
||||
XCTAssert(otpDescription.hasPrefix("TimeBased".localize() + " ("))
|
||||
XCTAssert(otpDescription.hasSuffix(")"))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,6 +171,27 @@ class TokenBuilderTest: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
func testRepresentation() {
|
||||
[
|
||||
(nil, .numeric),
|
||||
("steamguard", .steamguard),
|
||||
("numeric", .numeric),
|
||||
("wrong representation", .numeric),
|
||||
].forEach { (inputRepresentation: String?, represenetation: OneTimePassword.Generator.Representation) in
|
||||
var builder = TokenBuilder()
|
||||
.usingSecret(SECRET)
|
||||
.usingType("totp")
|
||||
.usingRepresentation(inputRepresentation)
|
||||
if represenetation == .steamguard {
|
||||
builder = builder
|
||||
.usingDigits("5")
|
||||
.usingAlgorithm("sha1")
|
||||
}
|
||||
let token = builder.build()
|
||||
XCTAssertEqual(token?.generator.representation, represenetation)
|
||||
}
|
||||
}
|
||||
|
||||
func testUnparsableCounter() {
|
||||
let token = TokenBuilder()
|
||||
.usingSecret(SECRET)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ let PASSWORD_PATH = "/path/to/password"
|
|||
let PASSWORD_URL = URL(fileURLWithPath: "/path/to/password")
|
||||
let PASSWORD_STRING = "abcd1234"
|
||||
let TOTP_URL = "otpauth://totp/email@email.com?secret=abcd1234"
|
||||
let STEAM_TOTP_URL = "otpauth://totp/username?secret=12345678901234567890&issuer=Steam&algorithm=SHA1&digits=5&period=30&representation=steamguard"
|
||||
let HOTP_URL = "otpauth://hotp/email@email.com?secret=abcd1234"
|
||||
|
||||
let FIELD = "key" => "value"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue