def test_16_init_detail(self):
        db_token = Token.query.filter_by(serial=self.serial1).first()
        token = HotpTokenClass(db_token)
        token.add_init_details("otpkey", "11223344556677889900")
        detail = token.get_init_detail()
        self.assertTrue("otpkey" in detail, detail)
        # but the otpkey must not be written to token.token.info (DB)
        # As this only writes the OTPkey to the internal init_details dict
        self.assertTrue("otpkey" not in token.token.get_info(),
                        token.token.get_info())

        # Now get the Google Authenticator URL, which we only
        # get, if a user is specified.
        detail = token.get_init_detail(user=User("cornelius", self.realm1))
        self.assertTrue("otpkey" in detail, detail)
        otpkey = detail.get("otpkey")
        self.assertTrue("img" in otpkey, otpkey)
        self.assertTrue("googleurl" in detail, detail)
        # some other stuff.
        r = token.get_QRimage_data(
            {"googleurl": detail.get("googleurl").get("value")})
        self.assertTrue(
            'otpauth://hotp/SE123456?secret=CERDGRCVMZ3YRGIA'
            '&counter=1' in r[0], r[0])
        self.assertRaises(Exception, token.set_init_details, "unvalid value")
        token.set_init_details({"detail1": "value1"})
        self.assertTrue("detail1" in token.get_init_details(),
                        token.get_init_details())
    def test_16_init_detail(self):
        db_token = Token.query.filter_by(serial=self.serial1).first()
        token = HotpTokenClass(db_token)
        token.add_init_details("otpkey", "11223344556677889900")
        detail = token.get_init_detail()
        self.assertTrue("otpkey" in detail, detail)
        # but the otpkey must not be written to token.token.info (DB)
        # As this only writes the OTPkey to the internal init_details dict
        self.assertTrue("otpkey" not in token.token.get_info(),
                        token.token.get_info())

        # Now get the Google Authenticator URL, which we only
        # get, if a user is specified.
        detail = token.get_init_detail(user=User("cornelius",
                                                 self.realm1))
        self.assertTrue("otpkey" in detail, detail)
        otpkey = detail.get("otpkey")
        self.assertTrue("img" in otpkey, otpkey)
        self.assertTrue("googleurl" in detail, detail)
        # some other stuff.
        r = token.get_QRimage_data({"googleurl": detail.get("googleurl").get(
            "value")})
        self.assertTrue('otpauth://hotp/SE123456?secret=CERDGRCVMZ3YRGIA'
                        '&counter=1' in r[0], r[0])
        self.assertRaises(Exception, token.set_init_details, "unvalid value")
        token.set_init_details({"detail1": "value1"})
        self.assertTrue("detail1" in token.get_init_details(),
                        token.get_init_details())
Beispiel #3
0
 def get_init_detail(self, params=None, user=None):
     """
     to complete the token initialization some additional details
     should be returned, which are displayed at the end of
     the token initialization.
     This is the e.g. the enrollment URL for a Google Authenticator.
     """
     params = params or {}
     if params.get("totp.hashlib"):
         params["hashlib"] = params.get("totp.hashlib")
     response_detail = HotpTokenClass.get_init_detail(self, params, user)
     return response_detail
Beispiel #4
0
 def get_init_detail(self, params=None, user=None):
     """
     to complete the token initialization some additional details
     should be returned, which are displayed at the end of
     the token initialization.
     This is the e.g. the enrollment URL for a Google Authenticator.
     """
     params = params or {}
     if params.get("totp.hashlib"):
         params["hashlib"] = params.get("totp.hashlib")
     response_detail = HotpTokenClass.get_init_detail(self, params, user)
     return response_detail