Example #1
0
 def get_virtual_repo(self, repo_name: str) -> VirtualRepositoryResponse:
     """
     Finds repository in artifactory. Fill object if exist
     :param repo_name: Name of the repository to retrieve
     :return: VirtualRepositoryResponse object
     """
     try:
         r = self._get(f"api/{self._uri}/{repo_name}")
         return VirtualRepositoryResponse(**r.json())
     except requests.exceptions.HTTPError as e:
         if e.response.status_code == 404 or e.response.status_code == 400:
             logging.error(f"Repository {repo_name} does not exist")
             raise RepositoryNotFoundException(
                 f" Repository {repo_name} does not exist")
         raise ArtifactoryException from e
Example #2
0
 def get_virtual_repo(self, repo_name: str) -> VirtualRepositoryResponse:
     """
     Finds repository in artifactory. Fill object if exist
     :param repo_name: Name of the repository to retrieve
     :return: VirtualRepositoryResponse object
     """
     warnings.warn(
         "`get_virtual_repo()` is deprecated, use `get_repo` instead",
         DeprecationWarning,
     )
     try:
         response = self._get(f"api/{self._uri}/{repo_name}")
         logger.debug("Repository %s found", repo_name)
         return VirtualRepositoryResponse(**response.json())
     except requests.exceptions.HTTPError as error:
         if error.response.status_code in (404, 400):
             raise RepositoryNotFoundException(
                 f" Repository {repo_name} does not exist")
         raise ArtifactoryException from error
Example #3
0
    SimpleRepository,
)

URL = "http://localhost:8080/artifactory"
AUTH = ("user", "password_or_apiKey")

SIMPLE_REPOSITORY = SimpleRepository(key="test_repository",
                                     type="local",
                                     url="some-url",
                                     packageType="docker")
LOCAL_REPOSITORY = LocalRepository(key="test_local_repository")
LOCAL_REPOSITORY_RESPONSE = LocalRepositoryResponse(
    key="test_local_repository")
VIRTUAL_REPOSITORY = VirtualRepository(key="test_virtual_repository",
                                       rclass="virtual")
VIRTUAL_REPOSITORY_RESPONSE = VirtualRepositoryResponse(
    key="test_virtual_repository", rclass="virtual")
REMOTE_REPOSITORY = RemoteRepository(key="test_remote_repository",
                                     url="http://test-url.com",
                                     rclass="remote")
REMOTE_REPOSITORY_RESPONSE = RemoteRepositoryResponse(
    key="test_remote_repository", url="http://test-url.com", rclass="remote")


@responses.activate
def test_create_local_repository_fail_if_user_already_exists(mocker):
    responses.add(
        responses.GET,
        f"{URL}/api/repositories/{LOCAL_REPOSITORY.key}",
        json=LOCAL_REPOSITORY_RESPONSE.dict(),
        status=200,
    )
Example #4
0
URL = "http://localhost:8080/artifactory"
AUTH = ("user", "password_or_apiKey")

SIMPLE_REPOSITORY = SimpleRepository(key="test_repository",
                                     type="local",
                                     url="some-url",
                                     packageType="docker")
LOCAL_REPOSITORY = LocalRepository(key="test_local_repository")
LOCAL_REPOSITORY_RESPONSE = LocalRepositoryResponse(
    key="test_local_repository")
UPDATED_LOCAL_REPOSITORY = LocalRepository(key="test_local_repository",
                                           description="updated")
UPDATED_LOCAL_REPOSITORY_RESPONSE = LocalRepositoryResponse(
    key="test_local_repository", description="updated")
VIRTUAL_REPOSITORY = VirtualRepository(key="test_virtual_repository")
VIRTUAL_REPOSITORY_RESPONSE = VirtualRepositoryResponse(
    key="test_virtual_repository")
UPDATED_VIRTUAL_REPOSITORY = VirtualRepository(key="test_virtual_repository",
                                               description="updated")
UPDATED_VIRTUAL_REPOSITORY_RESPONSE = VirtualRepositoryResponse(
    key="test_virtual_repository", description="updated")
REMOTE_REPOSITORY = RemoteRepository(key="test_remote_repository",
                                     url="http://test-url.com")
REMOTE_REPOSITORY_RESPONSE = RemoteRepositoryResponse(
    key="test_remote_repository", url="http://test-url.com")
UPDATED_REMOTE_REPOSITORY = RemoteRepository(
    key="test_remote_repository",
    url="http://test-url.com",
    description="updated",
)
UPDATED_REMOTE_REPOSITORY_RESPONSE = RemoteRepositoryResponse(
    key="test_remote_repository",