public void TestRetrieve_nonexistentDockerConfigFile()
        {
            DockerConfigCredentialRetriever dockerConfigCredentialRetriever =
                new DockerConfigCredentialRetriever("some registry", Paths.Get("fake/path"));

            Assert.IsFalse(dockerConfigCredentialRetriever.Retrieve(mockLogger).IsPresent());
        }
        public void TestRetrieve_none()
        {
            DockerConfigCredentialRetriever dockerConfigCredentialRetriever =
                new DockerConfigCredentialRetriever("unknown registry", dockerConfigFile);

            Assert.IsFalse(dockerConfigCredentialRetriever.Retrieve(mockLogger).IsPresent());
        }
        public void TestRetrieve_hasAuth()
        {
            DockerConfigCredentialRetriever dockerConfigCredentialRetriever =
                new DockerConfigCredentialRetriever("some registry", dockerConfigFile);

            Maybe <Credential> credentials = dockerConfigCredentialRetriever.Retrieve(mockLogger);

            Assert.IsTrue(credentials.IsPresent());
            Assert.AreEqual("some", credentials.Get().GetUsername());
            Assert.AreEqual("auth", credentials.Get().GetPassword());
        }
        public void TestRetrieve_useCredHelper()
        {
            Mock.Get(mockDockerConfig).Setup(m => m.GetCredentialHelperFor("another registry")).Returns(mockDockerCredentialHelper);

            DockerConfigCredentialRetriever dockerConfigCredentialRetriever =
                new DockerConfigCredentialRetriever("another registry", dockerConfigFile);

            Assert.AreEqual(
                FAKE_CREDENTIAL,
                dockerConfigCredentialRetriever
                .Retrieve(mockDockerConfig, mockLogger)
                .OrElseThrow(() => new AssertionException("")));
        }
        public void TestRetrieve_suffixMatchingFromAlias()
        {
            SystemPath dockerConfigFile =
                Paths.Get(TestResources.GetResource("core/json/dockerconfig_index_docker_io_v1.json").ToURI());

            DockerConfigCredentialRetriever dockerConfigCredentialRetriever =
                new DockerConfigCredentialRetriever("registry.hub.docker.com", dockerConfigFile);

            Maybe <Credential> credentials = dockerConfigCredentialRetriever.Retrieve(mockLogger);

            Assert.IsTrue(credentials.IsPresent());
            Assert.AreEqual("token for", credentials.Get().GetUsername());
            Assert.AreEqual(" index.docker.io/v1/", credentials.Get().GetPassword());
        }