Beispiel #1
0
    def test_not_losing_inactives(self):
        u1 = User.testing_create()
        u2 = User.testing_create()
        u2.inactive_flag = True

        g = Group.testing_create()
        g.users = [u2]
        db.sess.commit()

        topost = {
            'approved_permissions': [],
            'assigned_users': [u1.id],
            'denied_permissions': [],
            'group-submit-flag': u'submitted',
            'name': g.name,
            'submit': u'Submit'
        }
        req, resp = self.c.post('groups/edit/{0}'.format(g.id),
                                data=topost,
                                follow_redirects=True)
        assert resp.status_code == 200, resp.status
        assert '/groups/manage' in req.url, req.url

        db.sess.expire(g)
        eq_(len(g.users), 2)
        assert u1 in g.users
        assert u2 in g.users
Beispiel #2
0
    def test_no_exc_with_user_permissions(self):
        u = User.testing_create()
        ap = Permission.testing_create()
        dp = Permission.testing_create()
        u.assign_permissions([ap.id], [dp.id])
        db.sess.commit()

        resp = self.tam.get('/users/permissions/{0}'.format(u.id))
        assert b'<h1>Permissions for: ' in resp

        d = resp.pyq
        assert str(d('td.approved a[href="/users/edit/{0}"]'.format(u.id)))
        assert str(d('td.denied a[href="/users/edit/{0}"]'.format(u.id)))
Beispiel #3
0
    def test_no_exc_with_group_permissions(self):
        g = Group.testing_create()
        ap = Permission.testing_create()
        dp = Permission.testing_create()
        g.assign_permissions([ap.id], [dp.id])
        u = User.testing_create(groups=g)

        resp = self.tam.get('/users/permissions/{0}'.format(u.id))
        assert b'<h1>Permissions for: ' in resp

        d = resp.pyq
        db.sess.add(g)
        assert str(d('td.approved a[href="/groups/edit/{0}"]'.format(g.id)))
        assert str(d('td.denied a[href="/groups/edit/{0}"]'.format(g.id)))
Beispiel #4
0
def is_group_fk_present():
    g = Group.testing_create()
    u = User.testing_create(groups=g)
    gid = g.id

    # delete the group with delete_where() because .delete() loads the ORM
    # object and then calls <session>.delete().  That method will trigger SA
    # to issue a DELETE statement on the map table. Therefore, using
    # .delete() would allow this test to pass even if our FK was not
    # configured correctly.
    Group.delete_where(Group.id == gid)

    # if there are no records left, then the FK is present
    try:
        return db.sess.query(tbl_ugm).filter(
            tbl_ugm.c.auth_group_id == gid).count() == 0
    finally:
        db.sess.execute(tbl_ugm.delete().where(tbl_ugm.c.auth_group_id == gid))
        User.delete(u.id)
Beispiel #5
0
 def setup_class(cls):
     cls.userid = User.testing_create().id
     cls.tam = TestApp(ag.wsgi_test_app)
     login_client_with_permissions(cls.tam, [u'auth-manage'])
Beispiel #6
0
 def test_users_manage_name_filter(self):
     u = User.testing_create()
     User.edit(u.id, name_first=u'Jack', name_last=u'Frost')
     r = self.c.get('/users/manage?op(name)=contains&v1(name)=Frost')
     assert b'<td>Jack Frost</td>' in r.data
Beispiel #7
0
    def test_users_manage_paging(self):
        User.testing_create()
        User.testing_create()

        r = self.c.get('/users/manage?onpage=2&perpage=1')
        assert b'<h2>Manage Users</h2>' in r.data