Esempio n. 1
0
def test_group_permissions(engine, session):
    _create_all(session)

    admins = Group.get_by_name(session, "admins")
    admins.permissions.append(Permission.get_by_name(session, "READ"))
    admins.permissions.append(Permission.get_by_name(session, "WRITE"))
    session.commit()

    admins = Group.get_by_name(session, "admins")
    assert ["READ", "WRITE"] == sorted(permission.name
                                       for permission in admins.permissions)
Esempio n. 2
0
def test_user_permissions(engine, session):
    _create_all(session)

    alice = User.get_by_username(session, "alice")
    alice.user_permissions.append(Permission.get_by_name(session, "READ"))
    alice.user_permissions.append(Permission.get_by_name(session, "WRITE"))
    session.commit()

    alice = User.get_by_username(session, "alice")
    assert ["READ",
            "WRITE"] == sorted(permission.name
                               for permission in alice.user_permissions)
Esempio n. 3
0
def test_permissions(engine, session):
    _create_all(session)

    alice = User.get_by_username(session, "alice")

    admins = Group.get_by_name(session, "admins")
    admins.users.append(alice)

    write_permission = Permission.get_by_name(session, "WRITE")
    write_permission.groups.append(admins)

    alice.user_permissions.append(Permission.get_by_name(session, "READ"))
    session.commit()

    alice = User.get_by_username(session, "alice")
    assert ["READ", "WRITE"] == sorted(permission.name
                                       for permission in alice.permissions)