Compare commits

...

3 Commits
2.6.0 ... 2.6.1

Author SHA1 Message Date
5bbb9d269b Release 2.6.1 2023-01-25 15:28:27 +02:00
17466d8d37 make oauth client trully optional (#84)
Same old song, after migraiton to packages some optional modules are
being imported globally which lead to making hard dependency
2023-01-25 15:25:42 +02:00
9e4e3b701b enable lock for web service 2023-01-18 01:39:55 +02:00
17 changed files with 3401 additions and 3448 deletions

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 720 KiB

After

Width:  |  Height:  |  Size: 673 KiB

View File

@ -1,4 +1,4 @@
.TH AHRIMAN "1" "2023\-01\-16" "ahriman" "Generated Python Manual" .TH AHRIMAN "1" "2023\-01\-25" "ahriman" "Generated Python Manual"
.SH NAME .SH NAME
ahriman ahriman
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -1,7 +1,7 @@
# Maintainer: Evgeniy Alekseev # Maintainer: Evgeniy Alekseev
pkgname='ahriman' pkgname='ahriman'
pkgver=2.6.0 pkgver=2.6.1
pkgrel=1 pkgrel=1
pkgdesc="ArcH linux ReposItory MANager" pkgdesc="ArcH linux ReposItory MANager"
arch=('any') arch=('any')

View File

@ -929,7 +929,8 @@ def _set_web_parser(root: SubParserAction) -> argparse.ArgumentParser:
argparse.ArgumentParser: created argument parser argparse.ArgumentParser: created argument parser
""" """
parser = root.add_parser("web", help="web server", description="start web server", formatter_class=_formatter) parser = root.add_parser("web", help="web server", description="start web server", formatter_class=_formatter)
parser.set_defaults(handler=handlers.Web, lock=None, report=False, parser=_parser) parser.set_defaults(handler=handlers.Web, lock=Path(tempfile.gettempdir()) / "ahriman-web.lock", report=False,
parser=_parser)
return parser return parser

View File

@ -21,7 +21,6 @@ from __future__ import annotations
import argparse import argparse
from pathlib import Path
from types import TracebackType from types import TracebackType
from typing import Literal, Optional, Type from typing import Literal, Optional, Type
@ -68,7 +67,8 @@ class Lock(LazyLogging):
architecture(str): repository architecture architecture(str): repository architecture
configuration(Configuration): configuration instance configuration(Configuration): configuration instance
""" """
self.path = Path(f"{args.lock}_{architecture}") if args.lock is not None else None self.path = args.lock.with_stem(f"{args.lock.stem}_{architecture}") if args.lock is not None else None
print(self.path)
self.force = args.force self.force = args.force
self.unsafe = args.unsafe self.unsafe = args.unsafe

View File

@ -18,6 +18,3 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
from ahriman.core.auth.auth import Auth from ahriman.core.auth.auth import Auth
from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth.oauth import OAuth

View File

@ -78,10 +78,10 @@ class Auth(LazyLogging):
""" """
provider = AuthSettings.from_option(configuration.get("auth", "target", fallback="disabled")) provider = AuthSettings.from_option(configuration.get("auth", "target", fallback="disabled"))
if provider == AuthSettings.Configuration: if provider == AuthSettings.Configuration:
from ahriman.core.auth import Mapping from ahriman.core.auth.mapping import Mapping
return Mapping(configuration, database) return Mapping(configuration, database)
if provider == AuthSettings.OAuth: if provider == AuthSettings.OAuth:
from ahriman.core.auth import OAuth from ahriman.core.auth.oauth import OAuth
return OAuth(configuration, database) return OAuth(configuration, database)
return cls(configuration) return cls(configuration)

View File

@ -21,7 +21,7 @@ import aioauth_client
from typing import Optional, Type from typing import Optional, Type
from ahriman.core.auth import Mapping from ahriman.core.auth.mapping import Mapping
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite from ahriman.core.database import SQLite
from ahriman.core.exceptions import OptionError from ahriman.core.exceptions import OptionError

View File

@ -17,4 +17,4 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
__version__ = "2.6.0" __version__ = "2.6.1"

View File

@ -53,7 +53,7 @@ class LoginView(BaseView):
Examples: Examples:
This request must not be used directly. This request must not be used directly.
""" """
from ahriman.core.auth import OAuth from ahriman.core.auth.oauth import OAuth
oauth_provider = self.validator oauth_provider = self.validator
if not isinstance(oauth_provider, OAuth): # there is actually property, but mypy does not like it anyway if not isinstance(oauth_provider, OAuth): # there is actually property, but mypy does not like it anyway

View File

@ -754,11 +754,10 @@ def test_subparsers_user_remove_architecture(parser: argparse.ArgumentParser) ->
def test_subparsers_web(parser: argparse.ArgumentParser) -> None: def test_subparsers_web(parser: argparse.ArgumentParser) -> None:
""" """
web command must imply lock, report and parser web command must imply report and parser
""" """
args = parser.parse_args(["-a", "x86_64", "web"]) args = parser.parse_args(["-a", "x86_64", "web"])
assert args.architecture == ["x86_64"] assert args.architecture == ["x86_64"]
assert args.lock is None
assert not args.report assert not args.report
assert args.parser is not None and args.parser() assert args.parser is not None and args.parser()

View File

@ -1,3 +1,4 @@
import argparse
import pytest import pytest
import tempfile import tempfile
@ -7,11 +8,26 @@ from unittest.mock import call as MockCall
from ahriman import version from ahriman import version
from ahriman.application.lock import Lock from ahriman.application.lock import Lock
from ahriman.core.configuration import Configuration
from ahriman.core.exceptions import DuplicateRunError, UnsafeRunError from ahriman.core.exceptions import DuplicateRunError, UnsafeRunError
from ahriman.models.build_status import BuildStatus, BuildStatusEnum from ahriman.models.build_status import BuildStatus, BuildStatusEnum
from ahriman.models.internal_status import InternalStatus from ahriman.models.internal_status import InternalStatus
def test_path(args: argparse.Namespace, configuration: Configuration) -> None:
"""
must create path variable correctly
"""
assert Lock(args, "x86_64", configuration).path is None
args.lock = Path("/run/ahriman.lock")
assert Lock(args, "x86_64", configuration).path == Path("/run/ahriman_x86_64.lock")
with pytest.raises(ValueError):
args.lock = Path("/")
Lock(args, "x86_64", configuration).path # special case
def test_check_version(lock: Lock, mocker: MockerFixture) -> None: def test_check_version(lock: Lock, mocker: MockerFixture) -> None:
""" """
must check version correctly must check version correctly

View File

@ -1,6 +1,7 @@
import pytest import pytest
from ahriman.core.auth import Mapping, OAuth from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth.oauth import OAuth
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite from ahriman.core.database import SQLite

View File

@ -1,4 +1,6 @@
from ahriman.core.auth import Auth, Mapping, OAuth from ahriman.core.auth import Auth
from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth.oauth import OAuth
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite from ahriman.core.database import SQLite
from ahriman.models.user import User from ahriman.models.user import User

View File

@ -1,6 +1,6 @@
from pytest_mock import MockerFixture from pytest_mock import MockerFixture
from ahriman.core.auth import Mapping from ahriman.core.auth.mapping import Mapping
from ahriman.models.user import User from ahriman.models.user import User
from ahriman.models.user_access import UserAccess from ahriman.models.user_access import UserAccess

View File

@ -3,7 +3,7 @@ import pytest
from pytest_mock import MockerFixture from pytest_mock import MockerFixture
from ahriman.core.auth import OAuth from ahriman.core.auth.oauth import OAuth
from ahriman.core.exceptions import OptionError from ahriman.core.exceptions import OptionError

View File

@ -9,7 +9,7 @@ from unittest.mock import MagicMock
import ahriman.core.auth.helpers import ahriman.core.auth.helpers
from ahriman.core.auth import OAuth from ahriman.core.auth.oauth import OAuth
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite from ahriman.core.database import SQLite
from ahriman.core.repository import Repository from ahriman.core.repository import Repository