Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
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
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
6d943253
Verified
Commit
6d943253
authored
1 year ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
update oss-params examples and config unit test
parent
b4d08a21
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!161
Feature/add mailer service
Pipeline
#85722
failed
1 year ago
Stage: tox
Stage: documentation
Stage: sonarqube
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
gso/oss-params-example.json
+8
-0
8 additions, 0 deletions
gso/oss-params-example.json
gso/services/mailer.py
+5
-5
5 additions, 5 deletions
gso/services/mailer.py
gso/settings.py
+2
-2
2 additions, 2 deletions
gso/settings.py
test/conftest.py
+8
-0
8 additions, 0 deletions
test/conftest.py
with
23 additions
and
7 deletions
gso/oss-params-example.json
+
8
−
0
View file @
6d943253
...
...
@@ -77,5 +77,13 @@
"THIRD_PARTY_API_KEYS"
:
{
"AnsibleDynamicInventoryGenerator"
:
"REALLY_random_AND_secure_T0keN"
,
"Application_2"
:
"another_REALY_random_AND_3cure_T0keN"
},
"EMAIL"
:
{
"from_address"
:
"noreply@nren.local"
,
"smtp_host"
:
"smtp.nren.local"
,
"smtp_port"
:
487
,
"starttls_enabled"
:
true
,
"smtp_username"
:
"username"
,
"smtp_password"
:
"password"
}
}
This diff is collapsed.
Click to expand it.
gso/services/mailer.py
+
5
−
5
View file @
6d943253
...
...
@@ -7,14 +7,14 @@ from ssl import create_default_context
from
gso.settings
import
load_oss_params
def
send_mail
(
recipient
,
subject
,
body
)
->
None
:
def
send_mail
(
recipient
:
str
,
subject
:
str
,
body
:
str
)
->
None
:
"""
Send an email message to the given address.
Only supports STARTTLS, not SSL.
:param recipient: The destination address.
:param subject: The email subject.
:param body: The contents of the email message.
:param
str
recipient: The destination address.
:param
str
subject: The email subject.
:param
str
body: The contents of the email message.
"""
email_params
=
load_oss_params
().
EMAIL
msg
=
EmailMessage
()
...
...
@@ -27,6 +27,6 @@ def send_mail(recipient, subject, body) -> None:
if
email_params
.
starttls_enabled
:
tls_context
=
create_default_context
()
s
.
starttls
(
context
=
tls_context
)
if
email_params
.
smtp_username
or
email_params
.
smtp_password
:
if
email_params
.
smtp_username
and
email_params
.
smtp_password
:
s
.
login
(
email_params
.
smtp_username
,
email_params
.
smtp_password
)
s
.
send_message
(
msg
)
This diff is collapsed.
Click to expand it.
gso/settings.py
+
2
−
2
View file @
6d943253
...
...
@@ -160,8 +160,8 @@ class EmailParams(BaseSettings):
smtp_host
:
str
smtp_port
:
int
starttls_enabled
:
bool
smtp_username
:
str
|
None
=
""
smtp_password
:
str
|
None
=
""
smtp_username
:
str
|
None
smtp_password
:
str
|
None
class
OSSParams
(
BaseSettings
):
...
...
This diff is collapsed.
Click to expand it.
test/conftest.py
+
8
−
0
View file @
6d943253
...
...
@@ -208,6 +208,14 @@ def configuration_data() -> dict:
"
AnsibleDynamicInventoryGenerator
"
:
"
REALY_random_AND_3cure_T0keN
"
,
"
Application_2
"
:
"
another_REALY_random_AND_3cure_T0keN
"
,
},
"
EMAIL
"
:
{
"
from_address
"
:
"
noreply@nren.local
"
,
"
smtp_host
"
:
"
smtp.nren.local
"
,
"
smtp_port
"
:
487
,
"
starttls_enabled
"
:
True
,
"
smtp_username
"
:
"
username
"
,
"
smtp_password
"
:
"
password
"
,
},
}
...
...
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