Esempio n. 1
0
    def _get_api(self):
        if self.remote_url not in self._cached_capabilities:
            tmp = RestV1Methods(self.remote_url, self.token,
                                self.custom_headers, self._output,
                                self.requester, self.verify_ssl,
                                self._put_headers)
            _, _, cap = tmp.server_info()
            self._cached_capabilities[self.remote_url] = cap

        if not self.block_v2 and REVISIONS in self._cached_capabilities[
                self.remote_url]:
            checksum_deploy = CHECKSUM_DEPLOY in self._cached_capabilities[
                self.remote_url]
            revisions_enabled = get_env("CONAN_CLIENT_REVISIONS_ENABLED",
                                        False)
            self.custom_headers[
                "V2_COMPATIBILITY_MODE"] = "1" if not revisions_enabled else "0"
            return RestV2Methods(self.remote_url, self.token,
                                 self.custom_headers, self._output,
                                 self.requester, self.verify_ssl,
                                 self._put_headers, checksum_deploy)
        else:
            return RestV1Methods(self.remote_url, self.token,
                                 self.custom_headers, self._output,
                                 self.requester, self.verify_ssl,
                                 self._put_headers)
Esempio n. 2
0
    def _get_api(self):
        if self.remote_url not in self._cached_capabilities:
            tmp = RestV1Methods(self.remote_url, self.token,
                                self.custom_headers, self._output,
                                self.requester, self.verify_ssl,
                                self._put_headers)
            cap = tmp.server_capabilities()
            self._cached_capabilities[self.remote_url] = cap
            logger.debug("REST: Cached capabilities for the remote: %s" % cap)
            if not self._revisions_enabled and ONLY_V2 in cap:
                raise OnlyV2Available(self.remote_url)

        if self._revisions_enabled and REVISIONS in self._cached_capabilities.get(
                self.remote_url, []):
            checksum_deploy = CHECKSUM_DEPLOY in self._cached_capabilities.get(
                self.remote_url, [])
            return RestV2Methods(self.remote_url, self.token,
                                 self.custom_headers, self._output,
                                 self.requester, self.verify_ssl,
                                 self._put_headers, checksum_deploy)
        else:
            return RestV1Methods(self.remote_url, self.token,
                                 self.custom_headers, self._output,
                                 self.requester, self.verify_ssl,
                                 self._put_headers)
Esempio n. 3
0
 def _get_api(self):
     revisions = self._capable(REVISIONS)
     if self._revisions_enabled and revisions:
         checksum_deploy = self._capable(CHECKSUM_DEPLOY)
         return RestV2Methods(self.remote_url, self.token, self.custom_headers, self._output,
                              self.requester, self.verify_ssl, self._put_headers,
                              checksum_deploy)
     else:
         return RestV1Methods(self.remote_url, self.token, self.custom_headers, self._output,
                              self.requester, self.verify_ssl, self._put_headers)
Esempio n. 4
0
 def _get_api(self):
     revisions = self._capable(REVISIONS)
     matrix_params = self._capable(MATRIX_PARAMS)
     if self._revisions_enabled and revisions:
         checksum_deploy = self._capable(CHECKSUM_DEPLOY)
         return RestV2Methods(self._remote_url, self._token,
                              self._custom_headers, self._output,
                              self._requester, self._verify_ssl,
                              self._artifacts_properties, checksum_deploy,
                              matrix_params)
     else:
         return RestV1Methods(self._remote_url, self._token,
                              self._custom_headers, self._output,
                              self._requester, self._verify_ssl,
                              self._artifacts_properties, matrix_params)
Esempio n. 5
0
    def _get_api(self):
        if self.remote_url not in self._capabilities:
            tmp = RestV1Methods(self.remote_url, self.token,
                                self.custom_headers, self._output,
                                self.requester, self.verify_ssl,
                                self._put_headers)
            _, _, cap = tmp.server_info()
            self._capabilities[self.remote_url] = cap

        if API_V2 in self._capabilities[self.remote_url]:
            checksum_deploy = CHECKSUM_DEPLOY in self._capabilities[
                self.remote_url]
            return RestV2Methods(self.remote_url, self.token,
                                 self.custom_headers, self._output,
                                 self.requester, self.verify_ssl,
                                 self._put_headers, checksum_deploy)
        else:
            return RestV1Methods(self.remote_url, self.token,
                                 self.custom_headers, self._output,
                                 self.requester, self.verify_ssl,
                                 self._put_headers)
Esempio n. 6
0
    def test_corrupted_manifest(self):
        remote_url = "http://some.url"
        pref = PackageReference.loads("lib/version@user/channel:123#packageid")

        with patch.object(RestV2Methods, "_get_remote_file_contents", return_value=b"fail"), \
             patch.object(ClientV2Router, "package_manifest", return_value=None):

            v2 = RestV2Methods(remote_url,
                               token=None,
                               custom_headers=None,
                               output=None,
                               requester=None,
                               verify_ssl=None)
            with self.assertRaises(ConanException) as exc:
                v2.get_package_manifest(pref=pref)

            # Exception tells me about the originating error and the request I was doing.
            self.assertIn(
                "Error retrieving manifest file for package '{}'"
                " from remote ({})".format(pref.full_repr(), remote_url),
                str(exc.exception))
            self.assertIn("invalid literal for int() with base 10",
                          str(exc.exception))
Esempio n. 7
0
    def _get_api(self):
        if self.remote_url not in self._cached_capabilities:
            tmp = RestV1Methods(self.remote_url, self.token,
                                self.custom_headers, self._output,
                                self.requester, self.verify_ssl,
                                self._put_headers)
            _, _, cap = tmp.server_info()
            self._cached_capabilities[self.remote_url] = cap
            if not self._revisions_enabled and ONLY_V2 in cap:
                raise OnlyV2Available(self.remote_url)

        if self._revisions_enabled and REVISIONS in self._cached_capabilities[
                self.remote_url]:
            checksum_deploy = CHECKSUM_DEPLOY in self._cached_capabilities[
                self.remote_url]
            return RestV2Methods(self.remote_url, self.token,
                                 self.custom_headers, self._output,
                                 self.requester, self.verify_ssl,
                                 self._put_headers, checksum_deploy)
        else:
            return RestV1Methods(self.remote_url, self.token,
                                 self.custom_headers, self._output,
                                 self.requester, self.verify_ssl,
                                 self._put_headers)