Esempio n. 1
0
def do_test_docker_binding_failure(version_success=True, manifests_success=True,
  auth_success=True):
  with requests_mock.Mocker() as m:
    mock_registry(m, need_auth_token=True, version_success=version_success,
      manifests_success=manifests_success, auth_success=auth_success)

    with pytest.raises(DockerClientException):
      DockerRegistryClient.resolve(mock_cluster(), NAME, TAG)
Esempio n. 2
0
def do_test_docker_binding_failure(version_success=True,
                                   manifests_success=True,
                                   auth_success=True):
    with requests_mock.Mocker() as m:
        mock_registry(m,
                      need_auth_token=True,
                      version_success=version_success,
                      manifests_success=manifests_success,
                      auth_success=auth_success)

        with pytest.raises(DockerClientException):
            DockerRegistryClient.resolve(mock_cluster(), NAME, TAG)
Esempio n. 3
0
 def bind(self, config, match, env, binding_dict):
   cluster = CLUSTERS[config.cluster()]
   image = match
   ref_str = 'docker.image[%s][%s]' % image[2:4]
   ref = Ref.from_address(ref_str)
   if ref_str in binding_dict:
     (image_data, image_struct) = binding_dict[ref_str]
   else:
     image_data = '%s:%s' % (image[2], image[3])
     image_struct = DockerRegistryClient.resolve(cluster, image[2], image[3])
   binding_dict[ref_str] = (image_data, image_struct)
   config.bind({ref: image_struct})
Esempio n. 4
0
 def bind(self, config, match, env, binding_dict):
     cluster = CLUSTERS[config.cluster()]
     image = match
     ref_str = 'docker.image[%s][%s]' % image[2:4]
     ref = Ref.from_address(ref_str)
     if ref_str in binding_dict:
         (image_data, image_struct) = binding_dict[ref_str]
     else:
         image_data = '%s:%s' % (image[2], image[3])
         image_struct = DockerRegistryClient.resolve(
             cluster, image[2], image[3])
     binding_dict[ref_str] = (image_data, image_struct)
     config.bind({ref: image_struct})
Esempio n. 5
0
def do_test_docker_binding_success(need_auth_token=False):
  with requests_mock.Mocker() as m:
    mock_registry(m, need_auth_token=need_auth_token)
    assert DockerRegistryClient.resolve(mock_cluster(), NAME, TAG) == EXPECTED_REFERENCE
Esempio n. 6
0
def test_docker_binding_unknown_registry():
  with pytest.raises(Exception):
    DockerRegistryClient.resolve(mock_cluster(), NAME, TAG)
Esempio n. 7
0
def do_test_docker_binding_success(need_auth_token=False):
    with requests_mock.Mocker() as m:
        mock_registry(m, need_auth_token=need_auth_token)
        assert DockerRegistryClient.resolve(mock_cluster(), NAME,
                                            TAG) == EXPECTED_REFERENCE
Esempio n. 8
0
def test_docker_binding_unknown_registry():
    with pytest.raises(Exception):
        DockerRegistryClient.resolve(mock_cluster(), NAME, TAG)