mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-15 11:40:30 +03:00
parent
8daf273843
commit
17f6a778ba
12 changed files with 85 additions and 96 deletions
|
|
@ -15,29 +15,29 @@ if localmodule not in sys.path:
|
|||
sys.path.insert(0, localmodule)
|
||||
|
||||
import fdroidserver.common
|
||||
import fdroidserver.server
|
||||
import fdroidserver.deploy
|
||||
from testcommon import TmpCwd
|
||||
|
||||
|
||||
class ServerTest(unittest.TestCase):
|
||||
'''fdroidserver/server.py'''
|
||||
class DeployTest(unittest.TestCase):
|
||||
'''fdroidserver/deploy.py'''
|
||||
|
||||
def setUp(self):
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
self.basedir = os.path.join(localmodule, 'tests')
|
||||
|
||||
fdroidserver.server.options = mock.Mock()
|
||||
fdroidserver.server.config = {}
|
||||
fdroidserver.deploy.options = mock.Mock()
|
||||
fdroidserver.deploy.config = {}
|
||||
|
||||
def test_update_serverwebroot_make_cur_version_link(self):
|
||||
|
||||
# setup parameters for this test run
|
||||
fdroidserver.server.options.no_chcksum = True
|
||||
fdroidserver.server.options.identity_file = None
|
||||
fdroidserver.server.options.verbose = False
|
||||
fdroidserver.server.options.quiet = True
|
||||
fdroidserver.server.options.identity_file = None
|
||||
fdroidserver.server.config['make_current_version_link'] = True
|
||||
fdroidserver.deploy.options.no_chcksum = True
|
||||
fdroidserver.deploy.options.identity_file = None
|
||||
fdroidserver.deploy.options.verbose = False
|
||||
fdroidserver.deploy.options.quiet = True
|
||||
fdroidserver.deploy.options.identity_file = None
|
||||
fdroidserver.deploy.config['make_current_version_link'] = True
|
||||
serverwebroot = "example.com:/var/www/fdroid"
|
||||
repo_section = 'repo'
|
||||
|
||||
|
|
@ -86,19 +86,19 @@ class ServerTest(unittest.TestCase):
|
|||
os.symlink('repo/com.example.sym.apk.asc', 'Sym.apk.asc')
|
||||
os.symlink('repo/com.example.sym.apk.sig', 'Sym.apk.sig')
|
||||
with mock.patch('subprocess.call', side_effect=update_server_webroot_call):
|
||||
fdroidserver.server.update_serverwebroot(serverwebroot,
|
||||
fdroidserver.deploy.update_serverwebroot(serverwebroot,
|
||||
repo_section)
|
||||
self.assertEqual(call_iteration, 3, 'expected 3 invocations of subprocess.call')
|
||||
|
||||
def test_update_serverwebroot_with_id_file(self):
|
||||
|
||||
# setup parameters for this test run
|
||||
fdroidserver.server.options.no_chcksum = False
|
||||
fdroidserver.server.options.verbose = True
|
||||
fdroidserver.server.options.quiet = False
|
||||
fdroidserver.server.options.identity_file = None
|
||||
fdroidserver.server.config['identity_file'] = './id_rsa'
|
||||
fdroidserver.server.config['make_current_version_link'] = False
|
||||
fdroidserver.deploy.options.no_chcksum = False
|
||||
fdroidserver.deploy.options.verbose = True
|
||||
fdroidserver.deploy.options.quiet = False
|
||||
fdroidserver.deploy.options.identity_file = None
|
||||
fdroidserver.deploy.config['identity_file'] = './id_rsa'
|
||||
fdroidserver.deploy.config['make_current_version_link'] = False
|
||||
serverwebroot = "example.com:/var/www/fdroid"
|
||||
repo_section = 'archive'
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ class ServerTest(unittest.TestCase):
|
|||
'--verbose',
|
||||
'-e',
|
||||
'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i '
|
||||
+ fdroidserver.server.config['identity_file'],
|
||||
+ fdroidserver.deploy.config['identity_file'],
|
||||
'--exclude', 'archive/index.xml',
|
||||
'--exclude', 'archive/index.jar',
|
||||
'--exclude', 'archive/index-v1.jar',
|
||||
|
|
@ -129,7 +129,7 @@ class ServerTest(unittest.TestCase):
|
|||
'--verbose',
|
||||
'-e',
|
||||
'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i '
|
||||
+ fdroidserver.server.config['identity_file'],
|
||||
+ fdroidserver.deploy.config['identity_file'],
|
||||
'archive',
|
||||
serverwebroot])
|
||||
else:
|
||||
|
|
@ -138,15 +138,15 @@ class ServerTest(unittest.TestCase):
|
|||
return 0
|
||||
|
||||
with mock.patch('subprocess.call', side_effect=update_server_webroot_call):
|
||||
fdroidserver.server.update_serverwebroot(serverwebroot,
|
||||
fdroidserver.deploy.update_serverwebroot(serverwebroot,
|
||||
repo_section)
|
||||
self.assertEqual(call_iteration, 2, 'expected 2 invocations of subprocess.call')
|
||||
|
||||
@unittest.skipIf(not os.getenv('VIRUSTOTAL_API_KEY'), 'VIRUSTOTAL_API_KEY is not set')
|
||||
def test_upload_to_virustotal(self):
|
||||
fdroidserver.server.options.verbose = True
|
||||
fdroidserver.deploy.options.verbose = True
|
||||
virustotal_apikey = os.getenv('VIRUSTOTAL_API_KEY')
|
||||
fdroidserver.server.upload_to_virustotal('repo', virustotal_apikey)
|
||||
fdroidserver.deploy.upload_to_virustotal('repo', virustotal_apikey)
|
||||
|
||||
def test_remote_hostname_regex(self):
|
||||
for remote_url, name in (
|
||||
|
|
@ -158,7 +158,7 @@ class ServerTest(unittest.TestCase):
|
|||
):
|
||||
self.assertEqual(
|
||||
name,
|
||||
fdroidserver.server.REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url)
|
||||
fdroidserver.deploy.REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -171,5 +171,5 @@ if __name__ == "__main__":
|
|||
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
|
||||
|
||||
newSuite = unittest.TestSuite()
|
||||
newSuite.addTest(unittest.makeSuite(ServerTest))
|
||||
newSuite.addTest(unittest.makeSuite(DeployTest))
|
||||
unittest.main(failfast=False)
|
||||
|
|
@ -42,7 +42,6 @@ class MainTest(unittest.TestCase):
|
|||
'lint',
|
||||
'scanner',
|
||||
'stats',
|
||||
'server',
|
||||
'signindex',
|
||||
'btlog',
|
||||
'signatures',
|
||||
|
|
@ -63,7 +62,7 @@ class MainTest(unittest.TestCase):
|
|||
def test_call_deploy(self):
|
||||
co = mock.Mock()
|
||||
with mock.patch('sys.argv', ['', 'deploy', '-h']):
|
||||
with mock.patch('fdroidserver.server.main', co):
|
||||
with mock.patch('fdroidserver.deploy.main', co):
|
||||
with mock.patch('sys.exit') as exit_mock:
|
||||
fdroidserver.__main__.main()
|
||||
# note: this is sloppy, if `deploy` changes
|
||||
|
|
|
|||
|
|
@ -691,7 +691,7 @@ $fdroid lint
|
|||
$fdroid readmeta
|
||||
$fdroid rewritemeta fake
|
||||
$fdroid deploy
|
||||
$fdroid server update
|
||||
$fdroid deploy
|
||||
$fdroid scanner
|
||||
|
||||
# run these to get their output, but the are not setup, so don't fail
|
||||
|
|
@ -725,26 +725,26 @@ cd $REPOROOT
|
|||
$fdroid init
|
||||
$fdroid update --create-metadata --verbose
|
||||
$fdroid readmeta
|
||||
$fdroid server update --local-copy-dir=/tmp/fdroid
|
||||
$fdroid deploy --local-copy-dir=/tmp/fdroid
|
||||
$fdroid deploy --local-copy-dir=/tmp/fdroid --verbose
|
||||
|
||||
# now test the errors work
|
||||
set +e
|
||||
$fdroid server update --local-copy-dir=thisisnotanabsolutepath
|
||||
$fdroid deploy --local-copy-dir=thisisnotanabsolutepath
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "This should have failed because thisisnotanabsolutepath is not an absolute path!"
|
||||
exit 1
|
||||
else
|
||||
echo "testing absolute path checker passed"
|
||||
fi
|
||||
$fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf
|
||||
$fdroid deploy --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "This should have failed because the path does not end with 'fdroid'!"
|
||||
exit 1
|
||||
else
|
||||
echo "testing dirname exists checker passed"
|
||||
fi
|
||||
$fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf/fdroid
|
||||
$fdroid deploy --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf/fdroid
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "This should have failed because the dirname path does not exist!"
|
||||
exit 1
|
||||
|
|
@ -766,12 +766,12 @@ $fdroid readmeta
|
|||
grep -F '<application id=' repo/index.xml > /dev/null
|
||||
|
||||
LOCALCOPYDIR=`create_test_dir`/fdroid
|
||||
$fdroid server update --local-copy-dir=$LOCALCOPYDIR
|
||||
$fdroid deploy --local-copy-dir=$LOCALCOPYDIR
|
||||
NEWREPOROOT=`create_test_dir`
|
||||
cd $NEWREPOROOT
|
||||
fdroid_init_with_prebuilt_keystore
|
||||
echo "sync_from_local_copy_dir = True" >> config.py
|
||||
$fdroid server update --local-copy-dir=$LOCALCOPYDIR
|
||||
$fdroid deploy --local-copy-dir=$LOCALCOPYDIR
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
|
|
@ -1045,7 +1045,7 @@ cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $RE
|
|||
echo "binary_transparency_remote = '$GIT_REMOTE'" >> config.py
|
||||
$fdroid update --verbose
|
||||
if have_git_2_3; then
|
||||
$fdroid server update --verbose
|
||||
$fdroid deploy --verbose
|
||||
test -e repo/index.xml
|
||||
test -e repo/index.jar
|
||||
test -e repo/index-v1.jar
|
||||
|
|
@ -1204,7 +1204,7 @@ if have_git_2_3; then
|
|||
cd binary_transparency
|
||||
[ `git rev-list --count HEAD` == "1" ]
|
||||
cd ..
|
||||
$fdroid server update --verbose
|
||||
$fdroid deploy --verbose
|
||||
grep -F '<application id=' $LOCAL_COPY_DIR/repo/index.xml > /dev/null
|
||||
cd $ONLINE_ROOT
|
||||
echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
|
||||
|
|
@ -1213,7 +1213,7 @@ if have_git_2_3; then
|
|||
echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
|
||||
echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
|
||||
echo "binary_transparency_remote = '$BINARY_TRANSPARENCY_REMOTE'" >> config.py
|
||||
$fdroid server update --verbose
|
||||
$fdroid deploy --verbose
|
||||
cd $BINARY_TRANSPARENCY_REMOTE
|
||||
[ `git rev-list --count HEAD` == "1" ]
|
||||
cd $SERVER_GIT_MIRROR
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue