def setUp(self, settings={}):
     super(ResetPasswordFormTests, self).setUp(settings=settings)
     vccs_url = self.settings['vccs_url']
     fake_vccs_client = FakeVCCSClient()
     mock_config = {
         'return_value': fake_vccs_client,
     }
     self.patcher = patch.object(vccs, 'get_vccs_client', **mock_config)
     self.patcher.start()
     add_credentials(vccs_url, 'xxx', self.initial_password, self.user)
Пример #2
0
 def setUp(self, settings={}):
     super(ResetPasswordFormTests,
           self).setUp(settings=settings,
                       std_user='******')
     vccs_url = self.settings['vccs_url']
     fake_vccs_client = FakeVCCSClient()
     mock_config = {
         'return_value': fake_vccs_client,
     }
     self.patcher = patch.object(vccs, 'get_vccs_client', **mock_config)
     self.patcher.start()
     add_credentials(vccs_url, 'xxx', self.initial_password, self.user)
    def test_add_credentials(self):
        vccs_url = self.settings['vccs_url']
        self.assertTrue(check_password(vccs_url, self.initial_password, self.user))
        new_password = '******'
        add_credentials(vccs_url, self.initial_password, new_password, self.user)
        self.assertTrue(check_password(vccs_url, new_password, self.user))

        with patch('eduiddashboard.vccs', clear=True):
            vccs.get_vccs_client.return_value = FakeVCCSClient(fake_response={
                'auth_response': {
                    'version': 1,
                    'authenticated': False,
                },
            })
            self.assertFalse(check_password(vccs_url, self.initial_password, self.user))
Пример #4
0
def change_password(request, user, old_password, new_password):
    """ Change the user password, deleting old credentials """
    vccs_url = request.registry.settings.get('vccs_url')
    added = add_credentials(vccs_url, old_password, new_password, user)
    if added:
        user.save(request)
    return added
Пример #5
0
    def test_add_credentials(self):
        vccs_url = self.settings['vccs_url']
        self.assertTrue(
            check_password(vccs_url, self.initial_password, self.user))
        new_password = '******'
        add_credentials(vccs_url, self.initial_password, new_password,
                        self.user)
        self.assertTrue(check_password(vccs_url, new_password, self.user))

        with patch('eduiddashboard.vccs', clear=True):
            vccs.get_vccs_client.return_value = FakeVCCSClient(fake_response={
                'auth_response': {
                    'version': 1,
                    'authenticated': False,
                },
            })
            self.assertFalse(
                check_password(vccs_url, self.initial_password, self.user))
Пример #6
0
def change_password(request, user, old_password, new_password):
    """ Change the user password, deleting old credentials """
    vccs_url = request.registry.settings.get('vccs_url')
    added = add_credentials(vccs_url, old_password, new_password, user)
    if added:
        user.set_terminated(terminate=False)
        update_doc = {'$set': {'passwords': user.get_passwords(),
                               'terminated': None}}
        user.save(request, check_sync=False, update_doc=update_doc)
    return added
Пример #7
0
def change_password(request, user, old_password, new_password):
    """
    Change the user password, deleting old credentials

    @param request: Request object
    @param user: User object
    @param old_password: Old password, if supplied (i.e. not a password reset)
    @param new_password: New password

    @type request: Request
    @type user: User
    @type old_password: str or unicode or None
    """
    vccs_url = request.registry.settings.get('vccs_url')
    log.debug("Changing password user {!s}\nTIMESTAMP 1 {!s}".format(user, user.modified_ts))
    added = add_credentials(vccs_url, old_password, new_password, user)
    log.debug("Changing password user {!s}\nTIMESTAMP 2 {!s}".format(user, user.modified_ts))
    if added:
        retrieve_modified_ts(user, request.dashboard_userdb)
        user.terminated = False
        request.context.save_dashboard_user(user)
    return added
Пример #8
0
def change_password(request, user, old_password, new_password):
    """
    Change the user password, deleting old credentials

    @param request: Request object
    @param user: User object
    @param old_password: Old password, if supplied (i.e. not a password reset)
    @param new_password: New password

    @type request: Request
    @type user: User
    @type old_password: str or unicode or None
    """
    vccs_url = request.registry.settings.get('vccs_url')
    log.debug("Changing password user {!s}\nTIMESTAMP 1 {!s}".format(
        user, user.modified_ts))
    added = add_credentials(vccs_url, old_password, new_password, user)
    log.debug("Changing password user {!s}\nTIMESTAMP 2 {!s}".format(
        user, user.modified_ts))
    if added:
        retrieve_modified_ts(user, request.dashboard_userdb)
        user.terminated = False
        request.context.save_dashboard_user(user)
    return added