An iOS TOTP generator app.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

25 lines
774 B

//
// OTPGeneratorTests.swift
// OTPKitTests
//
// Created by Shadowfacts on 8/21/21.
//
import XCTest
@testable import OTPKit
class OTPGeneratorTests: XCTestCase {
func testGenerateTOTP() {
let key = TOTPKey(urlComponents: URLComponents(string: "otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example")!)!
let result = OTPGenerator.generate(key: key, counter: 54319307)
XCTAssertEqual(result, "155456")
}
func testPadWithZeroes() {
let key = TOTPKey(urlComponents: URLComponents(string: "otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example")!)!
let result = OTPGenerator.generate(key: key, counter: 54319378)
XCTAssertEqual(result, "095891")
}
}