Пример #1
0
    def test_get_works(self):
        invites.InvitesDAO.get(self.code).AndReturn(self.token)
        invites.auth.admin_client_set() \
                .AndReturn(self.fake_client_set)
        self.fake_client_set.identity_admin.users.get(self.user.id)\
                .AndReturn(self.user)
        invites.user_to_view(self.user, self.token).AndReturn('REPLY')

        self.mox.ReplayAll()
        rv = self.client.get('/v1/invites/%s' % self.code)
        data = self.check_and_parse_response(rv, authenticated=False)
        self.assertEquals(data, 'REPLY')
Пример #2
0
    def test_get_works(self):
        invites.InvitesDAO.get(self.code).AndReturn(self.token)
        invites.auth.admin_client_set() \
                .AndReturn(self.fake_client_set)
        self.fake_client_set.identity_admin.users.get(self.user.id)\
                .AndReturn(self.user)
        invites.user_to_view(self.user, self.token).AndReturn('REPLY')

        self.mox.ReplayAll()
        rv = self.client.get('/v1/invites/%s' % self.code)
        data = self.check_and_parse_response(rv, authenticated=False)
        self.assertEquals(data, 'REPLY')
Пример #3
0
    def test_accept_works(self):
        params = {'password': '******'}
        user_mgr = self.fake_client_set.identity_admin.users

        invites.InvitesDAO.get(self.code).AndReturn(self.token)
        invites.auth.admin_client_set().AndReturn(self.fake_client_set)
        user_mgr.get(self.user.id).AndReturn(self.user)
        invites.auth.admin_client_set().AndReturn(self.fake_client_set)
        user_mgr.update(self.user, enabled=True)
        user_mgr.update_password(self.user, '123')

        invites.auth.admin_client_set().AndReturn(self.fake_client_set)
        user_mgr.get(self.user.id).AndReturn(self.user)

        invites.InvitesDAO.complete_for_user(self.user.id)
        invites.user_to_view(self.user, self.token).AndReturn('REPLY')

        self.mox.ReplayAll()
        rv = self.client.put('/v1/invites/%s' % self.code,
                             data=json.dumps(params),
                             content_type='application/json')
        data = self.check_and_parse_response(rv, authenticated=False)
        self.assertEquals(data, 'REPLY')
Пример #4
0
    def test_accept_works(self):
        params = { 'password': '******' }
        user_mgr = self.fake_client_set.identity_admin.users

        invites.InvitesDAO.get(self.code).AndReturn(self.token)
        invites.auth.admin_client_set().AndReturn(self.fake_client_set)
        user_mgr.get(self.user.id).AndReturn(self.user)
        invites.auth.admin_client_set().AndReturn(self.fake_client_set)
        user_mgr.update(self.user, enabled=True)
        user_mgr.update_password(self.user, '123')

        invites.auth.admin_client_set().AndReturn(self.fake_client_set)
        user_mgr.get(self.user.id).AndReturn(self.user)

        invites.InvitesDAO.complete_for_user(self.user.id)
        invites.user_to_view(self.user, self.token).AndReturn('REPLY')

        self.mox.ReplayAll()
        rv = self.client.put('/v1/invites/%s' % self.code,
                             data=json.dumps(params),
                             content_type='application/json')
        data = self.check_and_parse_response(rv, authenticated=False)
        self.assertEquals(data, 'REPLY')