Signal-iOS/SignalServiceKit/tests/Util/OWS2FAManagerTest.swift
Evan Hahn 96cc668158
Move isWeakPin function, add tests
This change moves `PinSetupViewController`'s `isWeakPin` method to
`OWS2FAManager`, adds tests, and adds an additional length check.

This change should have no user impact and is useful for an upcoming
task.
2023-02-21 09:00:57 -08:00

22 lines
552 B
Swift

//
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import XCTest
import SignalServiceKit
final class OWS2FAManagerTest: XCTestCase {
func test_isWeakPin() {
let strongPins = ["90210", "alphanumeric"]
for pin in strongPins {
XCTAssertFalse(OWS2FAManager.isWeakPin(pin), pin)
}
let weakPins = ["", "901", "123456", "654321", "222222", "①②③④⑤⑥"]
for pin in weakPins {
XCTAssertTrue(OWS2FAManager.isWeakPin(pin), pin)
}
}
}