Exemple #1
0
 def test_resources_with_perm_type_other_found(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     resource2 = add_resource_b(db_session, 2, 'test_resource')
     resource3 = add_resource(db_session, 3, 'test_resource')
     resource4 = add_resource_b(db_session, 4, 'test_resource')
     db_session.flush()
     permission = UserResourcePermission(perm_name='test_perm',
                                         user_id=created_user.id,
                                         resource_id=resource.resource_id)
     resource.user_permissions.append(permission)
     permission2 = UserResourcePermission(perm_name='test_perm',
                                          user_id=created_user.id,
                                          resource_id=resource2.resource_id)
     resource2.user_permissions.append(permission2)
     permission3 = UserResourcePermission(perm_name='test_perm',
                                          user_id=created_user.id,
                                          resource_id=resource3.resource_id)
     resource3.user_permissions.append(permission3)
     permission4 = UserResourcePermission(perm_name='test_perm',
                                          user_id=created_user.id,
                                          resource_id=resource4.resource_id)
     resource4.user_permissions.append(permission4)
     db_session.flush()
     resources = created_user.resources_with_perms(
         ['test_perm'],
         resource_types=['test_resource_b'],
         db_session=db_session).all()
     assert len(resources) == 2
 def test_resources_with_perm_type_other_found(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     resource2 = add_resource_b(db_session, 2, 'test_resource')
     resource3 = add_resource(db_session, 3, 'test_resource')
     resource4 = add_resource_b(db_session, 4, 'test_resource')
     db_session.flush()
     permission = UserResourcePermission(perm_name='test_perm',
                                         user_id=created_user.id,
                                         resource_id=resource.resource_id)
     resource.user_permissions.append(permission)
     permission2 = UserResourcePermission(perm_name='test_perm',
                                          user_id=created_user.id,
                                          resource_id=resource2.resource_id)
     resource2.user_permissions.append(permission2)
     permission3 = UserResourcePermission(perm_name='test_perm',
                                          user_id=created_user.id,
                                          resource_id=resource3.resource_id)
     resource3.user_permissions.append(permission3)
     permission4 = UserResourcePermission(perm_name='test_perm',
                                          user_id=created_user.id,
                                          resource_id=resource4.resource_id)
     resource4.user_permissions.append(permission4)
     db_session.flush()
     resources = created_user.resources_with_perms(['test_perm'],
                                                   resource_types=[
                                                       'test_resource_b'],
                                                   db_session=db_session).all()
     assert len(resources) == 2
    def test_resources_ids_with_perm(self, db_session):
        created_user = add_user(db_session)
        resource1 = add_resource(db_session, 1, 'test_resource1')
        resource2 = add_resource(db_session, 2, 'test_resource2')
        resource3 = add_resource(db_session, 3, 'test_resource3')

        permission1 = UserResourcePermission(perm_name='test_perm',
                                             user_id=created_user.id,
                                             resource_id=resource1.resource_id)
        permission2 = UserResourcePermission(perm_name='test_perm',
                                             user_id=created_user.id,
                                             resource_id=resource2.resource_id)
        permission3 = UserResourcePermission(perm_name='test_perm',
                                             user_id=created_user.id,
                                             resource_id=resource3.resource_id)

        resource1.user_permissions.append(permission1)
        resource2.user_permissions.append(permission2)
        resource3.user_permissions.append(permission3)

        db_session.flush()
        resources = created_user.resources_with_perms(['test_perm'],
                                                      resource_ids=[1, 3],
                                                      db_session=db_session).all()
        assert resources == [resource1, resource3]
    def test_resources_ids_with_perm(self, db_session):
        created_user = add_user(db_session)
        resource1 = add_resource(db_session, 1, "test_resource1")
        resource2 = add_resource(db_session, 2, "test_resource2")
        resource3 = add_resource(db_session, 3, "test_resource3")

        permission1 = UserResourcePermission(
            perm_name="test_perm",
            user_id=created_user.id,
            resource_id=resource1.resource_id,
        )
        permission2 = UserResourcePermission(
            perm_name="test_perm",
            user_id=created_user.id,
            resource_id=resource2.resource_id,
        )
        permission3 = UserResourcePermission(
            perm_name="test_perm",
            user_id=created_user.id,
            resource_id=resource3.resource_id,
        )

        resource1.user_permissions.append(permission1)
        resource2.user_permissions.append(permission2)
        resource3.user_permissions.append(permission3)

        db_session.flush()
        resources = UserService.resources_with_perms(
            created_user, ["test_perm"], resource_ids=[1, 3], db_session=db_session
        ).all()
        assert resources == [resource1, resource3]
Exemple #5
0
    def test_resources_ids_with_perm(self, db_session):
        created_user = add_user(db_session)
        resource1 = add_resource(db_session, 1, "test_resource1")
        resource2 = add_resource(db_session, 2, "test_resource2")
        resource3 = add_resource(db_session, 3, "test_resource3")

        permission1 = UserResourcePermission(
            perm_name="test_perm",
            user_id=created_user.id,
            resource_id=resource1.resource_id,
        )
        permission2 = UserResourcePermission(
            perm_name="test_perm",
            user_id=created_user.id,
            resource_id=resource2.resource_id,
        )
        permission3 = UserResourcePermission(
            perm_name="test_perm",
            user_id=created_user.id,
            resource_id=resource3.resource_id,
        )

        resource1.user_permissions.append(permission1)
        resource2.user_permissions.append(permission2)
        resource3.user_permissions.append(permission3)

        db_session.flush()
        resources = UserService.resources_with_perms(
            created_user, ["test_perm"],
            resource_ids=[1, 3],
            db_session=db_session).all()
        assert resources == [resource1, resource3]
Exemple #6
0
 def test_multiple_resources_with_perm(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     permission = UserResourcePermission(perm_name='test_perm',
                                         user_id=created_user.id,
                                         resource_id=resource.resource_id)
     resource.user_permissions.append(permission)
     resource2 = add_resource(db_session, 2, 'test_resource2')
     permission2 = UserResourcePermission(perm_name='test_perm',
                                          user_id=created_user.id,
                                          resource_id=resource2.resource_id)
     resource2.user_permissions.append(permission2)
     resources = created_user.resources_with_perms(
         ['test_perm'], db_session=db_session).all()
     assert resources == [resource, resource2]
Exemple #7
0
 def test_mixed_perms(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     permission = UserResourcePermission(perm_name='test_perm',
                                         user_id=created_user.id,
                                         resource_id=resource.resource_id)
     resource.user_permissions.append(permission)
     resource2 = add_resource(db_session, 2, 'test_resource')
     created_user.resources.append(resource2)
     resource3 = add_resource(db_session, 3, 'test_resource')
     resource4 = add_resource_b(db_session, 4, 'test_resource')
     db_session.flush()
     resources = created_user.resources_with_perms(
         ['test_perm'], db_session=db_session).all()
     found_ids = [r.resource_id for r in resources]
     assert sorted(found_ids) == [1, 2]
 def test_mixed_perms(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     permission = UserResourcePermission(
         perm_name='test_perm', user_id=created_user.id,
         resource_id=resource.resource_id)
     resource.user_permissions.append(permission)
     resource2 = add_resource(db_session, 2, 'test_resource')
     created_user.resources.append(resource2)
     resource3 = add_resource(db_session, 3, 'test_resource')
     resource4 = add_resource_b(db_session, 4, 'test_resource')
     db_session.flush()
     resources = created_user.resources_with_perms(['test_perm'],
                                                   db_session=db_session).all()
     found_ids = [r.resource_id for r in resources]
     assert sorted(found_ids) == [1, 2]
Exemple #9
0
 def test_owned_permissions(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     created_user.resources.append(resource)
     db_session.flush()
     resources = created_user.resources_with_perms(
         ['test_perm'], db_session=db_session).all()
     assert resources[0] == resource
Exemple #10
0
 def test_owned_permissions(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     created_user.resources.append(resource)
     db_session.flush()
     resources = UserService.resources_with_perms(
         created_user, ["test_perm"], db_session=db_session).all()
     assert resources[0] == resource
 def test_owned_permissions(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     created_user.resources.append(resource)
     db_session.flush()
     resources = created_user.resources_with_perms(
         ['test_perm'], db_session=db_session).all()
     assert resources[0] == resource
Exemple #12
0
 def test_resources_with_wrong_perm(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     permission = UserResourcePermission(perm_name='test_perm_bad',
                                         user_id=created_user.id,
                                         resource_id=resource.resource_id)
     with pytest.raises(AssertionError):
         resource.user_permissions.append(permission)
 def test_multiple_resources_with_perm(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     permission = UserResourcePermission(perm_name='test_perm',
                                         user_id=created_user.id,
                                         resource_id=resource.resource_id
                                         )
     resource.user_permissions.append(permission)
     resource2 = add_resource(db_session, 2, 'test_resource2')
     permission2 = UserResourcePermission(perm_name='test_perm',
                                          user_id=created_user.id,
                                          resource_id=resource2.resource_id
                                          )
     resource2.user_permissions.append(permission2)
     resources = created_user.resources_with_perms(['test_perm'],
                                                   db_session=db_session).all()
     assert resources == [resource, resource2]
Exemple #14
0
 def test_mixed_perms(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     permission = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource.resource_id,
     )
     resource.user_permissions.append(permission)
     resource2 = add_resource(db_session, 2, "test_resource")
     created_user.resources.append(resource2)
     add_resource(db_session, 3, "test_resource")
     add_resource_b(db_session, 4, "test_resource")
     db_session.flush()
     resources = UserService.resources_with_perms(
         created_user, ["test_perm"], db_session=db_session).all()
     found_ids = [r.resource_id for r in resources]
     assert sorted(found_ids) == [1, 2]
 def test_owned_permissions(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     created_user.resources.append(resource)
     db_session.flush()
     resources = UserService.resources_with_perms(
         created_user, ["test_perm"], db_session=db_session
     ).all()
     assert resources[0] == resource
 def test_mixed_perms(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     permission = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource.resource_id,
     )
     resource.user_permissions.append(permission)
     resource2 = add_resource(db_session, 2, "test_resource")
     created_user.resources.append(resource2)
     add_resource(db_session, 3, "test_resource")
     add_resource_b(db_session, 4, "test_resource")
     db_session.flush()
     resources = UserService.resources_with_perms(
         created_user, ["test_perm"], db_session=db_session
     ).all()
     found_ids = [r.resource_id for r in resources]
     assert sorted(found_ids) == [1, 2]
Exemple #17
0
 def test_multiple_resources_with_perm(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     permission = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource.resource_id,
     )
     resource.user_permissions.append(permission)
     resource2 = add_resource(db_session, 2, "test_resource2")
     permission2 = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource2.resource_id,
     )
     resource2.user_permissions.append(permission2)
     resources = UserService.resources_with_perms(
         created_user, ["test_perm"], db_session=db_session).all()
     assert resources == [resource, resource2]
 def test_resources_with_wrong_perm(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     permission = UserResourcePermission(
         perm_name='test_perm_bad',
         user_id=created_user.id,
         resource_id=resource.resource_id
     )
     with pytest.raises(AssertionError):
         resource.user_permissions.append(permission)
 def test_resources_with_group_permission(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     resource2 = add_resource(db_session, 2, "test_resource2")
     add_resource(db_session, 3, "test_resource3")
     group = add_group(db_session)
     group.users.append(created_user)
     group_permission = GroupResourcePermission(
         perm_name="test_perm", group_id=1, resource_id=resource.resource_id
     )
     group_permission2 = GroupResourcePermission(
         perm_name="foo_perm", group_id=1, resource_id=resource2.resource_id
     )
     resource.group_permissions.append(group_permission)
     resource2.group_permissions.append(group_permission2)
     db_session.flush()
     resources = UserService.resources_with_perms(
         created_user, ["foo_perm"], db_session=db_session
     ).all()
     assert resources[0] == resource2
Exemple #20
0
 def test_resources_with_perm(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     permission = UserResourcePermission(perm_name='test_perm',
                                         user_id=created_user.id,
                                         resource_id=resource.resource_id)
     resource.user_permissions.append(permission)
     db_session.flush()
     resources = created_user.resources_with_perms(
         ['test_perm'], db_session=db_session).all()
     assert resources[0] == resource
 def test_resources_with_perm(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     permission = UserResourcePermission(
         perm_name='test_perm', user_id=created_user.id,
         resource_id=resource.resource_id)
     resource.user_permissions.append(permission)
     db_session.flush()
     resources = created_user.resources_with_perms(['test_perm'],
                                                   db_session=db_session).all()
     assert resources[0] == resource
 def test_multiple_resources_with_perm(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     permission = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource.resource_id,
     )
     resource.user_permissions.append(permission)
     resource2 = add_resource(db_session, 2, "test_resource2")
     permission2 = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource2.resource_id,
     )
     resource2.user_permissions.append(permission2)
     resources = UserService.resources_with_perms(
         created_user, ["test_perm"], db_session=db_session
     ).all()
     assert resources == [resource, resource2]
Exemple #23
0
 def test_resources_with_wrong_group_permission(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     group = add_group(db_session, )
     group.users.append(created_user)
     group_permission = GroupResourcePermission(
         perm_name='test_perm_bad',
         group_id=group.id,
         resource_id=resource.resource_id)
     with pytest.raises(AssertionError):
         resource.group_permissions.append(group_permission)
 def test_resources_with_wrong_group_permission(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     group = add_group(db_session, )
     group.users.append(created_user)
     group_permission = GroupResourcePermission(
         perm_name='test_perm_bad',
         group_id=group.id,
         resource_id=resource.resource_id
     )
     with pytest.raises(AssertionError):
         resource.group_permissions.append(group_permission)
Exemple #25
0
 def test_resources_with_group_permission(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     resource2 = add_resource(db_session, 2, "test_resource2")
     add_resource(db_session, 3, "test_resource3")
     group = add_group(db_session)
     group.users.append(created_user)
     group_permission = GroupResourcePermission(
         perm_name="test_perm",
         group_id=1,
         resource_id=resource.resource_id)
     group_permission2 = GroupResourcePermission(
         perm_name="foo_perm",
         group_id=1,
         resource_id=resource2.resource_id)
     resource.group_permissions.append(group_permission)
     resource2.group_permissions.append(group_permission2)
     db_session.flush()
     resources = UserService.resources_with_perms(
         created_user, ["foo_perm"], db_session=db_session).all()
     assert resources[0] == resource2
Exemple #26
0
 def test_resources_with_group_permission(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     resource2 = add_resource(db_session, 2, 'test_resource2')
     add_resource(db_session, 3, 'test_resource3')
     group = add_group(db_session, )
     group.users.append(created_user)
     group_permission = GroupResourcePermission(
         perm_name='test_perm',
         group_id=1,
         resource_id=resource.resource_id)
     group_permission2 = GroupResourcePermission(
         perm_name='foo_perm',
         group_id=1,
         resource_id=resource2.resource_id)
     resource.group_permissions.append(group_permission)
     resource2.group_permissions.append(group_permission2)
     db_session.flush()
     resources = created_user.resources_with_perms(
         ['foo_perm'], db_session=db_session).all()
     assert resources[0] == resource2
Exemple #27
0
 def test_owned_permissions(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     created_user.resources.append(resource)
     db_session.flush()
     resources = UserService.resources_with_perms(
         created_user, ["test_perm"], db_session=db_session).all()
     assert resources[0] == resource
     permission = ResourceService.direct_perms_for_user(
         resource, created_user)[0]
     assert permission.owner is True
     assert permission.allowed is True
     assert permission.user.id == created_user.id
Exemple #28
0
 def test_resources_with_perm_type_other_found(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     resource2 = add_resource_b(db_session, 2, "test_resource")
     resource3 = add_resource(db_session, 3, "test_resource")
     resource4 = add_resource_b(db_session, 4, "test_resource")
     db_session.flush()
     permission = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource.resource_id,
     )
     resource.user_permissions.append(permission)
     permission2 = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource2.resource_id,
     )
     resource2.user_permissions.append(permission2)
     permission3 = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource3.resource_id,
     )
     resource3.user_permissions.append(permission3)
     permission4 = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource4.resource_id,
     )
     resource4.user_permissions.append(permission4)
     db_session.flush()
     resources = UserService.resources_with_perms(
         created_user,
         ["test_perm"],
         resource_types=["test_resource_b"],
         db_session=db_session,
     ).all()
     assert len(resources) == 2
Exemple #29
0
 def test_resources_with_perm(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     permission = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource.resource_id,
     )
     resource.user_permissions.append(permission)
     db_session.flush()
     resources = UserService.resources_with_perms(
         created_user, ["test_perm"], db_session=db_session).all()
     assert resources[0] == resource
 def test_resources_with_perm_type_other_found(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     resource2 = add_resource_b(db_session, 2, "test_resource")
     resource3 = add_resource(db_session, 3, "test_resource")
     resource4 = add_resource_b(db_session, 4, "test_resource")
     db_session.flush()
     permission = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource.resource_id,
     )
     resource.user_permissions.append(permission)
     permission2 = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource2.resource_id,
     )
     resource2.user_permissions.append(permission2)
     permission3 = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource3.resource_id,
     )
     resource3.user_permissions.append(permission3)
     permission4 = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource4.resource_id,
     )
     resource4.user_permissions.append(permission4)
     db_session.flush()
     resources = UserService.resources_with_perms(
         created_user,
         ["test_perm"],
         resource_types=["test_resource_b"],
         db_session=db_session,
     ).all()
     assert len(resources) == 2
 def test_resources_with_perm(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, "test_resource")
     permission = UserResourcePermission(
         perm_name="test_perm",
         user_id=created_user.id,
         resource_id=resource.resource_id,
     )
     resource.user_permissions.append(permission)
     db_session.flush()
     resources = UserService.resources_with_perms(
         created_user, ["test_perm"], db_session=db_session
     ).all()
     assert resources[0] == resource
 def test_resources_with_group_permission(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     resource2 = add_resource(db_session, 2, 'test_resource2')
     add_resource(db_session, 3, 'test_resource3')
     group = add_group(db_session, )
     group.users.append(created_user)
     group_permission = GroupResourcePermission(
         perm_name='test_perm',
         group_id=1,
         resource_id=resource.resource_id
     )
     group_permission2 = GroupResourcePermission(
         perm_name='foo_perm',
         group_id=1,
         resource_id=resource2.resource_id
     )
     resource.group_permissions.append(group_permission)
     resource2.group_permissions.append(group_permission2)
     db_session.flush()
     resources = created_user.resources_with_perms(['foo_perm'],
                                                   db_session=db_session).all()
     assert resources[0] == resource2
Exemple #33
0
    def test_resources_ids_with_perm(self, db_session):
        created_user = add_user(db_session)
        resource1 = add_resource(db_session, 1, 'test_resource1')
        resource2 = add_resource(db_session, 2, 'test_resource2')
        resource3 = add_resource(db_session, 3, 'test_resource3')

        permission1 = UserResourcePermission(perm_name='test_perm',
                                             user_id=created_user.id,
                                             resource_id=resource1.resource_id)
        permission2 = UserResourcePermission(perm_name='test_perm',
                                             user_id=created_user.id,
                                             resource_id=resource2.resource_id)
        permission3 = UserResourcePermission(perm_name='test_perm',
                                             user_id=created_user.id,
                                             resource_id=resource3.resource_id)

        resource1.user_permissions.append(permission1)
        resource2.user_permissions.append(permission2)
        resource3.user_permissions.append(permission3)

        db_session.flush()
        resources = created_user.resources_with_perms(
            ['test_perm'], resource_ids=[1, 3], db_session=db_session).all()
        assert resources == [resource1, resource3]
Exemple #34
0
 def test_get_resource_permission(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     permission = UserResourcePermission(perm_name='test_perm',
                                         user_id=created_user.id,
                                         resource_id=resource.resource_id)
     resource.user_permissions.append(permission)
     db_session.flush()
     perm = UserResourcePermissionService.get(
         user_id=created_user.id,
         resource_id=resource.resource_id,
         perm_name='test_perm',
         db_session=db_session)
     assert perm.perm_name == 'test_perm'
     assert perm.resource_id == resource.resource_id
     assert perm.user_id == created_user.id
 def test_get_resource_permission(self, db_session):
     created_user = add_user(db_session)
     resource = add_resource(db_session, 1, 'test_resource')
     permission = UserResourcePermission(
         perm_name='test_perm', user_id=created_user.id,
         resource_id=resource.resource_id)
     resource.user_permissions.append(permission)
     db_session.flush()
     perm = UserResourcePermissionService.get(
         user_id=created_user.id,
         resource_id=resource.resource_id,
         perm_name='test_perm',
         db_session=db_session
     )
     assert perm.perm_name == 'test_perm'
     assert perm.resource_id == resource.resource_id
     assert perm.user_id == created_user.id
 def test_get(self, db_session):
     add_resource(db_session, 1, 'root')
     resource = ResourceService.get(resource_id=1, db_session=db_session)
     assert resource.resource_id == 1
     assert resource.resource_name == 'root'
 def test_pkey(self, db_session):
     resource = add_resource(db_session, 99, "some random name")
     assert resource.resource_id == 99
 def test_nopkey(self, db_session):
     resource = add_resource(db_session, None, 'some random name')
     assert resource.resource_id == 1
Exemple #39
0
 def test_pkey(self, db_session):
     resource = add_resource(db_session, 99, 'some random name')
     assert resource.resource_id == 99
Exemple #40
0
 def test_nopkey(self, db_session):
     resource = add_resource(db_session, None, "some random name")
     assert resource.resource_id == 1