Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-134087 / 25.04-RC.1 / Use a proper job id for download token test (by anodos325) #15665

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions tests/api2/test_audit_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
from middlewared.test.integration.utils.audit import expect_audit_log


@pytest.fixture(scope="module")
def job_with_pipe():
job_id, url = call("core.download", "config.save" , [], "debug.txz")
try:
yield job_id
finally:
call("core.job_abort", job_id)


@pytest.fixture(scope="module")
def download_token(job_with_pipe):
return call("auth.generate_token", 300, {"filename": "debug.txz", "job": job_with_pipe}, True)


@pytest.fixture(scope='function')
def sharing_admin_user(unprivileged_user_fixture):
privilege = call('privilege.query', [['local_groups.0.group', '=', unprivileged_user_fixture.group_name]])
Expand Down Expand Up @@ -315,9 +329,7 @@ def test_token_login_failed():
c.call("auth.login_with_token", "invalid_token")


def test_token_attributes_login_failed():
token = call("auth.generate_token", 300, {"filename": "debug.txz", "job": 1020}, True)

def test_token_attributes_login_failed(download_token):
with client(auth=None) as c:
with expect_audit_log([
{
Expand All @@ -326,15 +338,15 @@ def test_token_attributes_login_failed():
"credentials": {
"credentials": "TOKEN",
"credentials_data": {
"token": token,
"token": download_token,
},
},
"error": "Bad token",
},
"success": False,
}
], include_logins=True):
c.call("auth.login_with_token", token)
c.call("auth.login_with_token", download_token)


def test_api_key_login():
Expand Down