From d535f16fac142151d80ddd012a1b47a7b91ed5fa Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Mon, 6 Jun 2022 16:22:35 +0200 Subject: [PATCH] [#370] #UPDATE 'assemblyName: DotNet.Testcontainers; refactor: IAuthenticationProvider' {Prepare the authentication provider for different configurations.} --- .../Builders/Base64Provider.cs | 4 ++-- .../Builders/CredsHelperProvider.cs | 4 ++-- .../Builders/CredsStoreProvider.cs | 4 ++-- .../DockerRegistryAuthenticationProvider.cs | 6 +++--- .../Builders/IAuthenticationProvider.cs | 14 +++++++------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/DotNet.Testcontainers/Builders/Base64Provider.cs b/src/DotNet.Testcontainers/Builders/Base64Provider.cs index b34a1ff36..3f73d5222 100644 --- a/src/DotNet.Testcontainers/Builders/Base64Provider.cs +++ b/src/DotNet.Testcontainers/Builders/Base64Provider.cs @@ -8,8 +8,8 @@ using JetBrains.Annotations; using Microsoft.Extensions.Logging; - /// - internal sealed class Base64Provider : IAuthenticationProvider + /// + internal sealed class Base64Provider : IAuthenticationProvider { private readonly JsonElement rootElement; diff --git a/src/DotNet.Testcontainers/Builders/CredsHelperProvider.cs b/src/DotNet.Testcontainers/Builders/CredsHelperProvider.cs index f34de84dd..4fc0a8681 100644 --- a/src/DotNet.Testcontainers/Builders/CredsHelperProvider.cs +++ b/src/DotNet.Testcontainers/Builders/CredsHelperProvider.cs @@ -2,8 +2,8 @@ { using DotNet.Testcontainers.Configurations; - /// - internal sealed class CredsHelperProvider : IAuthenticationProvider + /// + internal sealed class CredsHelperProvider : IAuthenticationProvider { /// public bool IsApplicable() diff --git a/src/DotNet.Testcontainers/Builders/CredsStoreProvider.cs b/src/DotNet.Testcontainers/Builders/CredsStoreProvider.cs index 774a6b442..f8843d328 100644 --- a/src/DotNet.Testcontainers/Builders/CredsStoreProvider.cs +++ b/src/DotNet.Testcontainers/Builders/CredsStoreProvider.cs @@ -7,8 +7,8 @@ using JetBrains.Annotations; using Microsoft.Extensions.Logging; - /// - internal sealed class CredsStoreProvider : IAuthenticationProvider + /// + internal sealed class CredsStoreProvider : IAuthenticationProvider { private static readonly JsonSerializerOptions JsonSerializerOptions = new JsonSerializerOptions(); diff --git a/src/DotNet.Testcontainers/Builders/DockerRegistryAuthenticationProvider.cs b/src/DotNet.Testcontainers/Builders/DockerRegistryAuthenticationProvider.cs index b84e8b76e..87ff0ee7b 100644 --- a/src/DotNet.Testcontainers/Builders/DockerRegistryAuthenticationProvider.cs +++ b/src/DotNet.Testcontainers/Builders/DockerRegistryAuthenticationProvider.cs @@ -9,8 +9,8 @@ using JetBrains.Annotations; using Microsoft.Extensions.Logging; - /// - internal sealed class DockerRegistryAuthenticationProvider : IAuthenticationProvider + /// + internal sealed class DockerRegistryAuthenticationProvider : IAuthenticationProvider { private const string DockerHub = "index.docker.io"; @@ -81,7 +81,7 @@ private IDockerRegistryAuthenticationConfiguration GetUncachedAuthConfig(string { using (var dockerConfigDocument = JsonDocument.Parse(dockerConfigFileStream)) { - authConfig = new IAuthenticationProvider[] { new CredsHelperProvider(), new CredsStoreProvider(dockerConfigDocument, this.logger), new Base64Provider(dockerConfigDocument, this.logger) } + authConfig = new IAuthenticationProvider[] { new CredsHelperProvider(), new CredsStoreProvider(dockerConfigDocument, this.logger), new Base64Provider(dockerConfigDocument, this.logger) } .AsParallel() .Select(authenticationProvider => authenticationProvider.GetAuthConfig(hostname)) .FirstOrDefault(authenticationProvider => authenticationProvider != null); diff --git a/src/DotNet.Testcontainers/Builders/IAuthenticationProvider.cs b/src/DotNet.Testcontainers/Builders/IAuthenticationProvider.cs index 54c80eb93..e94b83199 100644 --- a/src/DotNet.Testcontainers/Builders/IAuthenticationProvider.cs +++ b/src/DotNet.Testcontainers/Builders/IAuthenticationProvider.cs @@ -1,13 +1,13 @@ namespace DotNet.Testcontainers.Builders { - using DotNet.Testcontainers.Configurations; using JetBrains.Annotations; /// - /// A Docker registry authentication provider. + /// A Docker authentication provider. /// + /// Type of the authentication configuration. [PublicAPI] - internal interface IAuthenticationProvider + internal interface IAuthenticationProvider { /// /// Is true when the authentication provider contains any credentials, otherwise false. @@ -17,12 +17,12 @@ internal interface IAuthenticationProvider bool IsApplicable(); /// - /// Gets the Docker registry authentication configuration. + /// Gets the Docker authentication configuration. /// - /// The Docker registry hostname. - /// The Docker registry authentication configuration or null if no configuration matches the hostname. + /// The Docker hostname. + /// The Docker authentication configuration or null if no configuration matches the hostname. [PublicAPI] [CanBeNull] - IDockerRegistryAuthenticationConfiguration GetAuthConfig(string hostname); + TAuthenticationConfiguration GetAuthConfig(string hostname); } }