def test_create_user(self):
     """Check that User can be created outside of a running identity provider."""
     u = TG_User(user_name='testcase',
                 email_address='*****@*****.**',
                 display_name='Test Me',
                 password='******')
     assert u.password == 'test', u.password
 def test_require_group_viewable(self):
     """Test that the current user and group properties are set correctly."""
     response = self.app.get('/in_peon_group?'
                             'user_name=samIam&password=secret&login=Login')
     user = TG_User.by_user_name("samIam")
     group_ids = set((TG_Group.by_group_name("peon").id,
                      TG_Group.by_group_name("other").id))
 def test_user_password(self):
     """Test if we can set a user password (no encryption algorithm)."""
     hub.begin()
     u = TG_User.by_user_name("samIam")
     u.password = "******"
     u.sync()
     assert u.password == "password"
     hub.rollback()
     hub.end()
 def test_user_password(self):
     """Test if we can set a user password (no encryption algorithm)."""
     hub.begin()
     u = TG_User.by_user_name('samIam')
     u.password = '******'
     u.sync()
     assert u.password == 'password'
     hub.rollback()
     hub.end()
    def in_peon_group(self):
        user = TG_User.by_user_name("samIam")
        group_ids = set((TG_Group.by_group_name("peon").id, TG_Group.by_group_name("other").id))
        assert identity.current.user == user
        assert identity.current.user_name == user.user_name
        assert identity.current.user_id == user.id
        assert identity.current.groups == set(("peon", "other"))
        assert identity.current.group_ids == group_ids
        assert "samIam" == cherrypy.serving.request.identity.user_name

        return "in_peon_group"
    def in_peon_group(self):
        user = TG_User.by_user_name("samIam")
        group_ids = set((TG_Group.by_group_name("peon").id,
                         TG_Group.by_group_name("other").id))
        assert identity.current.user == user
        assert identity.current.user_name == user.user_name
        assert identity.current.user_id == user.id
        assert identity.current.groups == set(('peon', 'other'))
        assert identity.current.group_ids == group_ids
        assert "samIam" == cherrypy.serving.request.identity.user_name

        return 'in_peon_group'
 def test_user_password_raw_unicode(self):
     config.update({"tools.identity.soprovider.encryption_algorithm": "sha1"})
     # force new config values to load
     startup.startTurboGears()
     self.app.get("/")
     hub.begin()
     u = TG_User.by_user_name("samIam")
     u.set_password_raw(u"garçon")
     u.sync()
     assert u.password == u"garçon"
     hub.rollback()
     hub.end()
 def test_user_password_raw_unicode(self):
     config.update(
         {'tools.identity.soprovider.encryption_algorithm': 'sha1'})
     # force new config values to load
     startup.startTurboGears()
     self.app.get('/')
     hub.begin()
     u = TG_User.by_user_name('samIam')
     u.set_password_raw(u'garçon')
     u.sync()
     assert u.password == u'garçon'
     hub.rollback()
     hub.end()
 def test_user_password_hashed_md5(self):
     """Test if a md5 hashed password is stored in the database."""
     config.update({"tools.identity.soprovider.encryption_algorithm": "md5"})
     # force new config values to load
     startup.startTurboGears()
     self.app.get("/")
     hub.begin()
     u = TG_User.by_user_name("samIam")
     u.password = "******"
     u.sync()
     assert u.password == "5f4dcc3b5aa765d61d8327deb882cf99"
     hub.rollback()
     hub.end()
 def test_user_password_hashed_sha(self):
     """Test if a sha hashed password is stored in the database."""
     config.update({"tools.identity.soprovider.encryption_algorithm": "sha1"})
     # force new config values to load
     startup.startTurboGears()
     self.app.get("/")
     hub.begin()
     u = TG_User.by_user_name("samIam")
     u.password = "******"
     u.sync()
     assert u.password == "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8"
     hub.rollback()
     hub.end()
 def test_user_password_unicode(self):
     """Test if we can set a user password which is encoded as unicode
     (no encryption algorithm)."""
     config.update({'tools.identity.soprovider.encryption_algorithm': None})
     # force new config values to load
     startup.startTurboGears()
     self.app.get('/')
     hub.begin()
     u = TG_User.by_user_name('samIam')
     u.password = u'garçon'
     u.sync()
     assert u.password == u'garçon'
     hub.rollback()
     hub.end()
 def test_user_password_hashed_md5(self):
     """Test if a md5 hashed password is stored in the database."""
     config.update(
         {'tools.identity.soprovider.encryption_algorithm': 'md5'})
     # force new config values to load
     startup.startTurboGears()
     self.app.get('/')
     hub.begin()
     u = TG_User.by_user_name('samIam')
     u.password = '******'
     u.sync()
     assert u.password == '5f4dcc3b5aa765d61d8327deb882cf99'
     hub.rollback()
     hub.end()
 def test_user_password_hashed_md5_unicode(self):
     """Test if a md5 hashed password with unicode characters is stored
     in the database."""
     config.update({"tools.identity.soprovider.encryption_algorithm": "md5"})
     # force new config values to load
     startup.startTurboGears()
     self.app.get("/")
     hub.begin()
     u = TG_User.by_user_name("samIam")
     u.password = u"garçon"
     u.sync()
     assert u.password == "c295c4bb2672ca8c432effc53b40bb1e"
     hub.rollback()
     hub.end()
 def test_user_password_unicode(self):
     """Test if we can set a user password which is encoded as unicode
     (no encryption algorithm)."""
     config.update({"tools.identity.soprovider.encryption_algorithm": None})
     # force new config values to load
     startup.startTurboGears()
     self.app.get("/")
     hub.begin()
     u = TG_User.by_user_name("samIam")
     u.password = u"garçon"
     u.sync()
     assert u.password == u"garçon"
     hub.rollback()
     hub.end()
 def test_user_password_hashed_sha(self):
     """Test if a sha hashed password is stored in the database."""
     config.update(
         {'tools.identity.soprovider.encryption_algorithm': 'sha1'})
     # force new config values to load
     startup.startTurboGears()
     self.app.get('/')
     hub.begin()
     u = TG_User.by_user_name('samIam')
     u.password = '******'
     u.sync()
     assert u.password == '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'
     hub.rollback()
     hub.end()
 def test_user_password_raw(self):
     """Test that we can store raw values in the password field
     (without being hashed)."""
     config.update({"tools.identity.soprovider.encryption_algorithm": "sha1"})
     # force new config values to load
     startup.startTurboGears()
     self.app.get("/")
     hub.begin()
     u = TG_User.by_user_name("samIam")
     u.set_password_raw("password")
     u.sync()
     assert u.password == "password"
     hub.rollback()
     hub.end()
 def test_user_password_hashed_sha_unicode(self):
     """Test if a sha hashed password with unicode characters is stored
     in the database."""
     config.update({"tools.identity.soprovider.encryption_algorithm": "sha1"})
     # force new config values to load
     startup.startTurboGears()
     self.app.get("/")
     hub.begin()
     u = TG_User.by_user_name("samIam")
     u.password = u"garçon"
     u.sync()
     assert u.password == "442edb21c491a6e6f502eb79e98614f3c7edf43e"
     hub.rollback()
     hub.end()
 def test_user_password_raw(self):
     """Test that we can store raw values in the password field
     (without being hashed)."""
     config.update(
         {'tools.identity.soprovider.encryption_algorithm': 'sha1'})
     # force new config values to load
     startup.startTurboGears()
     self.app.get('/')
     hub.begin()
     u = TG_User.by_user_name('samIam')
     u.set_password_raw('password')
     u.sync()
     assert u.password == 'password'
     hub.rollback()
     hub.end()
 def test_user_password_hashed_sha_unicode(self):
     """Test if a sha hashed password with unicode characters is stored
     in the database."""
     config.update(
         {'tools.identity.soprovider.encryption_algorithm': 'sha1'})
     # force new config values to load
     startup.startTurboGears()
     self.app.get('/')
     hub.begin()
     u = TG_User.by_user_name('samIam')
     u.password = u'garçon'
     u.sync()
     assert u.password == '442edb21c491a6e6f502eb79e98614f3c7edf43e'
     hub.rollback()
     hub.end()
 def test_user_password_hashed_md5_unicode(self):
     """Test if a md5 hashed password with unicode characters is stored
     in the database."""
     config.update(
         {'tools.identity.soprovider.encryption_algorithm': 'md5'})
     # force new config values to load
     startup.startTurboGears()
     self.app.get('/')
     hub.begin()
     u = TG_User.by_user_name('samIam')
     u.password = u'garçon'
     u.sync()
     assert u.password == 'c295c4bb2672ca8c432effc53b40bb1e'
     hub.rollback()
     hub.end()
 def test_user_password_hashed_md5_utf8string(self):
     """Test if a md5 hashed password with unicode characters is stored in
     the database if the password is entered as str (encoded in UTF-8). This
     test ensures that the encryption algorithm does handle non-unicode
     parameters gracefully."""
     config.update({"tools.identity.soprovider.encryption_algorithm": "md5"})
     # force new config values to load
     startup.startTurboGears()
     self.app.get("/")
     hub.begin()
     u = TG_User.by_user_name("samIam")
     u.password = u"garçon".encode("UTF-8")
     u.sync()
     assert u.password == "c295c4bb2672ca8c432effc53b40bb1e"
     hub.rollback()
     hub.end()
 def test_user_password_hashed_md5_utf8string(self):
     """Test if a md5 hashed password with unicode characters is stored in
     the database if the password is entered as str (encoded in UTF-8). This
     test ensures that the encryption algorithm does handle non-unicode
     parameters gracefully."""
     config.update(
         {'tools.identity.soprovider.encryption_algorithm': 'md5'})
     # force new config values to load
     startup.startTurboGears()
     self.app.get('/')
     hub.begin()
     u = TG_User.by_user_name('samIam')
     u.password = u'garçon'.encode('UTF-8')
     u.sync()
     assert u.password == 'c295c4bb2672ca8c432effc53b40bb1e'
     hub.rollback()
     hub.end()
 def test_user_password_hashed_custom(self):
     """Test if a custom hashed password is stored in the database."""
     config.update({
         'tools.identity.soprovider.encryption_algorithm':
         'custom',
         'tools.identity.custom_encryption':
         'identity.tests.test_identity.mycustomencrypt'
     })
     # force new config values to load
     startup.startTurboGears()
     self.app.get('/')
     hub.begin()
     u = TG_User.by_user_name('samIam')
     u.password = '******'
     u.sync()
     assert u.password == 'password_custom'
     hub.rollback()
     hub.end()
 def test_user_password_hashed_custom(self):
     """Test if a custom hashed password is stored in the database."""
     config.update(
         {
             "tools.identity.soprovider.encryption_algorithm": "custom",
             "tools.identity.custom_encryption": "identity.tests.test_identity.mycustomencrypt",
         }
     )
     # force new config values to load
     startup.startTurboGears()
     self.app.get("/")
     hub.begin()
     u = TG_User.by_user_name("samIam")
     u.password = "******"
     u.sync()
     assert u.password == "password_custom"
     hub.rollback()
     hub.end()
 def init_model(self):
     if TG_User.select().count() == 0:
         user = TG_User(
             user_name="samIam", email_address="*****@*****.**", display_name="Samuel Amicus", password="******"
         )
         admin_group = TG_Group(group_name="admin", display_name="Administrator")
         peon_group = TG_Group(group_name="peon", display_name="Regular Peon")
         other_group = TG_Group(group_name="other", display_name="Another Group")
         chopper_perm = TG_Permission(permission_name="chops_wood", description="Wood Chopper")
         boss_perm = TG_Permission(permission_name="bosses_people", description="Benevolent Dictator")
         peon_group.addTG_Permission(chopper_perm)
         admin_group.addTG_Permission(boss_perm)
         user.addTG_Group(peon_group)
         user.addTG_Group(other_group)
 def init_model(self):
     if TG_User.select().count() == 0:
         user = TG_User(user_name='samIam',
                        email_address='*****@*****.**',
                        display_name='Samuel Amicus',
                        password='******')
         admin_group = TG_Group(group_name="admin",
                                display_name="Administrator")
         peon_group = TG_Group(group_name="peon",
                               display_name="Regular Peon")
         other_group = TG_Group(group_name="other",
                                display_name="Another Group")
         chopper_perm = TG_Permission(permission_name='chops_wood',
                                      description="Wood Chopper")
         boss_perm = TG_Permission(permission_name='bosses_people',
                                   description="Benevolent Dictator")
         peon_group.addTG_Permission(chopper_perm)
         admin_group.addTG_Permission(boss_perm)
         user.addTG_Group(peon_group)
         user.addTG_Group(other_group)
 def test_require_group_viewable(self):
     """Test that a user with proper group membership can see a restricted url."""
     response = self.app.get('/in_peon_group?'
                             'user_name=samIam&password=secret&login=Login')
     assert 'in_peon_group' in response, response
     user = TG_User.by_user_name("samIam")
 def test_require_group_viewable(self):
     """Test that the current user and group properties are set correctly."""
     response = self.app.get("/in_peon_group?" "user_name=samIam&password=secret&login=Login")
     user = TG_User.by_user_name("samIam")
     group_ids = set((TG_Group.by_group_name("peon").id, TG_Group.by_group_name("other").id))
 def test_user_exists(self):
     u = TG_User.by_user_name('samIam')
     assert u.email_address == '*****@*****.**'
 def test_require_group_viewable(self):
     """Test that a user with proper group membership can see a restricted url."""
     response = self.app.get("/in_peon_group?" "user_name=samIam&password=secret&login=Login")
     assert "in_peon_group" in response, response
     user = TG_User.by_user_name("samIam")
 def test_user_exists(self):
     u = TG_User.by_user_name("samIam")
     assert u.email_address == "*****@*****.**"