@@ -66,9 +66,29 @@ public sealed class Base64ProviderTest
6666 private readonly WarnLogger _warnLogger = new WarnLogger ( ) ;
6767
6868 [ Theory ]
69- [ InlineData ( "{\" auths\" :{\" ghcr.io\" :{}}}" ) ]
70- [ InlineData ( "{\" auths\" :{\" ://ghcr.io\" :{}}}" ) ]
71- public void ResolvePartialDockerRegistry ( string jsonDocument )
69+ [ InlineData ( "{\" auths\" :{\" ghcr.io\" :{}}}" , "ghcr.io" , true ) ]
70+ [ InlineData ( "{\" auths\" :{\" ghcr.io\" :{}}}" , "ghcr" , false ) ]
71+ [ InlineData ( "{\" auths\" :{\" http://ghcr.io\" :{}}}" , "ghcr.io" , true ) ]
72+ [ InlineData ( "{\" auths\" :{\" https://ghcr.io\" :{}}}" , "ghcr.io" , true ) ]
73+ [ InlineData ( "{\" auths\" :{\" registry.example.com:5000\" :{}}}" , "registry.example.com:5000" , true ) ]
74+ [ InlineData ( "{\" auths\" :{\" localhost:5000\" :{}}}" , "localhost:5000" , true ) ]
75+ [ InlineData ( "{\" auths\" :{\" registry.example.com:5000\" :{}}}" , "registry.example.com" , false ) ]
76+ [ InlineData ( "{\" auths\" :{\" localhost:5000\" :{}}}" , "localhost" , false ) ]
77+ [ InlineData ( "{\" auths\" :{\" https://registry.example.com:5000\" :{}}}" , "registry.example.com:5000" , true ) ]
78+ [ InlineData ( "{\" auths\" :{\" http://localhost:8080\" :{}}}" , "localhost:8080" , true ) ]
79+ [ InlineData ( "{\" auths\" :{\" docker.io\" :{}}}" , "docker.io" , true ) ]
80+ [ InlineData ( "{\" auths\" :{\" docker.io\" :{}}}" , "index.docker.io" , false ) ]
81+ [ InlineData ( "{\" auths\" :{\" index.docker.io\" :{}}}" , "docker.io" , false ) ]
82+ [ InlineData ( "{\" auths\" :{\" https://index.docker.io/v1/\" :{}}}" , "index.docker.io" , true ) ]
83+ [ InlineData ( "{\" auths\" :{\" registry.k8s.io\" :{}}}" , "registry.k8s.io" , true ) ]
84+ [ InlineData ( "{\" auths\" :{\" gcr.io\" :{}}}" , "gcr.io" , true ) ]
85+ [ InlineData ( "{\" auths\" :{\" us-docker.pkg.dev\" :{}}}" , "us-docker.pkg.dev" , true ) ]
86+ [ InlineData ( "{\" auths\" :{\" quay.io\" :{}}}" , "quay.io" , true ) ]
87+ [ InlineData ( "{\" auths\" :{\" localhost\" :{}}}" , "localhost" , true ) ]
88+ [ InlineData ( "{\" auths\" :{\" 127.0.0.1:5000\" :{}}}" , "127.0.0.1:5000" , true ) ]
89+ [ InlineData ( "{\" auths\" :{\" [::1]:5000\" :{}}}" , "[::1]:5000" , true ) ]
90+ [ InlineData ( "{\" auths\" :{\" https://registry.example.com/v2\" :{}}}" , "registry.example.com" , true ) ]
91+ public void ResolvePartialDockerRegistry ( string jsonDocument , string hostname , bool expectedResult )
7292 {
7393 // Given
7494 var jsonElement = JsonDocument . Parse ( jsonDocument ) . RootElement ;
@@ -77,8 +97,7 @@ public void ResolvePartialDockerRegistry(string jsonDocument)
7797 var authenticationProvider = new Base64Provider ( jsonElement , NullLogger . Instance ) ;
7898
7999 // Then
80- Assert . False ( authenticationProvider . IsApplicable ( "ghcr" ) ) ;
81- Assert . True ( authenticationProvider . IsApplicable ( "ghcr.io" ) ) ;
100+ Assert . Equal ( expectedResult , authenticationProvider . IsApplicable ( hostname ) ) ;
82101 }
83102
84103 [ Theory ]
0 commit comments