Skip to content

Commit

Permalink
Nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nigusu-Allehu committed Mar 8, 2024
1 parent 77260e2 commit 1819d4e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
8 changes: 4 additions & 4 deletions src/NuGet.Core/NuGet.Configuration/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static NuGet.Configuration.ConfigurationConstants.GetConfigKeys() -> System.Coll
static readonly NuGet.Configuration.ConfigurationConstants.AuditSources -> string!
NuGet.Configuration.PackageSource.DisableTLSCertificateValidation.get -> bool
NuGet.Configuration.PackageSource.DisableTLSCertificateValidation.set -> void
~NuGet.Configuration.SourceItem.DisableTLSCertificateValidation.get -> string
~NuGet.Configuration.SourceItem.DisableTLSCertificateValidation.set -> void
~NuGet.Configuration.SourceItem.SourceItem(string key, string value, string protocolVersion, string allowInsecureConnections, string disableTLSCertificateValidation) -> void
~static readonly NuGet.Configuration.ConfigurationConstants.DisableTLSCertificateValidation -> string
NuGet.Configuration.SourceItem.DisableTLSCertificateValidation.get -> string?
NuGet.Configuration.SourceItem.DisableTLSCertificateValidation.set -> void
NuGet.Configuration.SourceItem.SourceItem(string! key, string! value, string? protocolVersion, string? allowInsecureConnections, string? disableTLSCertificateValidation) -> void
static readonly NuGet.Configuration.ConfigurationConstants.DisableTLSCertificateValidation -> string!
12 changes: 3 additions & 9 deletions src/NuGet.Core/NuGet.Configuration/Settings/Items/SourceItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public string? AllowInsecureConnections
set => AddOrUpdateAttribute(ConfigurationConstants.AllowInsecureConnections, value);
}

public string DisableTLSCertificateValidation
public string? DisableTLSCertificateValidation
{
get
{
Expand All @@ -55,22 +55,16 @@ public SourceItem(string key, string value)
}

public SourceItem(string key, string value, string? protocolVersion)
: this(key, value, protocolVersion, allowInsecureConnections: "")
{
}

public SourceItem(string key, string value, string? protocolVersion, string? allowInsecureConnections)
public SourceItem(string key, string value, string protocolVersion)
: this(key, value, protocolVersion, allowInsecureConnections: "", disableTLSCertificateValidation: "")
{
}

public SourceItem(string key, string value, string protocolVersion, string allowInsecureConnections)
public SourceItem(string key, string value, string? protocolVersion, string? allowInsecureConnections)
: this(key, value, protocolVersion, allowInsecureConnections, disableTLSCertificateValidation: "")
{
}

public SourceItem(string key, string value, string protocolVersion, string allowInsecureConnections, string disableTLSCertificateValidation)
public SourceItem(string key, string value, string? protocolVersion, string? allowInsecureConnections, string? disableTLSCertificateValidation)
: base(key, value)
{
if (!string.IsNullOrEmpty(protocolVersion))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,10 +888,8 @@ public void LoadPackageSources_ReadsSourcesWithNotNullAllowInsecureConnectionsFr
Assert.Equal(bool.Parse(allowInsecureConnections), loadedSource.AllowInsecureConnections);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void LoadPackageSources_ReadsSourcesWithNullDisableTLSCertificateVerificationFromPackageSourceSections_LoadsDefault(bool useStaticMethod)
[Fact]
public void LoadPackageSources_ReadsSourcesWithNullDisableTLSCertificateVerificationFromPackageSourceSections_LoadsDefault()
{
// Arrange
var settings = new Mock<ISettings>();
Expand All @@ -905,7 +903,7 @@ public void LoadPackageSources_ReadsSourcesWithNullDisableTLSCertificateVerifica
.Returns(new List<string>());

// Act
List<PackageSource> values = LoadPackageSources(useStaticMethod, settings.Object);
List<PackageSource> values = LoadPackageSources(settings.Object);

// Assert
var loadedSource = values.Single();
Expand All @@ -914,10 +912,8 @@ public void LoadPackageSources_ReadsSourcesWithNullDisableTLSCertificateVerifica
Assert.Equal(PackageSource.DefaultDisableTLSCertificateValidation, loadedSource.DisableTLSCertificateValidation);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void LoadPackageSources_ReadsSourcesWithInvalidDisableTLSCertificateVerificationFromPackageSourceSections_LoadsDefault(bool useStaticMethod)
[Fact]
public void LoadPackageSources_ReadsSourcesWithInvalidDisableTLSCertificateVerificationFromPackageSourceSections_LoadsDefault()
{
// Arrange
var settings = new Mock<ISettings>();
Expand All @@ -931,7 +927,7 @@ public void LoadPackageSources_ReadsSourcesWithInvalidDisableTLSCertificateVerif
.Returns(new List<string>());

// Act
List<PackageSource> values = LoadPackageSources(useStaticMethod, settings.Object);
List<PackageSource> values = LoadPackageSources(settings.Object);

// Assert
var loadedSource = values.Single();
Expand All @@ -941,13 +937,11 @@ public void LoadPackageSources_ReadsSourcesWithInvalidDisableTLSCertificateVerif
}

[Theory]
[InlineData(true, "true")]
[InlineData(true, "TRUE")]
[InlineData(true, "false")]
[InlineData(false, "false")]
[InlineData(false, "fALSE")]
[InlineData(false, "true")]
public void LoadPackageSources_ReadsSourcesWithNotNullDisableTLSCertificateVerificationFromPackageSourceSections_LoadsValue(bool useStaticMethod, string disableTLSCertificateValidation)
[InlineData("true")]
[InlineData("TRUE")]
[InlineData("false")]
[InlineData("fALSE")]
public void LoadPackageSources_ReadsSourcesWithNotNullDisableTLSCertificateVerificationFromPackageSourceSections_LoadsValue(string disableTLSCertificateValidation)
{
// Arrange
var settings = new Mock<ISettings>();
Expand All @@ -961,7 +955,7 @@ public void LoadPackageSources_ReadsSourcesWithNotNullDisableTLSCertificateVerif
.Returns(new List<string>());

// Act
List<PackageSource> values = LoadPackageSources(useStaticMethod, settings.Object);
List<PackageSource> values = LoadPackageSources(settings.Object);

// Assert
var loadedSource = values.Single();
Expand Down

0 comments on commit 1819d4e

Please sign in to comment.