-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function checking for login availability
- Loading branch information
1 parent
f6a6bc9
commit 700cfc7
Showing
2 changed files
with
50 additions
and
4 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,25 @@ | ||
import pytest | ||
|
||
from pycroft.helpers.user import login_hash | ||
from pycroft.lib.user import login_available | ||
from pycroft.model.unix_account import UnixTombstone | ||
|
||
|
||
def test_login_reuse_present(session, processor): | ||
assert not login_available(processor.login, session) | ||
|
||
|
||
LOGIN = "taken" | ||
|
||
|
||
def test_login_reuse_past(session, tombstone): | ||
assert not login_available(LOGIN, session) | ||
assert login_available(f"not-{LOGIN}", session) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def tombstone(module_session) -> UnixTombstone: | ||
ts = UnixTombstone(login_hash=login_hash(LOGIN)) | ||
with module_session.begin_nested(): | ||
module_session.add(ts) | ||
return ts |