当前位置: 首页>>代码示例>>Python>>正文


Python User.set_password方法代码示例

本文整理汇总了Python中streetsign_server.models.User.set_password方法的典型用法代码示例。如果您正苦于以下问题:Python User.set_password方法的具体用法?Python User.set_password怎么用?Python User.set_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在streetsign_server.models.User的用法示例。


在下文中一共展示了User.set_password方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_normal_user_cannot_set_other_to_admin

# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import set_password [as 别名]
    def test_normal_user_cannot_set_other_to_admin(self):
        user2 = User(loginname="user2",
                     emailaddress='[email protected]',
                     is_admin=False)
        user2.set_password("userpass2")
        user2.save()

        self.login(USERNAME, USERPASS)
        resp = self.post_update_request(userid=user2.id, is_admin=True)

        self.assertEqual(resp.status_code, 403)

        usernow = User.get(id=user2.id)
        self.assertEqual(usernow.is_admin, False)
开发者ID:Fivebread,项目名称:streetsign,代码行数:16,代码来源:test_views_users_and_auth.py

示例2: BasicUsersTestCase

# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import set_password [as 别名]
class BasicUsersTestCase(StreetSignTestCase):
    def setUp(self):
        super(BasicUsersTestCase, self).setUp()
        self.user = User(loginname=USERNAME,
                         emailaddress='[email protected]',
                         is_admin=False)
        self.user.set_password(USERPASS)
        self.user.save()


        self.admin = User(loginname=ADMINNAME,
                          emailaddress='[email protected]',
                          is_admin=True)
        self.admin.set_password(ADMINPASS)
        self.admin.save()
开发者ID:Fivebread,项目名称:streetsign,代码行数:17,代码来源:test_views_users_and_auth.py

示例3: test_cannot_have_matching_usernames

# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import set_password [as 别名]
    def test_cannot_have_matching_usernames(self):
        user2 = User(loginname='user2',
                     emailaddress='[email protected]',
                     is_admin=False)
        user2.set_password(USERPASS)
        user2.save()

        # if this get works, then the user exists:
        usernow = User.get(loginname="user2")
        self.assertEqual(user2.id, usernow.id)

        self.login(ADMINNAME, ADMINPASS)
        resp = self.post_create_request(currpass=ADMINPASS,
                                        newpass='not42', conf_newpass='not42')
        self.assertIn("Username already exists", resp.data)

        # and just make sure we didn't delete them, or set their password...

        usernew = User.get(loginname="user2")
        self.assertEqual(usernow.passwordhash, usernew.passwordhash)
开发者ID:Fivebread,项目名称:streetsign,代码行数:22,代码来源:test_views_users_and_auth.py

示例4: test_cannot_change_other_users_password_even_with_their_currpass

# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import set_password [as 别名]
    def test_cannot_change_other_users_password_even_with_their_currpass(self):

        user2 = User(loginname="user2",
                     emailaddress='[email protected]',
                     is_admin=False)
        user2.set_password("userpass2")
        user2.save()

        self.login(USERNAME, USERPASS)

        with self.ctx():
            resp = self.client.post(url_for('user_edit', userid=user2.id),
                                    data={"action":"update",
                                          "newpass": "200",
                                          "conf_newpass": "200",
                                          "currpass": "userpass2"},
                                    follow_redirects=True)

        self.assertIn("Permission Denied", resp.data)
        self.assertEquals(resp.status_code, 403)

        usernow = User.get(id=user2.id)
        self.assertEqual(usernow.passwordhash, user2.passwordhash)
开发者ID:Fivebread,项目名称:streetsign,代码行数:25,代码来源:test_views_users_and_auth.py

示例5: DeletingUsers

# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import set_password [as 别名]
class DeletingUsers(BasicUsersTestCase):
    ''' Only admin can delete users, and not themselves. '''

    def setUp(self):
        super(DeletingUsers, self).setUp()

        self.user2 = User(loginname='user2',
                          emailaddress='[email protected]',
                          is_admin=False)
        self.user2.set_password(USERPASS)
        self.user2.save()

    def post_delete_request(self, userid=False, **kwargs):
        data = {}
        data.update(kwargs)

        if userid == False:
            userid = self.user2.id

        with self.ctx():
            return self.client.delete(url_for('user_edit', userid=userid),
                                      data=data,
                                      follow_redirects=True)

    def test_logged_out_cannot_delete_user(self):
        resp = self.post_delete_request()
        self.assertEqual(resp.status_code, 403)
        User.get(id=self.user2.id)

    def test_normal_user_cannot_delete_user(self):
        self.login(USERNAME, USERPASS)
        resp = self.post_delete_request()
        self.assertEqual(resp.status_code, 403)
        User.get(id=self.user2.id)

    def test_normal_user_cannot_delete_self(self):
        self.login(USERNAME, USERPASS)
        resp = self.post_delete_request(userid=self.user.id)
        self.assertEqual(resp.status_code, 403)

        User.get(id=self.user.id)

    def test_normal_user_cannot_delete_admin(self):
        self.login(USERNAME, USERPASS)
        resp = self.post_delete_request(userid=self.admin.id)
        self.assertEqual(resp.status_code, 403)

        User.get(id=self.admin.id)

    def test_admin_can_delete_user(self):
        self.login(ADMINNAME, ADMINPASS)
        resp = self.post_delete_request()
        self.assertEqual(resp.status_code, 200)

        with self.assertRaises(User.DoesNotExist):
            User.get(id=self.user2.id)

    def test_admin_cannot_delete_self(self):
        self.login(ADMINNAME, ADMINPASS)
        resp = self.post_delete_request(userid=self.admin.id)
        self.assertIn("You cannot delete yourself", resp.data)

        User.get(id=self.admin.id)

    def test_admin_cannot_delete_nonexistant_user(self):
        self.login(ADMINNAME, ADMINPASS)
        resp = self.post_delete_request(userid=200)
        self.assertEqual(resp.status_code, 404)

    def test_normal_user_cannot_delete_nonexistant_user(self):
        self.login(USERNAME, USERPASS)
        resp = self.post_delete_request(userid=200)
        self.assertEqual(resp.status_code, 404)

    def when_user_deleted_posts_also_deleted(self):
        self.login(ADMINNAME, ADMINPASS)
        # TODO
        pass
开发者ID:Fivebread,项目名称:streetsign,代码行数:80,代码来源:test_views_users_and_auth.py


注:本文中的streetsign_server.models.User.set_password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。