Exemplo n.º 1
0
 def update_remote_repo(self,
                        repo: RemoteRepository) -> RemoteRepositoryResponse:
     """
     Updates a remote artifactory repository
     :param repo: VirtualRepository object
     :return: VirtualRepositoryResponse
     """
     repo_name = repo.key
     self.get_remote_repo(repo_name)
     self._post(f"api/{self._uri}/{repo_name}", json=repo.dict())
     logging.debug(f"Repository {repo_name} successfully updated")
     return self.get_remote_repo(repo_name)
Exemplo n.º 2
0
 def update_remote_repo(self, repo: RemoteRepository) -> RemoteRepositoryResponse:
     """
     Updates a remote artifactory repository
     :param repo: VirtualRepository object
     :return: VirtualRepositoryResponse
     """
     warnings.warn(
         "`update_remote_repo()` is deprecated, use `update_repo` instead",
         DeprecationWarning,
     )
     repo_name = repo.key
     self.get_remote_repo(repo_name)
     self._post(f"api/{self._uri}/{repo_name}", json=repo.dict())
     logger.debug("Repository %s successfully updated", repo_name)
     return self.get_remote_repo(repo_name)
Exemplo n.º 3
0
 def create_remote_repo(self,
                        repo: RemoteRepository) -> RemoteRepositoryResponse:
     """
     Creates a new local repository
     :param repo: RemoteRepository object
     :return: RemoteRepositoryResponse object
     """
     repo_name = repo.key
     try:
         self.get_remote_repo(repo_name)
         logging.error(f"Repository {repo_name} already exists")
         raise RepositoryAlreadyExistsException(
             f"Repository {repo_name} already exists")
     except RepositoryNotFoundException:
         self._put(f"api/{self._uri}/{repo_name}", json=repo.dict())
         logging.debug(f"Repository {repo_name} successfully created")
         return self.get_remote_repo(repo_name)
Exemplo n.º 4
0
 def create_remote_repo(self,
                        repo: RemoteRepository) -> RemoteRepositoryResponse:
     """
     Creates a new local repository
     :param repo: RemoteRepository object
     :return: RemoteRepositoryResponse object
     """
     warnings.warn(
         "`create_remote_repo()` is deprecated, use `create_repo` instead",
         DeprecationWarning,
     )
     repo_name = repo.key
     try:
         self.get_remote_repo(repo_name)
         logger.error("Repository %s already exists", repo_name)
         raise RepositoryAlreadyExistsException(
             f"Repository {repo_name} already exists")
     except RepositoryNotFoundException:
         self._put(f"api/{self._uri}/{repo_name}", json=repo.dict())
         logger.debug("Repository %s successfully created", repo_name)
         return self.get_remote_repo(repo_name)
Exemplo n.º 5
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")
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,
    )

    artifactory_repo = ArtifactoryRepository(AuthModel(url=URL, auth=AUTH))
Exemplo n.º 6
0
                                     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",
    url="http://test-url.com",
    description="updated",
)


@responses.activate