mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
single-shot auth using headers
This commit is contained in:
@@ -39,16 +39,16 @@ async def test_ok__htpasswd_service(tmpdir) -> None: # type: ignore
|
||||
htpasswd.save()
|
||||
|
||||
async with get_configured_auth_service("htpasswd", file=path) as service:
|
||||
assert not (await service.login("user", "foo"))
|
||||
assert not (await service.login("admin", "foo"))
|
||||
assert not (await service.login("user", "pass"))
|
||||
assert (await service.login("admin", "pass"))
|
||||
assert not (await service.authorize("user", "foo"))
|
||||
assert not (await service.authorize("admin", "foo"))
|
||||
assert not (await service.authorize("user", "pass"))
|
||||
assert (await service.authorize("admin", "pass"))
|
||||
|
||||
htpasswd.set_password("admin", "bar")
|
||||
htpasswd.set_password("user", "bar")
|
||||
htpasswd.save()
|
||||
|
||||
assert (await service.login("admin", "bar"))
|
||||
assert (await service.login("user", "bar"))
|
||||
assert not (await service.login("admin", "foo"))
|
||||
assert not (await service.login("user", "foo"))
|
||||
assert (await service.authorize("admin", "bar"))
|
||||
assert (await service.authorize("user", "bar"))
|
||||
assert not (await service.authorize("admin", "foo"))
|
||||
assert not (await service.authorize("user", "foo"))
|
||||
|
||||
@@ -73,7 +73,7 @@ async def test_ok(auth_server_port: int, kwargs: Dict) -> None:
|
||||
("auth_plus_basic" if kwargs.get("user") else "auth"),
|
||||
)
|
||||
async with get_configured_auth_service("http", url=url, **kwargs) as service:
|
||||
assert not (await service.login("user", "foobar"))
|
||||
assert not (await service.login("admin", "foobar"))
|
||||
assert not (await service.login("user", "pass"))
|
||||
assert (await service.login("admin", "pass"))
|
||||
assert not (await service.authorize("user", "foobar"))
|
||||
assert not (await service.authorize("admin", "foobar"))
|
||||
assert not (await service.authorize("user", "pass"))
|
||||
assert (await service.authorize("admin", "pass"))
|
||||
|
||||
Reference in New Issue
Block a user