Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
slapos
Commits
ee19a181
Commit
ee19a181
authored
Oct 21, 2020
by
Thomas Gambier
🚴🏼
Browse files
Options
Browse Files
Download
Plain Diff
software/proftpd: Updates software release tests to be python3 compliant
See merge request
nexedi/slapos!838
parents
c88d50cc
227bc33a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
16 deletions
+18
-16
software/proftpd/software.cfg
software/proftpd/software.cfg
+2
-0
software/proftpd/test/test.py
software/proftpd/test/test.py
+15
-15
software/slapos-sr-testing/software-py3.cfg
software/slapos-sr-testing/software-py3.cfg
+1
-0
software/slapos-sr-testing/software.cfg
software/slapos-sr-testing/software.cfg
+0
-1
No files found.
software/proftpd/software.cfg
View file @
ee19a181
...
@@ -12,6 +12,8 @@ parts =
...
@@ -12,6 +12,8 @@ parts =
proftpd-config-file
proftpd-config-file
instance-profile
instance-profile
[python]
part = python3
[download-file-base]
[download-file-base]
recipe = slapos.recipe.build:download
recipe = slapos.recipe.build:download
...
...
software/proftpd/test/test.py
View file @
ee19a181
...
@@ -27,9 +27,9 @@
...
@@ -27,9 +27,9 @@
import
os
import
os
import
shutil
import
shutil
import
urlparse
from
urllib.parse
import
urlparse
import
tempfile
import
tempfile
import
StringIO
import
io
import
subprocess
import
subprocess
import
pysftp
import
pysftp
...
@@ -58,7 +58,7 @@ class ProFTPdTestCase(SlapOSInstanceTestCase):
...
@@ -58,7 +58,7 @@ class ProFTPdTestCase(SlapOSInstanceTestCase):
cnopts
.
hostkeys
=
None
cnopts
.
hostkeys
=
None
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
sftp_url
=
urlparse
.
urlparse
(
parameter_dict
[
'url'
])
sftp_url
=
urlparse
(
parameter_dict
[
'url'
])
return
pysftp
.
Connection
(
return
pysftp
.
Connection
(
hostname
or
sftp_url
.
hostname
,
hostname
or
sftp_url
.
hostname
,
...
@@ -95,7 +95,7 @@ class TestSFTPOperations(ProFTPdTestCase):
...
@@ -95,7 +95,7 @@ class TestSFTPOperations(ProFTPdTestCase):
def
test_simple_sftp_session
(
self
):
def
test_simple_sftp_session
(
self
):
with
self
.
_getConnection
()
as
sftp
:
with
self
.
_getConnection
()
as
sftp
:
# put a file
# put a file
with
tempfile
.
NamedTemporaryFile
()
as
f
:
with
tempfile
.
NamedTemporaryFile
(
mode
=
'w'
)
as
f
:
f
.
write
(
"Hello FTP !"
)
f
.
write
(
"Hello FTP !"
)
f
.
flush
()
f
.
flush
()
sftp
.
put
(
f
.
name
,
remotepath
=
'testfile'
)
sftp
.
put
(
f
.
name
,
remotepath
=
'testfile'
)
...
@@ -117,14 +117,14 @@ class TestSFTPOperations(ProFTPdTestCase):
...
@@ -117,14 +117,14 @@ class TestSFTPOperations(ProFTPdTestCase):
def
test_uploaded_file_not_visible_until_fully_uploaded
(
self
):
def
test_uploaded_file_not_visible_until_fully_uploaded
(
self
):
test_self
=
self
test_self
=
self
class
PartialFile
(
StringIO
.
StringIO
):
class
PartialFile
(
io
.
StringIO
):
def
read
(
self
,
*
args
):
def
read
(
self
,
*
args
):
# file is not visible yet
# file is not visible yet
test_self
.
assertNotIn
(
'destination'
,
os
.
listdir
(
test_self
.
upload_dir
))
test_self
.
assertNotIn
(
'destination'
,
os
.
listdir
(
test_self
.
upload_dir
))
# it's just a hidden file
# it's just a hidden file
test_self
.
assertEqual
(
test_self
.
assertEqual
(
[
'.in.destination.'
],
os
.
listdir
(
test_self
.
upload_dir
))
[
'.in.destination.'
],
os
.
listdir
(
test_self
.
upload_dir
))
return
StringIO
.
StringIO
.
read
(
self
,
*
args
)
return
super
().
read
(
*
args
)
with
self
.
_getConnection
()
as
sftp
:
with
self
.
_getConnection
()
as
sftp
:
sftp
.
sftp_client
.
putfo
(
PartialFile
(
"content"
),
"destination"
)
sftp
.
sftp_client
.
putfo
(
PartialFile
(
"content"
),
"destination"
)
...
@@ -136,7 +136,7 @@ class TestSFTPOperations(ProFTPdTestCase):
...
@@ -136,7 +136,7 @@ class TestSFTPOperations(ProFTPdTestCase):
test_self
=
self
test_self
=
self
with
self
.
_getConnection
()
as
sftp
:
with
self
.
_getConnection
()
as
sftp
:
class
ErrorFile
(
StringIO
.
StringIO
):
class
ErrorFile
(
io
.
StringIO
):
def
read
(
self
,
*
args
):
def
read
(
self
,
*
args
):
# at this point, file is already created on server
# at this point, file is already created on server
test_self
.
assertEqual
(
test_self
.
assertEqual
(
...
@@ -152,17 +152,17 @@ class TestSFTPOperations(ProFTPdTestCase):
...
@@ -152,17 +152,17 @@ class TestSFTPOperations(ProFTPdTestCase):
def
test_user_cannot_escape_home
(
self
):
def
test_user_cannot_escape_home
(
self
):
with
self
.
_getConnection
()
as
sftp
:
with
self
.
_getConnection
()
as
sftp
:
with
self
.
assertRaises
Regexp
(
IOError
,
'Permission denied'
):
with
self
.
assertRaises
(
PermissionError
):
sftp
.
listdir
(
'..'
)
sftp
.
listdir
(
'..'
)
with
self
.
assertRaises
Regexp
(
IOError
,
'Permission denied'
):
with
self
.
assertRaises
(
PermissionError
):
sftp
.
listdir
(
'/'
)
sftp
.
listdir
(
'/'
)
with
self
.
assertRaises
Regexp
(
IOError
,
'Permission denied'
):
with
self
.
assertRaises
(
PermissionError
):
sftp
.
listdir
(
'/tmp/'
)
sftp
.
listdir
(
'/tmp/'
)
class
TestUserManagement
(
ProFTPdTestCase
):
class
TestUserManagement
(
ProFTPdTestCase
):
def
test_user_can_be_added_from_script
(
self
):
def
test_user_can_be_added_from_script
(
self
):
with
self
.
assertRaisesRegex
p
(
AuthenticationException
,
with
self
.
assertRaisesRegex
(
AuthenticationException
,
'Authentication failed'
):
'Authentication failed'
):
self
.
_getConnection
(
username
=
'bob'
,
password
=
'secret'
)
self
.
_getConnection
(
username
=
'bob'
,
password
=
'secret'
)
...
@@ -177,12 +177,12 @@ class TestBan(ProFTPdTestCase):
...
@@ -177,12 +177,12 @@ class TestBan(ProFTPdTestCase):
def
test_client_are_banned_after_5_wrong_passwords
(
self
):
def
test_client_are_banned_after_5_wrong_passwords
(
self
):
# Simulate failed 5 login attempts
# Simulate failed 5 login attempts
for
i
in
range
(
5
):
for
i
in
range
(
5
):
with
self
.
assertRaisesRegex
p
(
AuthenticationException
,
with
self
.
assertRaisesRegex
(
AuthenticationException
,
'Authentication failed'
):
'Authentication failed'
):
self
.
_getConnection
(
password
=
'wrong'
)
self
.
_getConnection
(
password
=
'wrong'
)
# after that, even with a valid password we cannot connect
# after that, even with a valid password we cannot connect
with
self
.
assertRaisesRegex
p
(
SSHException
,
'Connection reset by peer'
):
with
self
.
assertRaisesRegex
(
SSHException
,
'Connection reset by peer'
):
self
.
_getConnection
()
self
.
_getConnection
()
# ban event is logged
# ban event is logged
...
@@ -190,7 +190,7 @@ class TestBan(ProFTPdTestCase):
...
@@ -190,7 +190,7 @@ class TestBan(ProFTPdTestCase):
'var'
,
'var'
,
'log'
,
'log'
,
'proftpd-ban.log'
))
as
ban_log_file
:
'proftpd-ban.log'
))
as
ban_log_file
:
self
.
assertRegex
pMatches
(
self
.
assertRegex
(
ban_log_file
.
readlines
()[
-
1
],
ban_log_file
.
readlines
()[
-
1
],
'login from host .* denied due to host ban'
)
'login from host .* denied due to host ban'
)
...
@@ -203,7 +203,7 @@ class TestInstanceParameterPort(ProFTPdTestCase):
...
@@ -203,7 +203,7 @@ class TestInstanceParameterPort(ProFTPdTestCase):
def
test_instance_parameter_port
(
self
):
def
test_instance_parameter_port
(
self
):
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
parameter_dict
=
self
.
computer_partition
.
getConnectionParameterDict
()
sftp_url
=
urlparse
.
urlparse
(
parameter_dict
[
'url'
])
sftp_url
=
urlparse
(
parameter_dict
[
'url'
])
self
.
assertEqual
(
self
.
free_port
,
sftp_url
.
port
)
self
.
assertEqual
(
self
.
free_port
,
sftp_url
.
port
)
self
.
assertTrue
(
self
.
_getConnection
())
self
.
assertTrue
(
self
.
_getConnection
())
...
...
software/slapos-sr-testing/software-py3.cfg
View file @
ee19a181
...
@@ -14,3 +14,4 @@ eggs -=
...
@@ -14,3 +14,4 @@ eggs -=
extra =
extra =
${slapos.test.monitor-setup:setup}
${slapos.test.monitor-setup:setup}
${slapos.test.powerdns-setup:setup}
${slapos.test.powerdns-setup:setup}
${slapos.test.proftpd-setup:setup}
software/slapos-sr-testing/software.cfg
View file @
ee19a181
...
@@ -257,7 +257,6 @@ extra =
...
@@ -257,7 +257,6 @@ extra =
${slapos.test.htmlvalidatorserver-setup:setup}
${slapos.test.htmlvalidatorserver-setup:setup}
${slapos.test.slapos-master-setup:setup}
${slapos.test.slapos-master-setup:setup}
${slapos.test.plantuml-setup:setup}
${slapos.test.plantuml-setup:setup}
${slapos.test.proftpd-setup:setup}
${slapos.test.re6stnet-setup:setup}
${slapos.test.re6stnet-setup:setup}
${slapos.test.seleniumserver-setup:setup}
${slapos.test.seleniumserver-setup:setup}
${slapos.test.helloworld-setup:setup}
${slapos.test.helloworld-setup:setup}
...
...
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