public void ShouldGetNull(string jsonDocument, bool isApplicable) { // Given var jsonElement = JsonDocument.Parse(jsonDocument).RootElement; // When var authenticationProvider = new CredsHelperProvider(jsonElement, TestcontainersSettings.Logger); var authConfig = authenticationProvider.GetAuthConfig(DockerRegistry); // Then Assert.Equal(isApplicable, authenticationProvider.IsApplicable(DockerRegistry)); Assert.Null(authConfig); }
public void ShouldGetAuthConfig(string credHelperName, string expectedUsername, string expectedPassword, string expectedIdentityToken) { // Given var credHelpersScriptName = Path.ChangeExtension(credHelperName, RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "bat" : "sh"); var jsonDocument = "{\"credHelpers\":{\"" + DockerRegistry + "\":\"" + credHelpersScriptName + "\"}}"; var jsonElement = JsonDocument.Parse(jsonDocument).RootElement; // When var authenticationProvider = new CredsHelperProvider(jsonElement, TestcontainersSettings.Logger); var authConfig = authenticationProvider.GetAuthConfig(DockerRegistry); // Then Assert.True(authenticationProvider.IsApplicable(DockerRegistry)); Assert.NotNull(authConfig); Assert.Equal(DockerRegistry, authConfig.RegistryEndpoint); Assert.Equal(expectedUsername, authConfig.Username); Assert.Equal(expectedPassword, authConfig.Password); Assert.Equal(expectedIdentityToken, authConfig.IdentityToken); }