Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate http usage: restore scenarios promote warning to error for http sources #5731

Merged

Conversation

Nigusu-Allehu
Copy link
Contributor

@Nigusu-Allehu Nigusu-Allehu commented Mar 27, 2024

Bug

Fixes: NuGet/Home#13353

Regression? Last working version:

Description

Promote http source usage warnings in restore scenarios to errors.

PR Checklist

  • PR has a meaningful title

  • PR has a linked issue.

  • Described changes

  • Tests

    • Automated tests added
    • OR
    • Test exception
    • OR
    • N/A
  • Documentation

    https://github.com/Add documentation for NU1302  Home#13502
    • Documentation PR or issue filled
    • OR
    • N/A

@Nigusu-Allehu Nigusu-Allehu self-assigned this Mar 27, 2024
@Nigusu-Allehu Nigusu-Allehu requested a review from a team as a code owner March 27, 2024 18:22
@Nigusu-Allehu Nigusu-Allehu changed the title Deprecate http usage: nuget push promote warning to error for http sources Deprecate http usage: restore scenarios promote warning to error for http sources Mar 27, 2024
@Nigusu-Allehu Nigusu-Allehu force-pushed the dev-nyenework-http-error-restore branch from d2054fb to 1fbf7b3 Compare April 17, 2024 17:42
@Nigusu-Allehu Nigusu-Allehu changed the title Deprecate http usage: restore scenarios promote warning to error for http sources Deprecate http usage: restore / install scenarios promote warning to error for http sources Apr 19, 2024
Copy link
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the slow turnaround.
Product changes look good.

Some test questions.

@Nigusu-Allehu Nigusu-Allehu changed the title Deprecate http usage: restore / install scenarios promote warning to error for http sources Deprecate http usage: restore scenarios promote warning to error for http sources Apr 25, 2024
Assert.Contains($"Added package 'A.1.0.0' to folder '{projectBPackages}'", result.Output);
Assert.DoesNotContain(warningForHttpsSource, result.Output);
if (hasHttpWarning)
Assert.DoesNotContain(errorForHttpsSource, result.AllOutput);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of asserting a missing error, why can't this depend on result.Success.Should().BeTrue() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I have seen, it is possible for the restore command runner to log an error and still exit code of 0. This is just making sure that is not happening and this error is not logged.

@@ -66,7 +66,7 @@ public async Task FeedPackagePruning_GivenThatAV3FeedPrunesAPackageDuringRestore
server.Start();

var feedUrl = server.Uri + "index.json";

pathContext.Settings.AddSource(feedUrl, feedUrl, allowInsecureConnectionsValue: "true");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a tracking issue to change all the test dependencies to use HTTPS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I think that is a good point.

@dotnet-policy-service dotnet-policy-service bot added the Status:No recent activity No recent activity. label May 6, 2024
<configuration>
<packageSources>
<clear />
<add key=""http-feed"" value=""{source}"" allowInsecureConnections=""true""/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like allowInsecureConnections setting can also be configured through an environment variable. I guess we need a test to verify that behavior as well. I am okay with addressing this comment in a follow up pull-request.

https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Configuration/Settings/Items/SourceItem.cs#L24-L36

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to setting the config file as follows

<packageSources>
    <clear />    
    <add key="source" value="http://source" allowInsecureConnections="${Allow_Insecure_Connection_Value}" />
</packageSources>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are correct Nigusu. However, environment variable syntax is a bit different as I explained below. NuGet uses Environment.ExpandEnvironment .NET API internally.

<packageSources>
    <clear />    
    <add key="source" value="http://source" allowInsecureConnections="%AllowInsecureConnectionValue%" />
</packageSources>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to address this comment in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't env var vs a nuget.config value stylistic?
What's the benefit of the env var over the nguet.config.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of any benefit with the environment variable for this setting. I added the comment because currently code expands environment variable for this setting also. May be we could remove the environment variable support for this setting because it doesn't add much value to the users.

@dotnet-policy-service dotnet-policy-service bot removed the Status:No recent activity No recent activity. label May 6, 2024
@Nigusu-Allehu
Copy link
Contributor Author

@NuGet/nuget-client Any suggestions?

@Nigusu-Allehu Nigusu-Allehu merged commit 079b9ea into dev-feature-http-error May 9, 2024
12 of 16 checks passed
@Nigusu-Allehu Nigusu-Allehu deleted the dev-nyenework-http-error-restore branch May 9, 2024 22:02
Nigusu-Allehu added a commit that referenced this pull request May 22, 2024
Nigusu-Allehu added a commit that referenced this pull request May 22, 2024
Nigusu-Allehu added a commit that referenced this pull request May 22, 2024
Nigusu-Allehu added a commit that referenced this pull request May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants