Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
truenas-rk3588
truenas
Commits
cd070b41
Unverified
Commit
cd070b41
authored
1 year ago
by
sonicaj
Committed by
GitHub
1 year ago
Browse files
Options
Download
Email Patches
Plain Diff
Backport common checks asset to DF for roles based integration tests (#13191)
parent
7b251135
stable/dragonfish
NAS-127422-24.04-RC.1
NAS-127559-24.04-RC.1
NAS-127702
NAS-127840-24.04.0
NAS-127922-24.04.0
NAS-128040-24.04.0
awalker_testing_ad
df_fail_test_012
release/24.04-RC.1
release/24.04.0
TS-24.04-RC.1
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/middlewared/middlewared/test/integration/assets/roles.py
+29
-0
src/middlewared/middlewared/test/integration/assets/roles.py
with
29 additions
and
0 deletions
+29
-0
src/middlewared/middlewared/test/integration/assets/roles.py
0 → 100644
View file @
cd070b41
import
errno
import
pytest
from
middlewared.client.client
import
ClientException
from
middlewared.test.integration.assets.account
import
unprivileged_user_client
def
common_checks
(
method
,
role
,
valid_role
,
valid_role_exception
=
True
,
method_args
=
None
,
method_kwargs
=
None
,
is_return_type_none
=
False
):
method_args
=
method_args
or
[]
method_kwargs
=
method_kwargs
or
{}
with
unprivileged_user_client
(
roles
=
[
role
])
as
client
:
if
valid_role
:
if
valid_role_exception
:
with
pytest
.
raises
(
Exception
)
as
exc_info
:
client
.
call
(
method
,
*
method_args
,
**
method_kwargs
)
assert
not
isinstance
(
exc_info
.
value
,
ClientException
)
elif
is_return_type_none
:
assert
client
.
call
(
method
,
*
method_args
,
**
method_kwargs
)
is
None
else
:
assert
client
.
call
(
method
,
*
method_args
,
**
method_kwargs
)
is
not
None
else
:
with
pytest
.
raises
(
ClientException
)
as
ve
:
client
.
call
(
method
,
*
method_args
,
**
method_kwargs
)
assert
ve
.
value
.
errno
==
errno
.
EACCES
assert
ve
.
value
.
error
==
'Not authorized'
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help