Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor 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
mediaserver
envsetup
Commits
5d4081ec
Verified
Commit
5d4081ec
authored
5 years ago
by
Nicolas KAROLAK
Browse files
Options
Downloads
Patches
Plain Diff
handle EMAIL_SMTP_SERVER host:port notation
parent
b7c72294
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_email.py
+11
-12
11 additions, 12 deletions
tests/test_email.py
with
11 additions
and
12 deletions
tests/test_email.py
+
11
−
12
View file @
5d4081ec
...
...
@@ -43,11 +43,13 @@ def check_listen() -> tuple:
return
warnings
,
errors
def
check_relay
(
relay
:
str
,
domain
:
str
)
->
tuple
:
def
check_relay
(
relay
_host
:
str
,
relay_port
:
str
,
domain
:
str
)
->
tuple
:
"""
Check that Postfix is not an open relay.
:param relay: Hostname or IP address of relay host
:type relay: str
:param relay_host: Hostname or IP address of relay host
:type relay_host: str
:param relay_port: Port of relay host
:type relay_port: str
:param domain: Domain name under which mails will be send
:type domain: str
:return: Exit return codes
...
...
@@ -83,6 +85,7 @@ def check_relay(relay: str, domain: str) -> tuple:
u
.
warning
(
'"
myorigin
"
setting does not contain a valid domain
'
)
warnings
+=
1
relay
=
"
{}:{}
"
.
format
(
relay_host
,
relay_port
)
if
relay_port
else
relay_host
if
relay
!=
configured_relay
:
u
.
error
(
"
STMP relay must be {}
"
.
format
(
relay
))
errors
+=
1
...
...
@@ -110,8 +113,7 @@ def check_send(sender: str) -> tuple:
if
sender
:
sender
=
"
-a
'
From: {}
'
"
.
format
(
sender
)
else
:
u
.
warning
(
"
Sender address is not set
"
)
warnings
+=
1
u
.
info
(
"
Sender address is not set
"
)
cmd
=
"
echo
'
test email
'
| mail -s
'
Email used to test configuration.
'
{}{}
"
.
format
(
sender
,
email
)
...
...
@@ -210,12 +212,9 @@ def main():
# get settings
conf
=
u
.
load_conf
()
relay_host
=
(
conf
.
get
(
"
EMAIL_SMTP_SERVER
"
,
""
)
.
replace
(
"
[
"
,
""
)
.
replace
(
"
]
"
,
""
)
.
split
(
"
:
"
)[
0
]
)
relay
=
conf
.
get
(
"
EMAIL_SMTP_SERVER
"
,
""
).
replace
(
"
[
"
,
""
).
replace
(
"
]
"
,
""
)
relay_host
=
relay
.
split
(
"
:
"
)[
0
]
if
"
:
"
in
relay
else
relay
relay_port
=
relay
.
split
(
"
:
"
)[
-
1
]
if
"
:
"
in
relay
else
""
ip_addr
=
(
(
socket
.
gethostbyname
(
relay_host
)
if
relay_host
else
None
)
or
conf
.
get
(
"
NETWORK_IP_NAT
"
)
...
...
@@ -235,7 +234,7 @@ def main():
errors
+=
check_err
if
check_err
else
errors
# check that relayhost is correct
check_warn
,
check_err
=
check_relay
(
relay_host
,
domain
)
check_warn
,
check_err
=
check_relay
(
relay_host
,
relay_port
,
domain
)
warnings
+=
check_warn
if
check_warn
else
warnings
errors
+=
check_err
if
check_err
else
errors
...
...
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