def test_06_reuse_otp_value(self):
        key = "0123456789abcdef"
        db_token = Token("motp002", tokentype="motp")
        db_token.save()
        token = MotpTokenClass(db_token)
        token.update({"otpkey": key, "motppin": "6666", "pin": "test"})
        self.assertTrue(token.token.tokentype == "motp", token.token.tokentype)
        self.assertTrue(token.type == "motp", token)
        class_prefix = token.get_class_prefix()
        self.assertTrue(class_prefix == "PIMO", class_prefix)
        self.assertTrue(token.get_class_type() == "motp", token)

        # Correct OTP value
        r = token.check_otp("6ed4e4", options={"initTime": 129612120})
        self.assertTrue(r == 129612120, r)

        # Check the same value again
        r = token.check_otp("6ed4e4", options={"initTime": 129612120})
        self.assertTrue(r == -1, r)
Пример #2
0
    def test_06_reuse_otp_value(self):
        key = "0123456789abcdef"
        db_token = Token("motp002", tokentype="motp")
        db_token.save()
        token = MotpTokenClass(db_token)
        token.update({"otpkey": key,
                      "motppin": "6666",
                      "pin": "test"})
        self.assertTrue(token.token.tokentype == "motp", token.token.tokentype)
        self.assertTrue(token.type == "motp", token)
        class_prefix = token.get_class_prefix()
        self.assertTrue(class_prefix == "PIMO", class_prefix)
        self.assertTrue(token.get_class_type() == "motp", token)

        # Correct OTP value
        r = token.check_otp("6ed4e4", options={"initTime": 129612120})
        self.assertTrue(r == 129612120, r)

        # Check the same value again
        r = token.check_otp("6ed4e4", options={"initTime": 129612120})
        self.assertTrue(r == -1, r)
    def test_02_check_password(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = MotpTokenClass(db_token)

        # Wrong OTP value
        r = token.check_otp("aba73b")
        self.assertTrue(r == -1, r)

        # check pin+otp:
        token.set_pin(self.otppin)
        r = token.authenticate("{0!s}aba73b".format(self.otppin))
        self.assertTrue(r[0], r)
        self.assertTrue(r[1] == -1, r)
    def test_02_check_password(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = MotpTokenClass(db_token)

        # Wrong OTP value
        r = token.check_otp("aba73b")
        self.assertTrue(r == -1, r)

        # check pin+otp:
        token.set_pin(self.otppin)
        r = token.authenticate("%saba73b" % self.otppin)
        self.assertTrue(r[0], r)
        self.assertTrue(r[1] == -1, r)