Ejemplo n.º 1
0
 def test_10_authenticate_challenge_response(self):
     db_token = Token.query.filter(Token.serial == self.serial1).first()
     token = RemoteTokenClass(db_token)
     token.set_pin(self.otppin)
     r = token.is_challenge_request(self.otppin)
     # Return True, the PIN triggers a challenges request.
     self.assertTrue(r)
 def test_10_authenticate_challenge_response(self):
     db_token = Token.query.filter(Token.serial == self.serial1).first()
     token = RemoteTokenClass(db_token)
     token.set_pin(self.otppin)
     r = token.is_challenge_request(self.otppin)
     # Return True, the PIN triggers a challenges request.
     self.assertTrue(r)
Ejemplo n.º 3
0
    def test_11_check_challenge_response(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = RemoteTokenClass(db_token)
        token.set_pin(self.otppin)
        r = token.check_challenge_response(passw="somePW",
                                           options={"transactionid": "1234"})

        self.assertTrue(r)
Ejemplo n.º 4
0
    def __init__(self, aToken):
        RemoteTokenClass.__init__(self, aToken)
        self.setType(u"radius")

        self.radiusServer = ""
        self.radiusUser = ""
        self.radiusLocal_checkpin = "0"
        self.radiusSecret = VOID_RADIUS_SECRET
    def test_11_check_challenge_response(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = RemoteTokenClass(db_token)
        token.set_pin(self.otppin)
        r = token.check_challenge_response(passw="somePW",
                                           options={"transactionid": "1234"})

        self.assertTrue(r)
Ejemplo n.º 6
0
    def test_02_class_methods(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = RemoteTokenClass(db_token)

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

        info = token.get_class_info("title")
        self.assertTrue(info == "Remote Token", info)
    def test_07_do_request_missing_config(self):
        responses.add(responses.POST,
                      "http://my.privacyidea.server/validate/check",
                      body=json.dumps(self.success_body),
                      content_type="application/json")

        db_token = Token.query.filter(Token.serial == self.serial3).first()
        token = RemoteTokenClass(db_token)
        # Authentication will fail, since neither remote.serial nor remote.user
        otpcount = token.check_otp("123456")
        self.assertTrue(otpcount == -1, otpcount)
    def test_04_do_request_success(self):
        responses.add(responses.POST,
                      "http://my.privacyidea.server/validate/check",
                      body=json.dumps(self.success_body),
                      content_type="application/json")

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

        otpcount = token.check_otp("123456")
        self.assertTrue(otpcount > 0, otpcount)
Ejemplo n.º 9
0
    def test_07_do_request_missing_config(self):
        responses.add(responses.POST,
                      "http://my.privacyidea.server/validate/check",
                      body=json.dumps(self.success_body),
                      content_type="application/json")

        db_token = Token.query.filter(Token.serial == self.serial3).first()
        token = RemoteTokenClass(db_token)
        # Authentication will fail, since neither remote.serial nor remote.user
        otpcount = token.check_otp("123456")
        self.assertTrue(otpcount == -1, otpcount)
Ejemplo n.º 10
0
    def test_05_do_request_fail(self):
        responses.add(responses.POST,
                      "http://my.privacyidea.server/validate/check",
                      body=json.dumps(self.fail_body),
                      content_type="application/json")

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

        otpcount = token.check_otp("123456")
        self.assertTrue(otpcount == -1, otpcount)
Ejemplo n.º 11
0
    def test_06_do_request_success_remote_user(self):
        # verify SSL
        set_privacyidea_config("remote.verify_ssl_certificate", True)
        responses.add(responses.POST,
                      "http://my.privacyidea.server/validate/check",
                      body=json.dumps(self.success_body),
                      content_type="application/json")

        db_token = Token.query.filter(Token.serial == self.serial2).first()
        token = RemoteTokenClass(db_token)
        otpcount = token.check_otp("123456")
        self.assertTrue(otpcount > 0, otpcount)
    def test_06_do_request_success_remote_user(self):
        # verify SSL
        set_privacyidea_config("remote.verify_ssl_certificate", True)
        responses.add(responses.POST,
                      "http://my.privacyidea.server/validate/check",
                      body=json.dumps(self.success_body),
                      content_type="application/json")

        db_token = Token.query.filter(Token.serial == self.serial2).first()
        token = RemoteTokenClass(db_token)
        otpcount = token.check_otp("123456")
        self.assertTrue(otpcount > 0, otpcount)
 def test_09_authenticate_remote_pin(self):
     responses.add(responses.POST,
                   "http://my.privacyidea.server/validate/check",
                   body=json.dumps(self.success_body),
                   content_type="application/json")
     db_token = Token.query.filter(Token.serial == self.serial2).first()
     token = RemoteTokenClass(db_token)
     token.set_pin("")
     r = token.authenticate("remotePIN123456")
     self.assertTrue(r[0], r)
     self.assertTrue(r[1] >= 0, r)
     self.assertTrue(r[2].get("message") == "matching 1 tokens", r)
Ejemplo n.º 14
0
 def test_09_authenticate_remote_pin(self):
     responses.add(responses.POST,
                   "http://my.privacyidea.server/validate/check",
                   body=json.dumps(self.success_body),
                   content_type="application/json")
     db_token = Token.query.filter(Token.serial == self.serial2).first()
     token = RemoteTokenClass(db_token)
     token.set_pin("")
     r = token.authenticate("remotePIN123456")
     self.assertTrue(r[0], r)
     self.assertTrue(r[1] >= 0, r)
     self.assertTrue(r[2].get("message") == "matching 1 tokens", r)
    def test_04_do_request_success(self):
        responses.add(responses.POST,
                      "http://my.privacyidea.server/validate/check",
                      body=json.dumps(self.success_body),
                      content_type="application/json")

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

        otpcount = token.check_otp("123456")
        self.assertTrue(otpcount > 0, otpcount)

        remote_serial = token.get_tokeninfo("last_matching_remote_serial")
        self.assertEqual("PISP0000AB00", remote_serial)
Ejemplo n.º 16
0
    def test_08_authenticate_local_pin(self):
        responses.add(responses.POST,
                      "http://my.privacyidea.server/validate/check",
                      body=json.dumps(self.success_body),
                      content_type="application/json")
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = RemoteTokenClass(db_token)

        # wrong PIN
        r = token.authenticate("wrong" + "123456")
        self.assertFalse(r[0], r)
        self.assertTrue(r[1] == -1, r)
        self.assertTrue(r[2].get("message") == "Wrong PIN", r)
        # rigth PIN
        r = token.authenticate(self.otppin + "123456")
        self.assertTrue(r[0], r)
        self.assertTrue(r[1] >= 0, r)
        self.assertTrue(r[2].get("message") == "matching 1 tokens", r)
    def test_08_authenticate_local_pin(self):
        responses.add(responses.POST,
                      "http://my.privacyidea.server/validate/check",
                      body=json.dumps(self.success_body),
                      content_type="application/json")
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = RemoteTokenClass(db_token)

        # wrong PIN
        r = token.authenticate("wrong"+"123456")
        self.assertFalse(r[0], r)
        self.assertTrue(r[1] == -1, r)
        self.assertTrue(r[2].get("message") == "Wrong PIN", r)
        # rigth PIN
        r = token.authenticate(self.otppin+"123456")
        self.assertTrue(r[0], r)
        self.assertTrue(r[1] >= 0, r)
        self.assertTrue(r[2].get("message") == "matching 1 tokens", r)
Ejemplo n.º 18
0
    def checkPin(self, pin, options=None):
        '''
        check the pin - either remote or localy
        - in case of remote, we return true, as the
          the splitPinPass will put the passw then in the otpVal

        :param pin: the pin which should be checked
        :param options: the additional request parameters
        '''
        res = True

        if self.check_pin_local():
            log.debug("checking PIN locally")
            res = RemoteTokenClass.checkPin(self, pin)

        return res
Ejemplo n.º 19
0
 def __init__(self, db_token):
     RemoteTokenClass.__init__(self, db_token)
     self.set_type(u"radius")
     self.mode = ['authenticate', 'challenge']
Ejemplo n.º 20
0
 def __init__(self, db_token):
     RemoteTokenClass.__init__(self, db_token)
     self.set_type(u"radius")
     self.mode = ['authenticate', 'challenge']
    def test_01_create_token(self):
        db_token = Token(self.serial3, tokentype="remote")
        db_token.save()
        token = RemoteTokenClass(db_token)
        token.update(self.params3)
        token.set_pin(self.otppin)

        db_token = Token(self.serial2, tokentype="remote")
        db_token.save()
        token = RemoteTokenClass(db_token)
        token.update(self.params2)
        token.set_pin(self.otppin)

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

        self.assertTrue(token.token.serial == self.serial1, token)
        self.assertTrue(token.token.tokentype == "remote",
                        token.token.tokentype)
        self.assertTrue(token.type == "remote", token)
        class_prefix = token.get_class_prefix()
        self.assertTrue(class_prefix == "PIRE", class_prefix)
        self.assertTrue(token.get_class_type() == "remote", token)
Ejemplo n.º 22
0
    def test_01_create_token(self):
        db_token = Token(self.serial3, tokentype="remote")
        db_token.save()
        token = RemoteTokenClass(db_token)
        token.update(self.params3)
        token.set_pin(self.otppin)

        db_token = Token(self.serial2, tokentype="remote")
        db_token.save()
        token = RemoteTokenClass(db_token)
        token.update(self.params2)
        token.set_pin(self.otppin)

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

        self.assertTrue(token.token.serial == self.serial1, token)
        self.assertTrue(token.token.tokentype == "remote",
                        token.token.tokentype)
        self.assertTrue(token.type == "remote", token)
        class_prefix = token.get_class_prefix()
        self.assertTrue(class_prefix == "PIRE", class_prefix)
        self.assertTrue(token.get_class_type() == "remote", token)
Ejemplo n.º 23
0
    def test_03_check_pin_local(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = RemoteTokenClass(db_token)

        r = token.check_pin_local
        self.assertTrue(r, r)