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
8b3fc233
Commit
8b3fc233
authored
3 years ago
by
Christian Boettcher
Browse files
Options
Downloads
Patches
Plain Diff
basic testing completed
parent
9fe12872
No related branches found
No related tags found
No related merge requests found
Pipeline
#87473
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
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
tests/test_secrets.py
+39
-2
39 additions, 2 deletions
tests/test_secrets.py
with
40 additions
and
2 deletions
.gitignore
+
1
−
0
View file @
8b3fc233
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
dist/
dist/
__pycache__/
__pycache__/
*.egg-info/
*.egg-info/
coverage_html_report/
# generated files
# generated files
.coverage
.coverage
...
...
This diff is collapsed.
Click to expand it.
tests/test_secrets.py
+
39
−
2
View file @
8b3fc233
from
unittest
import
TestCase
from
unittest
import
TestCase
import
os
import
os
,
json
from
dotenv
import
load_dotenv
from
dotenv
import
load_dotenv
from
datacat_integration.secrets
import
DataCatConnectionWithSecrets
,
get_connection_with_secrets_from_entry
,
DatacatSecretsBackend
from
datacat_integration.secrets
import
DataCatConnectionWithSecrets
,
get_connection_with_secrets_from_entry
,
DatacatSecretsBackend
class
TestSecretsBacken
b
d
(
TestCase
):
class
TestSecretsBackend
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
load_dotenv
(
"
tests/testing-authentication.env
"
,
verbose
=
False
)
# does nothing if file is not present
load_dotenv
(
"
tests/testing-authentication.env
"
,
verbose
=
False
)
# does nothing if file is not present
self
.
backend
=
DatacatSecretsBackend
()
self
.
backend
=
DatacatSecretsBackend
()
...
@@ -25,3 +25,40 @@ class TestSecretsBackenbd(TestCase):
...
@@ -25,3 +25,40 @@ class TestSecretsBackenbd(TestCase):
self
.
assertEqual
(
conn
.
extra_dejson
[
'
some_extra
'
],
"
secret_12345
"
)
self
.
assertEqual
(
conn
.
extra_dejson
[
'
some_extra
'
],
"
secret_12345
"
)
self
.
assertEqual
(
conn
.
extra_dejson
[
'
some_public_extra
'
],
"
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
"
)
self
.
assertEqual
(
conn
.
extra_dejson
[
'
some_other_extra_to_be_overwritten_by_secret
'
],
"
secret_67890
"
)
class
TestSecretsConnection
(
TestCase
):
def
setUp
(
self
):
load_dotenv
(
"
tests/testing-authentication.env
"
,
verbose
=
False
)
# does nothing if file is not present
self
.
url
=
os
.
getenv
(
'
DATACAT_URL
'
,
"
https://zam10036.zam.kfa-juelich.de
"
)
self
.
user
=
os
.
getenv
(
'
DATACAT_LOGIN
'
,
"
dls-testing
"
)
self
.
password
=
os
.
getenv
(
'
DATACAT_PASSWORD
'
)
self
.
assertIsNotNone
(
self
.
url
)
self
.
assertIsNotNone
(
self
.
user
)
self
.
assertIsNotNone
(
self
.
password
)
self
.
connection
=
DataCatConnectionWithSecrets
(
self
.
url
,
self
.
user
,
self
.
password
)
self
.
oid
=
"
860355e9-975f-4253-9421-1815e20c879b
"
self
.
conn_type
=
"
airflow_connections
"
self
.
keys
=
[
"
login
"
,
"
password
"
,
"
some_extra
"
,
"
some_other_extra
"
,
"
some_other_extra_to_be_overwritten_by_secret
"
]
self
.
key_value_map
=
{
"
login
"
:
"
foo
"
,
"
password
"
:
"
bar
"
,
"
some_extra
"
:
"
secret_12345
"
,
"
some_other_extra
"
:
"
secret_67890
"
,
"
some_other_extra_to_be_overwritten_by_secret
"
:
"
secret_67890
"
}
def
test_get_keys
(
self
):
keys
=
json
.
loads
(
self
.
connection
.
get_secrets_keys
(
self
.
conn_type
,
self
.
oid
))
self
.
assertListEqual
(
keys
,
self
.
keys
)
def
test_get_key_value
(
self
):
k_v_map
=
json
.
loads
(
self
.
connection
.
get_all_secret_key_value
(
self
.
conn_type
,
self
.
oid
))
self
.
assertDictEqual
(
k_v_map
,
self
.
key_value_map
)
def
test_get_single_value
(
self
):
for
key
in
self
.
keys
:
self
.
assertEqual
(
self
.
key_value_map
[
key
],
json
.
loads
(
self
.
connection
.
get_secret_value
(
self
.
conn_type
,
self
.
oid
,
key
)))
def
test_connection_errore
(
self
):
self
.
assertRaises
(
ConnectionError
,
self
.
connection
.
get_secrets_keys
,
self
.
conn_type
,
"
invalid_oid
"
)
self
.
assertRaises
(
ConnectionError
,
self
.
connection
.
get_all_secret_key_value
,
self
.
conn_type
,
"
invalid_oid
"
)
self
.
assertRaises
(
ConnectionError
,
self
.
connection
.
get_secret_value
,
self
.
conn_type
,
"
invalid_oid
"
,
"
fake_key
"
)
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