Ejemplo n.º 1
0
    def testAscii(self):
        """user: encode ascii password"""
        # u'MoinMoin' and 'MoinMoin' should be encoded to same result
        expected = "{SSHA256}n0JB8FCTQCpQeg0bmdgvTGwPKvxm8fVNjSRD+JGNs50xMjM0NQ=="

        result = crypto.crypt_password("MoinMoin", salt='12345')
        assert result == expected
        result = crypto.crypt_password(u"MoinMoin", salt='12345')
        assert result == expected
Ejemplo n.º 2
0
 def testvalidpassword(self):
     """ validate user password """
     hash_val = crypto.crypt_password(u"MoinMoin", salt='12345')
     result = crypto.valid_password(u'MoinMoin', hash_val)
     assert result
     with pytest.raises(ValueError):
         invalid_result = crypto.valid_password("MoinMoin", '{junk_value}')
Ejemplo n.º 3
0
 def testvalidpassword2(self):
     """ validate user password """
     hash_val = crypto.crypt_password(u"MoinMoin")
     result = crypto.valid_password('MoinMoin', hash_val)
     assert result
     result = crypto.valid_password('WrongPassword', hash_val)
     assert not result
     with pytest.raises(ValueError):
         invalid_result = crypto.valid_password("MoinMoin", '{junk_value}')
Ejemplo n.º 4
0
    def run(self, name, uid, password):
        flaskg.unprotected_storage = app.unprotected_storage
        flags_given = name or uid
        if not flags_given:
            print 'incorrect number of arguments'
            import sys
            sys.exit()

        if uid:
            u = user.User(uid)
        elif name:
            u = user.User(auth_username=name)

        if not u.exists():
            print 'This user "{0}" does not exists!'.format(u.name)
            return

        u.enc_password = crypto.crypt_password(password)
        u.save()
        print 'Password set.'
Ejemplo n.º 5
0
 def testUnicode(self):
     """ user: encode unicode password """
     result = crypto.crypt_password(u'סיסמה סודית בהחלט', salt='12345') # Hebrew
     expected = "{SSHA256}pdYvYv+4Vph259sv/HAm7zpZTv4sBKX9ITOX/m00HMsxMjM0NQ=="
     assert result == expected
Ejemplo n.º 6
0
 def set_password(self, password, is_encrypted=False):
     if not is_encrypted:
         password = crypt_password(password)
     self.profile[ENC_PASSWORD] = password
     # Invalidate all other browser sessions except this one.
     session['user.session_token'] = self.generate_session_token(False)