mirror of
				https://github.com/f-droid/fdroidserver.git
				synced 2025-11-04 06:30:27 +03:00 
			
		
		
		
	Remove libcloud and s3cmd from fdroidserver
This commit is contained in:
		
							parent
							
								
									a9856cfb92
								
							
						
					
					
						commit
						dbd769db9f
					
				
					 9 changed files with 417 additions and 819 deletions
				
			
		| 
						 | 
				
			
			@ -1,9 +1,11 @@
 | 
			
		|||
import configparser
 | 
			
		||||
import itertools
 | 
			
		||||
import os
 | 
			
		||||
import platform
 | 
			
		||||
import re
 | 
			
		||||
import shlex
 | 
			
		||||
import shutil
 | 
			
		||||
import stat
 | 
			
		||||
import subprocess
 | 
			
		||||
import sys
 | 
			
		||||
import threading
 | 
			
		||||
| 
						 | 
				
			
			@ -19,7 +21,7 @@ except ModuleNotFoundError:
 | 
			
		|||
 | 
			
		||||
from fdroidserver._yaml import yaml, yaml_dumper
 | 
			
		||||
 | 
			
		||||
from .shared_test_code import mkdir_testfiles
 | 
			
		||||
from .shared_test_code import mkdir_testfiles, VerboseFalseOptions
 | 
			
		||||
 | 
			
		||||
# TODO: port generic tests that use index.xml to index-v2 (test that
 | 
			
		||||
#       explicitly test index-v0 should still use index.xml)
 | 
			
		||||
| 
						 | 
				
			
			@ -34,12 +36,17 @@ except KeyError:
 | 
			
		|||
    WORKSPACE = basedir.parent
 | 
			
		||||
 | 
			
		||||
from fdroidserver import common
 | 
			
		||||
from fdroidserver import deploy
 | 
			
		||||
 | 
			
		||||
conf = {"sdk_path": os.getenv("ANDROID_HOME", "")}
 | 
			
		||||
common.find_apksigner(conf)
 | 
			
		||||
USE_APKSIGNER = "apksigner" in conf
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def docker_socket_exists(path="/var/run/docker.sock"):
 | 
			
		||||
    return os.path.exists(path) and stat.S_ISSOCK(os.stat(path).st_mode)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian')
 | 
			
		||||
class IntegrationTest(unittest.TestCase):
 | 
			
		||||
    @classmethod
 | 
			
		||||
| 
						 | 
				
			
			@ -64,6 +71,7 @@ class IntegrationTest(unittest.TestCase):
 | 
			
		|||
        self.testdir = mkdir_testfiles(WORKSPACE, self)
 | 
			
		||||
        self.tmp_repo_root = self.testdir / "fdroid"
 | 
			
		||||
        self.tmp_repo_root.mkdir(parents=True)
 | 
			
		||||
        deploy.config = {}
 | 
			
		||||
        os.chdir(self.tmp_repo_root)
 | 
			
		||||
 | 
			
		||||
    def tearDown(self):
 | 
			
		||||
