Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Neil Hanlon
Efs Utils
Commits
880da73a
Commit
880da73a
authored
Dec 04, 2019
by
Yuan Gao
Browse files
Support Python 3 for tests
parent
b6b0d993
Changes
6
Hide whitespace changes
Inline
Side-by-side
test/mount_efs_test/test_bootstrap_tls.py
View file @
880da73a
...
...
@@ -30,7 +30,7 @@ def setup_mocks(mocker):
mocker
.
patch
(
'mount_efs.start_watchdog'
)
mocker
.
patch
(
'mount_efs.get_tls_port_range'
,
return_value
=
(
DEFAULT_TLS_PORT
,
DEFAULT_TLS_PORT
+
10
))
mocker
.
patch
(
'socket.socket'
,
return_value
=
MagicMock
())
mocker
.
patch
(
'mount_efs.write_tls_tunnel_state_file'
)
mocker
.
patch
(
'mount_efs.write_tls_tunnel_state_file'
,
return_value
=
"~mocktempfile"
)
mocker
.
patch
(
'os.rename'
)
mocker
.
patch
(
'os.kill'
)
...
...
test/mount_efs_test/test_choose_tls_port.py
View file @
880da73a
...
...
@@ -7,19 +7,26 @@
#
import
mount_efs
import
ConfigParser
import
socket
import
pytest
from
mock
import
MagicMock
try
:
import
ConfigParser
except
ImportError
:
from
configparser
import
ConfigParser
DEFAULT_TLS_PORT_RANGE_LOW
=
20049
DEFAULT_TLS_PORT_RANGE_HIGH
=
20449
def
_get_config
():
config
=
ConfigParser
.
SafeConfigParser
()
try
:
config
=
ConfigParser
.
SafeConfigParser
()
except
AttributeError
:
config
=
ConfigParser
()
config
.
add_section
(
mount_efs
.
CONFIG_SECTION
)
config
.
set
(
mount_efs
.
CONFIG_SECTION
,
'port_range_lower_bound'
,
str
(
DEFAULT_TLS_PORT_RANGE_LOW
))
config
.
set
(
mount_efs
.
CONFIG_SECTION
,
'port_range_upper_bound'
,
str
(
DEFAULT_TLS_PORT_RANGE_HIGH
))
...
...
test/mount_efs_test/test_get_dns_name.py
View file @
880da73a
...
...
@@ -63,7 +63,7 @@ def test_get_dns_name_bad_format_wrong_specifiers(mocker):
with
pytest
.
raises
(
ValueError
)
as
ex
:
mount_efs
.
get_dns_name
(
config
,
FS_ID
)
assert
'must include'
in
ex
.
value
.
message
assert
'must include'
in
str
(
ex
)
def
test_get_dns_name_bad_format_too_many_specifiers_1
(
mocker
):
...
...
@@ -72,7 +72,7 @@ def test_get_dns_name_bad_format_too_many_specifiers_1(mocker):
with
pytest
.
raises
(
ValueError
)
as
ex
:
mount_efs
.
get_dns_name
(
config
,
FS_ID
)
assert
'incorrect number'
in
ex
.
value
.
message
assert
'incorrect number'
in
str
(
ex
)
def
test_get_dns_name_bad_format_too_many_specifiers_2
(
mocker
):
...
...
@@ -81,7 +81,7 @@ def test_get_dns_name_bad_format_too_many_specifiers_2(mocker):
with
pytest
.
raises
(
ValueError
)
as
ex
:
mount_efs
.
get_dns_name
(
config
,
FS_ID
)
assert
'incorrect number'
in
ex
.
value
.
message
assert
'incorrect number'
in
str
(
ex
)
def
test_get_dns_name_unresolvable
(
mocker
,
capsys
):
...
...
test/mount_efs_test/test_get_region.py
View file @
880da73a
...
...
@@ -11,7 +11,10 @@ import json
import
pytest
from
urllib2
import
URLError
try
:
from
urllib2
import
URLError
except
ImportError
:
from
urllib.error
import
URLError
INSTANCE_DATA
=
{
'devpayProductCodes'
:
None
,
...
...
test/mount_efs_test/test_is_ocsp_enabled.py
View file @
880da73a
...
...
@@ -7,13 +7,19 @@
#
import
mount_efs
import
ConfigParser
import
pytest
try
:
import
ConfigParser
except
ImportError
:
from
configparser
import
ConfigParser
def
_get_config
(
stunnel_check_cert_validity
):
config
=
ConfigParser
.
SafeConfigParser
()
try
:
config
=
ConfigParser
.
SafeConfigParser
()
except
AttributeError
:
config
=
ConfigParser
()
config
.
add_section
(
mount_efs
.
CONFIG_SECTION
)
if
stunnel_check_cert_validity
is
not
None
:
config
.
set
(
mount_efs
.
CONFIG_SECTION
,
'stunnel_check_cert_validity'
,
str
(
stunnel_check_cert_validity
))
...
...
test/mount_efs_test/test_write_stunnel_config_file.py
View file @
880da73a
...
...
@@ -7,11 +7,15 @@
#
import
mount_efs
import
ConfigParser
import
os
import
pytest
try
:
import
ConfigParser
except
ImportError
:
from
configparser
import
ConfigParser
FS_ID
=
'fs-deadbeef'
DNS_NAME
=
'fs-deadbeef.com'
MOUNT_POINT
=
'/mnt'
...
...
@@ -33,7 +37,10 @@ def _get_config(mocker, stunnel_debug_enabled=False, stunnel_check_cert_hostname
if
stunnel_check_cert_validity
is
None
:
stunnel_check_cert_validity
=
stunnel_check_cert_validity_supported
config
=
ConfigParser
.
SafeConfigParser
()
try
:
config
=
ConfigParser
.
SafeConfigParser
()
except
AttributeError
:
config
=
ConfigParser
()
config
.
add_section
(
mount_efs
.
CONFIG_SECTION
)
config
.
set
(
mount_efs
.
CONFIG_SECTION
,
'stunnel_debug_enabled'
,
str
(
stunnel_debug_enabled
))
config
.
set
(
mount_efs
.
CONFIG_SECTION
,
'stunnel_check_cert_hostname'
,
str
(
stunnel_check_cert_hostname
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment