Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DataCatalog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eFlows4HPC WP2
DataCatalog
Commits
48cd35e6
Commit
48cd35e6
authored
3 years ago
by
Christian Boettcher
Browse files
Options
Downloads
Patches
Plain Diff
test acess denied for users without access rights
parent
cecf7f59
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/apiserver_tests/test_secretswithauth.py
+24
-0
24 additions, 0 deletions
tests/apiserver_tests/test_secretswithauth.py
with
24 additions
and
0 deletions
tests/apiserver_tests/test_secretswithauth.py
+
24
−
0
View file @
48cd35e6
...
@@ -11,6 +11,9 @@ proper_uuid = "3a33262e-276e-4de8-87bc-f2d5a0195faf"
...
@@ -11,6 +11,9 @@ proper_uuid = "3a33262e-276e-4de8-87bc-f2d5a0195faf"
def
myfunc
():
def
myfunc
():
return
User
(
username
=
'
secret_foo
'
,
email
=
'
secret_bar
'
,
has_secrets_access
=
True
)
return
User
(
username
=
'
secret_foo
'
,
email
=
'
secret_bar
'
,
has_secrets_access
=
True
)
def
non_access_user
():
return
User
(
username
=
'
secret_foo
'
,
email
=
'
secret_bar
'
,
has_secrets_access
=
False
)
class
UserTests
(
TestCase
):
class
UserTests
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -98,4 +101,25 @@ class UserTests(TestCase):
...
@@ -98,4 +101,25 @@ class UserTests(TestCase):
key
=
element
[
'
key
'
]
key
=
element
[
'
key
'
]
rsp
=
self
.
client
.
delete
(
f
'
/dataset/
{
self
.
dummy_oid
}
/secrets/
{
key
}
'
)
rsp
=
self
.
client
.
delete
(
f
'
/dataset/
{
self
.
dummy_oid
}
/secrets/
{
key
}
'
)
def
test_secrets_without_access
(
self
):
# override with non_access user
apiserver
.
app
.
dependency_overrides
[
apiserver
.
main
.
my_auth
]
=
non_access_user
apiserver
.
app
.
dependency_overrides
[
apiserver
.
main
.
my_user
]
=
non_access_user
# check if access for all secrets endpoints failed with 401 Auth required
# list secrets, add secret, get secret, delete secret
rsp
=
self
.
client
.
get
(
f
'
/dataset/
{
proper_uuid
}
/secrets
'
)
self
.
assertEqual
(
403
,
rsp
.
status_code
)
rsp
=
self
.
client
.
get
(
f
'
/dataset/
{
proper_uuid
}
/secrets/somespecificsecret
'
)
self
.
assertEqual
(
403
,
rsp
.
status_code
)
rsp
=
self
.
client
.
post
(
f
'
/dataset/
{
proper_uuid
}
/secrets
'
,
json
=
{
'
key
'
:
"
somekey
"
,
"
secret
"
:
"
somesecret
"
})
self
.
assertEqual
(
403
,
rsp
.
status_code
)
rsp
=
self
.
client
.
delete
(
f
'
/dataset/
{
proper_uuid
}
/secrets/somespecificsecret
'
)
self
.
assertEqual
(
403
,
rsp
.
status_code
)
# TODO test delete object, DO secrets disappear too? (currently they don't)
# TODO test delete object, DO secrets disappear too? (currently they don't)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment