예제 #1
0
    def test_04_check_otp_success(self):
        responses.add(responses.POST, YUBICO_URL, body=self.success_body)

        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = YubicoTokenClass(db_token)
        otpcount = token.check_otp("vvbgidlghkhgndujklhhudbcuttkcklhvjktrjrt")
        # Nonce and hash do not match
        self.assertTrue(otpcount == -2, otpcount)
    def test_04_check_otp_success(self):
        responses.add(responses.POST, YUBICO_URL,
                      body=json.dumps(self.success_body))

        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = YubicoTokenClass(db_token)
        otpcount = token.check_otp("vvbgidlghkhgndujklhhudbcuttkcklhvjktrjrt")
        # Nonce and hash do not match
        self.assertTrue(otpcount == -2, otpcount)
예제 #3
0
    def test_05_check_otp_fail(self):
        responses.add(responses.POST, YUBICO_URL, body=self.fail_body)

        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = YubicoTokenClass(db_token)

        otpcount = token.check_otp("vvbgidlghkhgndujklhhudbcuttkcklhvjktrjrt")
        # Status != "OK".
        self.assertTrue(otpcount == -1, otpcount)
    def test_05_check_otp_fail(self):
        responses.add(responses.POST, YUBICO_URL,
                      body=json.dumps(self.fail_body))

        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = YubicoTokenClass(db_token)

        otpcount = token.check_otp("vvbgidlghkhgndujklhhudbcuttkcklhvjktrjrt")
        # Status != "OK".
        self.assertTrue(otpcount == -1, otpcount)
    def test_02_class_methods(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = YubicoTokenClass(db_token)

        info = token.get_class_info()
        self.assertTrue(info.get("title") == "Yubico Token",
                        "%s" % info.get("title"))

        info = token.get_class_info("title")
        self.assertTrue(info == "Yubico Token", info)
예제 #6
0
    def test_02_class_methods(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = YubicoTokenClass(db_token)

        info = token.get_class_info()
        self.assertTrue(
            info.get("title") == "Yubico Token", "%s" % info.get("title"))

        info = token.get_class_info("title")
        self.assertTrue(info == "Yubico Token", info)
    def test_04_check_otp_success_with_post_request(self):
        set_privacyidea_config("yubico.do_post", True)
        responses.add(responses.POST, YUBICO_URL,
                      body=self.success_body)

        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = YubicoTokenClass(db_token)
        otpcount = token.check_otp("vvbgidlghkhgndujklhhudbcuttkcklhvjktrjrt")
        # Nonce and hash do not match
        self.assertTrue(otpcount == -2, otpcount)
        set_privacyidea_config("yubico.do_post", False)
예제 #8
0
    def test_01_create_token(self):

        db_token = Token(self.serial1, tokentype="remote")
        db_token.save()
        token = YubicoTokenClass(db_token)
        token.update(self.params1)
        token.set_pin(self.otppin)

        self.assertTrue(token.token.serial == self.serial1, token)
        self.assertTrue(token.token.tokentype == "yubico",
                        token.token.tokentype)
        self.assertTrue(token.type == "yubico", token)
        class_prefix = token.get_class_prefix()
        self.assertTrue(class_prefix == "UBCM", class_prefix)
        self.assertTrue(token.get_class_type() == "yubico", token)
    def test_01_create_token(self):

        db_token = Token(self.serial1, tokentype="remote")
        db_token.save()
        token = YubicoTokenClass(db_token)
        token.update(self.params1)
        token.set_pin(self.otppin)

        self.assertTrue(token.token.serial == self.serial1, token)
        self.assertTrue(token.token.tokentype == "yubico",
                        token.token.tokentype)
        self.assertTrue(token.type == "yubico", token)
        class_prefix = token.get_class_prefix()
        self.assertTrue(class_prefix == "UBCM", class_prefix)
        self.assertTrue(token.get_class_type() == "yubico", token)
 def test_07_check_otp_ID_wrong(self):
     db_token = Token.query.filter(Token.serial == self.serial1).first()
     token = YubicoTokenClass(db_token)
     otpcount = token.check_otp("Xvbgidlghkhgndujklhhudbcuttkcklhvjktrjrt")
     self.assertTrue(otpcount == -1, otpcount)
 def test_06_check_otp_ID_too_short(self):
     db_token = Token.query.filter(Token.serial == self.serial1).first()
     token = YubicoTokenClass(db_token)
     otpcount = token.check_otp("vvbgidlg")
     self.assertTrue(otpcount == -1, otpcount)
예제 #12
0
 def test_08_init_ID_too_short(self):
     db_token = Token("neuYT", tokentype="remote")
     db_token.save()
     token = YubicoTokenClass(db_token)
     self.assertRaises(Exception, token.update,
                       {"yubico.tokenid": "vvbgidlg"})
예제 #13
0
 def test_07_check_otp_ID_wrong(self):
     db_token = Token.query.filter(Token.serial == self.serial1).first()
     token = YubicoTokenClass(db_token)
     otpcount = token.check_otp("Xvbgidlghkhgndujklhhudbcuttkcklhvjktrjrt")
     self.assertTrue(otpcount == -1, otpcount)
예제 #14
0
 def test_06_check_otp_ID_too_short(self):
     db_token = Token.query.filter(Token.serial == self.serial1).first()
     token = YubicoTokenClass(db_token)
     otpcount = token.check_otp("vvbgidlg")
     self.assertTrue(otpcount == -1, otpcount)