-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
service: display tombstone for deleted record's files
- Loading branch information
Showing
11 changed files
with
515 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2023 CERN. | ||
# | ||
# Invenio-Records-Resources is free software; you can redistribute it and/or | ||
# modify it under the terms of the MIT License; see LICENSE file for more | ||
# details. | ||
|
||
"""Schemas for parameter parsing.""" | ||
|
||
from flask_resources.parsers import MultiDictSchema | ||
from marshmallow import Schema, fields | ||
|
||
|
||
class RequestExtraArgsSchema(MultiDictSchema): | ||
"""Schema for request extra args.""" | ||
|
||
include_deleted = fields.Bool() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
|
||
import pytest | ||
from flask_principal import Identity, Need, UserNeed | ||
from invenio_access import ActionRoles, superuser_access | ||
from invenio_accounts.models import Role | ||
from invenio_app.factory import create_api as _create_api | ||
from mock_module.config import MockFileServiceConfig, ServiceConfig | ||
|
||
|
@@ -100,3 +102,48 @@ def identity_simple(): | |
i.provides.add(UserNeed(1)) | ||
i.provides.add(Need(method="system_role", value="any_user")) | ||
return i | ||
|
||
|
||
@pytest.fixture() | ||
def superuser_role_need(db): | ||
"""Store 1 role with 'superuser-access' ActionNeed. | ||
WHY: This is needed because expansion of ActionNeed is | ||
done on the basis of a User/Role being associated with that Need. | ||
If no User/Role is associated with that Need (in the DB), the | ||
permission is expanded to an empty list. | ||
""" | ||
role = Role(name="superuser-access") | ||
db.session.add(role) | ||
|
||
action_role = ActionRoles.create(action=superuser_access, role=role) | ||
db.session.add(action_role) | ||
|
||
db.session.commit() | ||
|
||
return action_role.need | ||
|
||
|
||
@pytest.fixture() | ||
def superuser(UserFixture, app, db, superuser_role_need): | ||
"""Superuser.""" | ||
u = UserFixture( | ||
email="[email protected]", | ||
password="superuser", | ||
) | ||
u.create(app, db) | ||
|
||
datastore = app.extensions["security"].datastore | ||
_, role = datastore._prepare_role_modify_args(u.user, "superuser-access") | ||
|
||
datastore.add_role_to_user(u.user, role) | ||
db.session.commit() | ||
return u | ||
|
||
|
||
@pytest.fixture() | ||
def superuser_identity(superuser_role_need): | ||
"""Superuser identity fixture.""" | ||
identity = Identity(1) | ||
identity.provides.add(superuser_role_need) | ||
return identity |
Oops, something went wrong.