Example #1
0
    def setUp(self):
        self.conan_reference = ConanFileReference.loads(
            "openssl/2.0.3@lasote/testing")
        self.package_reference = PackageReference(self.conan_reference,
                                                  "123123123")
        self.tmp_dir = temp_folder()

        read_perms = [("*/*@*/*", "*")]
        write_perms = []
        authorizer = BasicAuthorizer(read_perms, write_perms)

        self.fake_url = "http://url"
        updown_auth_manager = JWTUpDownAuthManager("secret",
                                                   timedelta(seconds=200))
        adapter = ServerDiskAdapter(self.fake_url, self.tmp_dir,
                                    updown_auth_manager)
        self.paths = SimplePaths(self.tmp_dir)
        self.file_manager = FileManager(self.paths, adapter)
        self.service = ConanService(authorizer, self.file_manager, "lasote")
        self.search_service = SearchService(authorizer, self.paths, "lasote")

        files = hello_source_files("test")
        save_files(self.paths.export(self.conan_reference), files)
        self.conan_digest = FileTreeManifest.create(
            self.paths.export(self.conan_reference))
        conan_digest_path = os.path.join(
            self.paths.export(self.conan_reference), CONAN_MANIFEST)
        save(conan_digest_path, str(self.conan_digest))

        files = hello_source_files("package")
        save_files(self.paths.package(self.package_reference), files)
Example #2
0
    def setUp(self):
        self.ref = ConanFileReference.loads("openssl/2.0.3@lasote/testing#%s" % DEFAULT_REVISION_V1)

        self.pref = PackageReference(self.ref, "123123123", DEFAULT_REVISION_V1)
        self.tmp_dir = temp_folder()

        read_perms = [("*/*@*/*", "*")]
        write_perms = []
        authorizer = BasicAuthorizer(read_perms, write_perms)

        self.fake_url = "http://url"
        updown_auth_manager = JWTUpDownAuthManager("secret", timedelta(seconds=200))
        adapter = ServerDiskAdapter(self.fake_url, self.tmp_dir, updown_auth_manager)
        self.server_store = ServerStore(storage_adapter=adapter)
        self.service = ConanService(authorizer, self.server_store, "lasote")
        self.search_service = SearchService(authorizer, self.server_store, "lasote")

        files = hello_source_files("test")
        save_files(self.server_store.export(self.ref), files)
        self.server_store.update_last_revision(self.ref)
        self.conan_digest = FileTreeManifest.create(self.server_store.export(self.ref))
        conan_digest_path = os.path.join(self.server_store.export(self.ref), CONAN_MANIFEST)
        save(conan_digest_path, str(self.conan_digest))

        files = hello_source_files("package")
        save_files(self.server_store.package(self.pref), files)
Example #3
0
def get_server_store(disk_storage_path, public_url, updown_auth_manager):
    disk_controller_url = "%s/%s" % (public_url, "files")
    if not updown_auth_manager:
        raise Exception(
            "Updown auth manager needed for disk controller (not s3)")
    adapter = ServerDiskAdapter(disk_controller_url, disk_storage_path,
                                updown_auth_manager)
    return ServerStore(adapter)
Example #4
0
def get_file_manager(config, public_url=None, updown_auth_manager=None):
    store_adapter = config.store_adapter
    if store_adapter == "disk":
        public_url = public_url or config.public_url
        disk_controller_url = "%s/%s" % (public_url, "files")
        if not updown_auth_manager:
            raise Exception("Updown auth manager needed for disk controller (not s3)")
        adapter = ServerDiskAdapter(disk_controller_url, config.disk_storage_path, updown_auth_manager)
        paths = SimplePaths(config.disk_storage_path)
    else:
        # Want to develop new adapter? create a subclass of
        # conans.server.store.file_manager.ServerStorageAdapter and implement the abstract methods
        raise Exception("Store adapter not implemented! Change 'store_adapter' "
                        "variable in server.conf file to one of the available options: 'disk' ")
    return FileManager(paths, adapter)