mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-03 09:05:49 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
bd0f850d25 | |||
5904727da2 | |||
263c53bac5 | |||
6743f1d62a |
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 812 KiB After Width: | Height: | Size: 809 KiB |
@ -1,4 +1,4 @@
|
||||
.TH AHRIMAN "1" "2023\-07\-22" "ahriman" "Generated Python Manual"
|
||||
.TH AHRIMAN "1" "2023\-07\-28" "ahriman" "Generated Python Manual"
|
||||
.SH NAME
|
||||
ahriman
|
||||
.SH SYNOPSIS
|
||||
@ -733,7 +733,7 @@ path to unix socket used for interprocess communications
|
||||
.SH COMMAND \fI\,'ahriman service\-shell'\/\fR
|
||||
usage: ahriman service\-shell [\-h] [code]
|
||||
|
||||
drop into python shell while having created application
|
||||
drop into python shell
|
||||
|
||||
.TP
|
||||
\fBcode\fR
|
||||
|
@ -20,6 +20,14 @@ ahriman.core.formatters.build\_printer module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.formatters.configuration\_paths\_printer module
|
||||
------------------------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.formatters.configuration_paths_printer
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.formatters.configuration\_printer module
|
||||
-----------------------------------------------------
|
||||
|
||||
|
@ -58,9 +58,9 @@ _shtab_ahriman_commands() {
|
||||
"service-config-validate:validate configuration and print found errors"
|
||||
"service-key-import:import PGP key from public sources to the repository user"
|
||||
"service-setup:create initial service configuration, requires root"
|
||||
"service-shell:drop into python shell while having created application"
|
||||
"service-shell:drop into python shell"
|
||||
"setup:create initial service configuration, requires root"
|
||||
"shell:drop into python shell while having created application"
|
||||
"shell:drop into python shell"
|
||||
"sign:(re-)sign packages and repository database according to current settings"
|
||||
"status:request status of the package"
|
||||
"status-update:update package status on the status page"
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Maintainer: Evgeniy Alekseev
|
||||
|
||||
pkgname='ahriman'
|
||||
pkgver=2.10.0
|
||||
pkgver=2.10.1
|
||||
pkgrel=1
|
||||
pkgdesc="ArcH linux ReposItory MANager"
|
||||
arch=('any')
|
||||
|
@ -904,8 +904,7 @@ def _set_service_shell_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
argparse.ArgumentParser: created argument parser
|
||||
"""
|
||||
parser = root.add_parser("service-shell", aliases=["shell"], help="invoke python shell",
|
||||
description="drop into python shell while having created application",
|
||||
formatter_class=_formatter)
|
||||
description="drop into python shell", formatter_class=_formatter)
|
||||
parser.add_argument("code", help="instead of dropping into shell, just execute the specified code", nargs="?")
|
||||
parser.add_argument("-v", "--verbose", help=argparse.SUPPRESS, action="store_true")
|
||||
parser.set_defaults(handler=handlers.Shell, lock=None, report=False)
|
||||
|
@ -23,7 +23,6 @@ import sys
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers import Handler
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.formatters import StringPrinter
|
||||
@ -47,14 +46,12 @@ class Shell(Handler):
|
||||
configuration(Configuration): configuration instance
|
||||
report(bool): force enable or disable reporting
|
||||
"""
|
||||
# pylint: disable=possibly-unused-variable
|
||||
application = Application(architecture, configuration, report=report)
|
||||
if args.verbose:
|
||||
# licensed by https://creativecommons.org/licenses/by-sa/3.0
|
||||
path = Path(sys.prefix) / "share" / "ahriman" / "templates" / "shell"
|
||||
StringPrinter(path.read_text(encoding="utf8")).print(verbose=False)
|
||||
# we only want to pass application instance inside
|
||||
local_variables = {"architecture": architecture, "configuration": configuration}
|
||||
if args.code is None:
|
||||
code.interact(local={"application": application})
|
||||
code.interact(local=local_variables)
|
||||
else:
|
||||
code.InteractiveConsole(locals={"application": application}).runcode(args.code)
|
||||
code.InteractiveConsole(locals=local_variables).runcode(args.code)
|
||||
|
@ -17,4 +17,4 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
__version__ = "2.10.0"
|
||||
__version__ = "2.10.1"
|
||||
|
@ -17,3 +17,22 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from ahriman.web.schemas.aur_package_schema import AURPackageSchema
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.counters_schema import CountersSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.internal_status_schema import InternalStatusSchema
|
||||
from ahriman.web.schemas.log_schema import LogSchema
|
||||
from ahriman.web.schemas.login_schema import LoginSchema
|
||||
from ahriman.web.schemas.logs_schema import LogsSchema
|
||||
from ahriman.web.schemas.oauth2_schema import OAuth2Schema
|
||||
from ahriman.web.schemas.package_name_schema import PackageNameSchema
|
||||
from ahriman.web.schemas.package_names_schema import PackageNamesSchema
|
||||
from ahriman.web.schemas.package_properties_schema import PackagePropertiesSchema
|
||||
from ahriman.web.schemas.package_schema import PackageSchema
|
||||
from ahriman.web.schemas.package_status_schema import PackageStatusSimplifiedSchema, PackageStatusSchema
|
||||
from ahriman.web.schemas.pgp_key_id_schema import PGPKeyIdSchema
|
||||
from ahriman.web.schemas.pgp_key_schema import PGPKeySchema
|
||||
from ahriman.web.schemas.remote_schema import RemoteSchema
|
||||
from ahriman.web.schemas.search_schema import SearchSchema
|
||||
from ahriman.web.schemas.status_schema import StatusSchema
|
||||
|
@ -22,9 +22,7 @@ import aiohttp_apispec # type: ignore[import]
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.package_names_schema import PackageNamesSchema
|
||||
from ahriman.web.schemas import AuthSchema, ErrorSchema, PackageNamesSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -22,10 +22,7 @@ import aiohttp_apispec # type: ignore[import]
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent, HTTPNotFound, Response, json_response
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.pgp_key_id_schema import PGPKeyIdSchema
|
||||
from ahriman.web.schemas.pgp_key_schema import PGPKeySchema
|
||||
from ahriman.web.schemas import AuthSchema, ErrorSchema, PGPKeyIdSchema, PGPKeySchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -22,9 +22,7 @@ import aiohttp_apispec # type: ignore[import]
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.package_names_schema import PackageNamesSchema
|
||||
from ahriman.web.schemas import AuthSchema, ErrorSchema, PackageNamesSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -22,9 +22,7 @@ import aiohttp_apispec # type: ignore[import]
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.package_names_schema import PackageNamesSchema
|
||||
from ahriman.web.schemas import AuthSchema, ErrorSchema, PackageNamesSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -22,9 +22,7 @@ import aiohttp_apispec # type: ignore[import]
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.package_names_schema import PackageNamesSchema
|
||||
from ahriman.web.schemas import AuthSchema, ErrorSchema, PackageNamesSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -25,10 +25,7 @@ from collections.abc import Callable
|
||||
from ahriman.core.alpm.remote import AUR
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.aur_package_schema import AURPackageSchema
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.search_schema import SearchSchema
|
||||
from ahriman.web.schemas import AURPackageSchema, AuthSchema, ErrorSchema, SearchSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -22,8 +22,7 @@ import aiohttp_apispec # type: ignore[import]
|
||||
from aiohttp.web import HTTPNoContent
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas import AuthSchema, ErrorSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -24,11 +24,7 @@ from aiohttp.web import HTTPBadRequest, HTTPNoContent, HTTPNotFound, Response, j
|
||||
from ahriman.core.exceptions import UnknownPackageError
|
||||
from ahriman.models.log_record_id import LogRecordId
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.log_schema import LogSchema
|
||||
from ahriman.web.schemas.logs_schema import LogsSchema
|
||||
from ahriman.web.schemas.package_name_schema import PackageNameSchema
|
||||
from ahriman.web.schemas import AuthSchema, ErrorSchema, LogSchema, LogsSchema, PackageNameSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -25,10 +25,7 @@ from ahriman.core.exceptions import UnknownPackageError
|
||||
from ahriman.models.build_status import BuildStatusEnum
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.package_name_schema import PackageNameSchema
|
||||
from ahriman.web.schemas.package_status_schema import PackageStatusSchema, PackageStatusSimplifiedSchema
|
||||
from ahriman.web.schemas import AuthSchema, ErrorSchema, PackageNameSchema, PackageStatusSchema, PackageStatusSimplifiedSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -22,9 +22,7 @@ import aiohttp_apispec # type: ignore[import]
|
||||
from aiohttp.web import HTTPNoContent, Response, json_response
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.package_status_schema import PackageStatusSchema
|
||||
from ahriman.web.schemas import AuthSchema, ErrorSchema, PackageStatusSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -26,10 +26,7 @@ from ahriman.models.build_status import BuildStatusEnum
|
||||
from ahriman.models.counters import Counters
|
||||
from ahriman.models.internal_status import InternalStatus
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.internal_status_schema import InternalStatusSchema
|
||||
from ahriman.web.schemas.status_schema import StatusSchema
|
||||
from ahriman.web.schemas import AuthSchema, ErrorSchema, InternalStatusSchema, StatusSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -23,9 +23,7 @@ from aiohttp.web import HTTPFound, HTTPMethodNotAllowed, HTTPUnauthorized
|
||||
|
||||
from ahriman.core.auth.helpers import remember
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas.login_schema import LoginSchema
|
||||
from ahriman.web.schemas.oauth2_schema import OAuth2Schema
|
||||
from ahriman.web.schemas import ErrorSchema, LoginSchema, OAuth2Schema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
@ -66,7 +64,11 @@ class LoginView(BaseView):
|
||||
HTTPMethodNotAllowed: in case if method is used, but OAuth is disabled
|
||||
HTTPUnauthorized: if case of authorization error
|
||||
"""
|
||||
try:
|
||||
from ahriman.core.auth.oauth import OAuth
|
||||
except ImportError:
|
||||
# no aioauth library found
|
||||
raise HTTPMethodNotAllowed(self.request.method, ["POST"])
|
||||
|
||||
oauth_provider = self.validator
|
||||
if not isinstance(oauth_provider, OAuth): # there is actually property, but mypy does not like it anyway
|
||||
|
@ -23,8 +23,7 @@ from aiohttp.web import HTTPFound, HTTPUnauthorized
|
||||
|
||||
from ahriman.core.auth.helpers import check_authorized, forget
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas.error_schema import ErrorSchema
|
||||
from ahriman.web.schemas import AuthSchema, ErrorSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
|
@ -88,6 +88,30 @@ def get_package_status_extended(package: Package) -> dict[str, Any]:
|
||||
return {"status": BuildStatus().view(), "package": package.view()}
|
||||
|
||||
|
||||
@pytest.helpers.register
|
||||
def import_error(package: str, components: list[str], mocker: MockerFixture) -> MagicMock:
|
||||
"""
|
||||
mock import error
|
||||
|
||||
Args:
|
||||
package(str): package name to import
|
||||
components(list[str]): component to import if any (e.g. from ... import ...)
|
||||
mocker(MockerFixture): mocker object
|
||||
|
||||
Returns:
|
||||
MagicMock: mocked object
|
||||
"""
|
||||
import builtins
|
||||
_import = builtins.__import__
|
||||
|
||||
def test_import(name: str, globals: Any, locals: Any, from_list: list[str], level: Any):
|
||||
if name == package and (not components or any(component in from_list for component in components)):
|
||||
raise ImportError
|
||||
return _import(name, globals, locals, from_list, level)
|
||||
|
||||
return mocker.patch.object(builtins, "__import__", test_import)
|
||||
|
||||
|
||||
# generic fixtures
|
||||
@pytest.fixture
|
||||
def aur_package_ahriman() -> AURPackage:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ahriman.web.schemas.auth_schema import AuthSchema
|
||||
from ahriman.web.schemas import AuthSchema
|
||||
|
||||
|
||||
def test_schema() -> None:
|
||||
|
@ -1,5 +1,5 @@
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.web.schemas.package_name_schema import PackageNameSchema
|
||||
from ahriman.web.schemas import PackageNameSchema
|
||||
|
||||
|
||||
def test_schema(package_ahriman: Package) -> None:
|
||||
|
@ -25,6 +25,15 @@ async def test_get_default_validator(client_with_auth: TestClient) -> None:
|
||||
assert response.status == 405
|
||||
|
||||
|
||||
async def test_get_import_error(client_with_auth: TestClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return 405 on import error
|
||||
"""
|
||||
pytest.helpers.import_error("ahriman.core.auth.oauth", ["OAuth"], mocker)
|
||||
response = await client_with_auth.get("/api/v1/login")
|
||||
assert response.status == 405
|
||||
|
||||
|
||||
async def test_get_redirect_to_oauth(client_with_oauth_auth: TestClient) -> None:
|
||||
"""
|
||||
must redirect to OAuth service provider in case if no code is supplied
|
||||
|
Reference in New Issue
Block a user