public void TestGetCredentialHelperFor_correctSuffixMatching() { SystemPath json = Paths.Get(TestResources.GetResource("core/json/dockerconfig.json").ToURI()); DockerConfig dockerConfig = new DockerConfig(JsonTemplateMapper.ReadJsonFromFile <DockerConfigTemplate>(json)); Assert.IsNull(dockerConfig.GetCredentialHelperFor("example")); Assert.IsNull(dockerConfig.GetCredentialHelperFor("another.example")); }
public void TestGetCredentialHelperFor_withProtocolAndSuffix() { SystemPath json = Paths.Get(TestResources.GetResource("core/json/dockerconfig.json").ToURI()); DockerConfig dockerConfig = new DockerConfig(JsonTemplateMapper.ReadJsonFromFile <DockerConfigTemplate>(json)); Assert.AreEqual( Paths.Get("docker-credential-some credential store"), dockerConfig.GetCredentialHelperFor("with.protocol.and.suffix").GetCredentialHelper()); }
public void Test_fromJson() { // Loads the JSON string. SystemPath jsonFile = Paths.Get(TestResources.GetResource("core/json/dockerconfig.json").ToURI()); // Deserializes into a docker config JSON object. DockerConfig dockerConfig = new DockerConfig(JsonTemplateMapper.ReadJsonFromFile <DockerConfigTemplate>(jsonFile)); Assert.AreEqual("some:auth", DecodeBase64(dockerConfig.GetAuthFor("some registry"))); Assert.AreEqual( "some:other:auth", DecodeBase64(dockerConfig.GetAuthFor("some other registry"))); Assert.AreEqual("token", DecodeBase64(dockerConfig.GetAuthFor("registry"))); Assert.AreEqual("token", DecodeBase64(dockerConfig.GetAuthFor("https://registry"))); Assert.IsNull(dockerConfig.GetAuthFor("just registry")); Assert.AreEqual( Paths.Get("docker-credential-some credential store"), dockerConfig.GetCredentialHelperFor("some registry").GetCredentialHelper()); Assert.AreEqual( Paths.Get("docker-credential-some credential store"), dockerConfig.GetCredentialHelperFor("some other registry").GetCredentialHelper()); Assert.AreEqual( Paths.Get("docker-credential-some credential store"), dockerConfig.GetCredentialHelperFor("just registry").GetCredentialHelper()); Assert.AreEqual( Paths.Get("docker-credential-some credential store"), dockerConfig.GetCredentialHelperFor("with.protocol").GetCredentialHelper()); Assert.AreEqual( Paths.Get("docker-credential-another credential helper"), dockerConfig.GetCredentialHelperFor("another registry").GetCredentialHelper()); Assert.IsNull(dockerConfig.GetCredentialHelperFor("unknonwn registry")); }