Exemple #1
0
    def test_get_otpauth_url(self):
        """Test :attr:`googauth.get_otpauth_url`."""
        secret_key = "GYZTKMJSMZQWEMDF"
        value = googauth.get_otpauth_url("test", "domain.com", secret_key)
        self.assertTrue(value == "otpauth://totp/[email protected]?secret=GYZTKMJSMZQWEMDF")

        secret_key = "MMZDQMRTMU2WGNDB"
        value = googauth.get_otpauth_url("user", "domain.com", secret_key)
        self.assertTrue(value == "otpauth://totp/[email protected]?secret=MMZDQMRTMU2WGNDB")
Exemple #2
0
    def test_get_otpauth_url(self):
        """Test :attr:`googauth.get_otpauth_url`."""
        secret_key = 'GYZTKMJSMZQWEMDF'
        value = googauth.get_otpauth_url('test', 'domain.com', secret_key)
        self.assertTrue(
            value == 'otpauth://totp/[email protected]?secret=GYZTKMJSMZQWEMDF')

        secret_key = 'MMZDQMRTMU2WGNDB'
        value = googauth.get_otpauth_url('user', 'domain.com', secret_key)
        self.assertTrue(
            value == 'otpauth://totp/[email protected]?secret=MMZDQMRTMU2WGNDB')
Exemple #3
0
 def qrcode(self):
     '''returns a stringio object containing
     the PNG qrcode for use in google authenticator
     '''
     qr = qrcode.QRCode(
           box_size=5,
           border=4,
       )
     qr.add_data(googauth.get_otpauth_url(
                             self.username, 
                             self.domain, 
                             self.secret_key
                             )
                         )
     qr.make(fit=True)
     barcode = StringIO.StringIO()
     qr.make_image().save(barcode)
     barcode.seek(0)
     return barcode