Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Airflow Datacat Integration
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
Airflow Datacat Integration
Commits
ef632c33
Commit
ef632c33
authored
3 years ago
by
Christian Boettcher
Browse files
Options
Downloads
Patches
Plain Diff
add first basic testcase for secrets backend
parent
cd65a836
Branches
Branches containing commit
Tags
release-v0.0.9
Tags containing commit
No related merge requests found
Pipeline
#86466
passed
3 years ago
Stage: test
Stage: build
Stage: publish
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/datacat_integration/secrets.py
+4
-4
4 additions, 4 deletions
src/datacat_integration/secrets.py
tests/test_secrets.py
+20
-0
20 additions, 0 deletions
tests/test_secrets.py
with
24 additions
and
4 deletions
src/datacat_integration/secrets.py
+
4
−
4
View file @
ef632c33
...
@@ -20,13 +20,13 @@ def get_connection_with_secrets_from_entry(data: Dict[str, Any], secrets: Dict[s
...
@@ -20,13 +20,13 @@ def get_connection_with_secrets_from_entry(data: Dict[str, Any], secrets: Dict[s
conn
.
password
=
secrets
.
get
(
'
password
'
)
conn
.
password
=
secrets
.
get
(
'
password
'
)
conn
.
login
=
secrets
.
get
(
'
login
'
)
conn
.
login
=
secrets
.
get
(
'
login
'
)
# add all remaining secrets to extra
# add all remaining secrets to extra
extra
=
conn
.
extra
extra
=
json
.
loads
(
conn
.
extra
)
for
key
in
secrets
.
keys
():
for
key
in
secrets
.
keys
():
if
key
in
[
'
password
'
,
'
login
'
]:
if
key
in
[
'
password
'
,
'
login
'
]:
continue
continue
extra
[
key
]
=
secrets
[
key
]
extra
[
key
]
=
secrets
[
key
]
conn
.
extra
=
extra
conn
.
extra
=
json
.
dumps
(
extra
)
return
conn
return
conn
...
@@ -88,7 +88,7 @@ class DatacatSecretsBackend(BaseSecretsBackend):
...
@@ -88,7 +88,7 @@ class DatacatSecretsBackend(BaseSecretsBackend):
log
.
debug
(
f
"
Get connection:
{
conn_id
}
"
)
log
.
debug
(
f
"
Get connection:
{
conn_id
}
"
)
secrets_conn
=
DataCatConnectionWithSecrets
(
self
.
url
,
self
.
user
,
self
.
password
)
secrets_conn
=
DataCatConnectionWithSecrets
(
self
.
url
,
self
.
user
,
self
.
password
)
data
=
DataCatalogEntry
.
from_json
(
secrets_conn
.
get_entry
(
connection_backend_type
,
conn_id
)).
__dict__
data
:
Dict
[
str
,
str
]
=
DataCatalogEntry
.
from_json
(
secrets_conn
.
get_entry
(
connection_backend_type
,
conn_id
)).
__dict__
secrets
=
json
.
loads
(
secrets_conn
.
get_all_secret_key_value
(
connection_backend_type
,
conn_id
))
secrets
:
Dict
[
str
,
str
]
=
json
.
loads
(
secrets_conn
.
get_all_secret_key_value
(
connection_backend_type
,
conn_id
))
conn
=
get_connection_with_secrets_from_entry
(
data
,
secrets
,
connection_backend_type
,
conn_id
)
conn
=
get_connection_with_secrets_from_entry
(
data
,
secrets
,
connection_backend_type
,
conn_id
)
return
conn
return
conn
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/test_secrets.py
0 → 100644
+
20
−
0
View file @
ef632c33
from
unittest
import
TestCase
from
datacat_integration.secrets
import
DataCatConnectionWithSecrets
,
get_connection_with_secrets_from_entry
,
DatacatSecretsBackend
class
TestSecretsBackenbd
(
TestCase
):
def
setUp
(
self
):
self
.
backend
=
DatacatSecretsBackend
()
self
.
backend
.
url
=
"
https://zam10036.zam.kfa-juelich.de
"
self
.
backend
.
user
=
"
dls-testing
"
self
.
backend
.
password
=
"
dls-testing-pass
"
def
test_get_connection_from_oid
(
self
):
conn
=
self
.
backend
.
get_connection
(
"
860355e9-975f-4253-9421-1815e20c879b
"
)
self
.
assertEqual
(
conn
.
conn_id
,
"
airflow_connections/860355e9-975f-4253-9421-1815e20c879b-connection
"
)
self
.
assertEqual
(
conn
.
conn_type
,
"
http
"
)
self
.
assertEqual
(
conn
.
port
,
"
443
"
)
self
.
assertEqual
(
conn
.
extra_dejson
[
'
some_extra
'
],
"
secret_12345
"
)
self
.
assertEqual
(
conn
.
extra_dejson
[
'
some_public_extra
'
],
"
12345
"
)
self
.
assertEqual
(
conn
.
extra_dejson
[
'
some_other_extra_to_be_overwritten_by_secret
'
],
"
secret_67890
"
)
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