| 
						 | 
				
			
			@ -1556,3 +1564,114 @@ class IntegrationTest(unittest.TestCase):
 | 
			
		|||
            self.fdroid_cmd + ["checkupdates", "--allow-dirty", "--auto", "-v"]
 | 
			
		||||
        )
 | 
			
		||||
        self.assertIn("CurrentVersionCode: 1", Path("metadata/fake.yml").read_text())
 | 
			
		||||
 | 
			
		||||
    @unittest.skipUnless(docker_socket_exists(), "Docker is not available")
 | 
			
		||||
    def test_update_remote_storage_with_rclone_and_minio(self):
 | 
			
		||||
        try:
 | 
			
		||||
            from testcontainers.minio import MinioContainer
 | 
			
		||||
        except ImportError:
 | 
			
		||||
            self.skipTest('Requires testcontainers.minio to run')
 | 
			
		||||
        with MinioContainer(image="quay.io/minio/minio:latest") as minio:
 | 
			
		||||
            # Set up minio bukcet
 | 
			
		||||
            client = minio.get_client()
 | 
			
		||||
            client.make_bucket('test-bucket')
 | 
			
		||||
            host_ip = minio.get_config()['endpoint']
 | 
			
		||||
 | 
			
		||||
            # Set up Repo dir
 | 
			
		||||
            os.chdir(self.testdir)
 | 
			
		||||
            repo_section = 'repo'
 | 
			
		||||
            repo = Path(repo_section)
 | 
			
		||||
            repo.mkdir(parents=True, exist_ok=True)
 | 
			
		||||
            shutil.copy(basedir / 'SpeedoMeterApp.main_1.apk', repo)
 | 
			
		||||
            shutil.copy(basedir / 'repo/index-v2.json', repo)
 | 
			
		||||
 | 
			
		||||
            # write out config for test use
 | 
			
		||||
            rclone_config = configparser.ConfigParser()
 | 
			
		||||
            rclone_config.add_section("test-minio-config")
 | 
			
		||||
            rclone_config.set("test-minio-config", "type", "s3")
 | 
			
		||||
            rclone_config.set("test-minio-config", "provider", "Minio")
 | 
			
		||||
            rclone_config.set("test-minio-config", "endpoint", "http://" + host_ip)
 | 
			
		||||
            rclone_config.set("test-minio-config", "acl", "public-read")
 | 
			
		||||
            rclone_config.set("test-minio-config", "env_auth", "true")
 | 
			
		||||
            rclone_config.set("test-minio-config", "region", "us-east-1")
 | 
			
		||||
            rclone_config.set("test-minio-config", "access_key_id", "minioadmin")
 | 
			
		||||
            rclone_config.set("test-minio-config", "secret_access_key", "minioadmin")
 | 
			
		||||
 | 
			
		||||
            rclone_config_path = Path('rclone_config_path')
 | 
			
		||||
            rclone_config_path.mkdir(parents=True, exist_ok=True)
 | 
			
		||||
            rclone_file = rclone_config_path / 'rclone-minio.conf'
 | 
			
		||||
            with open(rclone_file, "w", encoding="utf-8") as configfile:
 | 
			
		||||
                rclone_config.write(configfile)
 | 
			
		||||
 | 
			
		||||
            # set up config for run
 | 
			
		||||
            awsbucket = "test-bucket"
 | 
			
		||||
            deploy.config['awsbucket'] = awsbucket
 | 
			
		||||
            deploy.config['rclone_config'] = "test-minio-config"
 | 
			
		||||
            deploy.config['path_to_custom_rclone_config'] = str(rclone_file)
 | 
			
		||||
            common.options = VerboseFalseOptions
 | 
			
		||||
 | 
			
		||||
            # call function
 | 
			
		||||
            deploy.update_remote_storage_with_rclone(repo_section, awsbucket)
 | 
			
		||||
 | 
			
		||||
            # check if apk and index file are available
 | 
			
		||||
            bucket_content = client.list_objects('test-bucket', recursive=True)
 | 
			
		||||
            files_in_bucket = {obj.object_name for obj in bucket_content}
 | 
			
		||||
        self.assertEqual(
 | 
			
		||||
            files_in_bucket,
 | 
			
		||||
            {'fdroid/repo/SpeedoMeterApp.main_1.apk', 'fdroid/repo/index-v2.json'},
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    @unittest.skipUnless(docker_socket_exists(), "Docker is not available")
 | 
			
		||||
    def test_update_remote_storage_with_rclone_and_minio_in_index_only_mode(self):
 | 
			
		||||
        try:
 | 
			
		||||
            from testcontainers.minio import MinioContainer
 | 
			
		||||
        except ImportError:
 | 
			
		||||
            self.skipTest('Requires testcontainers.minio to run')
 | 
			
		||||
        with MinioContainer(image="quay.io/minio/minio:latest") as minio:
 | 
			
		||||
            # Set up minio bukcet
 | 
			
		||||
            client = minio.get_client()
 | 
			
		||||
            client.make_bucket('test-bucket')
 | 
			
		||||
            host_ip = minio.get_config()['endpoint']
 | 
			
		||||
 | 
			
		||||
            # Set up Repo dir
 | 
			
		||||
            os.chdir(self.testdir)
 | 
			
		||||
            repo_section = 'repo'
 | 
			
		||||
            repo = Path(repo_section)
 | 
			
		||||
            repo.mkdir(parents=True, exist_ok=True)
 | 
			
		||||
            shutil.copy(basedir / 'SpeedoMeterApp.main_1.apk', repo)
 | 
			
		||||
            shutil.copy(basedir / 'repo/index-v2.json', repo)
 | 
			
		||||
 | 
			
		||||
            # write out config for test use
 | 
			
		||||
            rclone_config = configparser.ConfigParser()
 | 
			
		||||
            rclone_config.add_section("test-minio-config")
 | 
			
		||||
            rclone_config.set("test-minio-config", "type", "s3")
 | 
			
		||||
            rclone_config.set("test-minio-config", "provider", "Minio")
 | 
			
		||||
            rclone_config.set("test-minio-config", "endpoint", "http://" + host_ip)
 | 
			
		||||
            rclone_config.set("test-minio-config", "acl", "public-read")
 | 
			
		||||
            rclone_config.set("test-minio-config", "env_auth", "true")
 | 
			
		||||
            rclone_config.set("test-minio-config", "region", "us-east-1")
 | 
			
		||||
            rclone_config.set("test-minio-config", "access_key_id", "minioadmin")
 | 
			
		||||
            rclone_config.set("test-minio-config", "secret_access_key", "minioadmin")
 | 
			
		||||
 | 
			
		||||
            rclone_config_path = Path('rclone_config_path')
 | 
			
		||||
            rclone_config_path.mkdir(parents=True, exist_ok=True)
 | 
			
		||||
            rclone_file = rclone_config_path / 'rclone-minio.conf'
 | 
			
		||||
            with open(rclone_file, "w", encoding="utf-8") as configfile:
 | 
			
		||||
                rclone_config.write(configfile)
 | 
			
		||||
 | 
			
		||||
            # set up config for run
 | 
			
		||||
            awsbucket = "test-bucket"
 | 
			
		||||
            deploy.config['awsbucket'] = awsbucket
 | 
			
		||||
            deploy.config['rclone_config'] = "test-minio-config"
 | 
			
		||||
            deploy.config['path_to_custom_rclone_config'] = str(rclone_file)
 | 
			
		||||
            common.options = VerboseFalseOptions
 | 
			
		||||
 | 
			
		||||
            # call function
 | 
			
		||||
            deploy.update_remote_storage_with_rclone(
 | 
			
		||||
                repo_section, awsbucket, is_index_only=True
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            # check if apk and index file are available
 | 
			
		||||
            bucket_content = client.list_objects('test-bucket', recursive=True)
 | 
			
		||||
            files_in_bucket = {obj.object_name for obj in bucket_content}
 | 
			
		||||
        self.assertEqual(files_in_bucket, {'fdroid/repo/index-v2.json'})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue