// Copyright © WireMock.Net
using System;
using Docker.DotNet.Models;
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Configurations;
using JetBrains.Annotations;
namespace WireMock.Net.Testcontainers;
///
[PublicAPI]
public sealed class WireMockConfiguration : ContainerConfiguration
{
#pragma warning disable CS1591
public string? Username { get; }
public string? Password { get; }
public string? StaticMappingsPath { get; private set; }
public bool HasBasicAuthentication => !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password);
public WireMockConfiguration(string? username = null, string? password = null)
{
Username = username;
Password = password;
}
#pragma warning restore CS1591
///
/// Initializes a new instance of the class.
///
/// The Docker resource configuration.
public WireMockConfiguration(IResourceConfiguration resourceConfiguration) : base(resourceConfiguration)
{
// Passes the configuration upwards to the base implementations to create an updated immutable copy.
}
///
/// Initializes a new instance of the class.
///
/// The Docker resource configuration.
public WireMockConfiguration(IContainerConfiguration resourceConfiguration) : base(resourceConfiguration)
{
// Passes the configuration upwards to the base implementations to create an updated immutable copy.
}
///
/// Initializes a new instance of the class.
///
/// The Docker resource configuration.
public WireMockConfiguration(WireMockConfiguration resourceConfiguration) : this(new WireMockConfiguration(), resourceConfiguration)
{
// Passes the configuration upwards to the base implementations to create an updated immutable copy.
}
///
/// Initializes a new instance of the class.
///
/// The old Docker resource configuration.
/// The new Docker resource configuration.
public WireMockConfiguration(WireMockConfiguration oldValue, WireMockConfiguration newValue) : base(oldValue, newValue)
{
Username = BuildConfiguration.Combine(oldValue.Username, newValue.Username);
Password = BuildConfiguration.Combine(oldValue.Password, newValue.Password);
StaticMappingsPath = BuildConfiguration.Combine(oldValue.StaticMappingsPath, newValue.StaticMappingsPath);
}
///
/// Set the StaticMappingsPath.
///
/// The path which contains the StaticMappings.
///
public WireMockConfiguration WithStaticMappingsPath(string path)
{
StaticMappingsPath = path;
return this;
}
}