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

Do not warn http sources in search/list scenarios when allowInsecureConnections is set to true. #5371

Conversation

heng-liu
Copy link
Contributor

@heng-liu heng-liu commented Aug 22, 2023

Bug

Fixes: NuGet/Home#12790

Regression? Last working version:

Description

When allowInsecureConnections property in packageSources section is set to true in NuGet.Config files, do not warn for HTTP sources in search/list scenarios.

The PRs enable the HTTP warnings in those scenarios are:
#4629
#4628

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

    • Documentation PR or issue filled
    • OR
    • N/A

@heng-liu heng-liu marked this pull request as ready for review August 22, 2023 21:04
@heng-liu heng-liu requested a review from a team as a code owner August 22, 2023 21:04
@@ -1169,6 +1170,65 @@ public void ListCommand_WhenListWithHttpSource_Warns()
Assert.Contains("WARNING: You are running the 'list' operation with an 'HTTP' source", result.AllOutput);
}

[PlatformTheory(Platform.Windows)]
Copy link
Member

Choose a reason for hiding this comment

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

Similar feedback as the other PR: #5363.
Checking for false is really just checking the parsing in the settings. We probably don't need those.
Both tests have the same concern.

Rest looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @nkolev92 for reviewing!
I think having both true and false in the same test looks more clear, as there is a contrast and it proves the flag works correctly.
To avoid testing duplicate scenarios, how about removing the ListCommand_WhenListWithHttpSource_Warns? As it tests null AllowInsecureConnections, which is the same with false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed three tests which tests the null AllowInsecureConnections and kept the three false AllowInsecureConnections tests.

@heng-liu heng-liu requested a review from nkolev92 August 24, 2023 20:11
Util.CreateFile(packageDirectory, "nuget.config", $@"
<configuration>
<packageSources>
<add key='http-feed' value='{server.Uri}nuget' allowInsecureConnections=""{allowInsecureConnections}"" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Do we have any tests where we validate that the absence of this attributes results in warnings for http connections?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reviewing @aortiz-msft !
There used to be a ListCommand_WhenListWithHttpSource_Warns test, testing the absence of this attributes results in http warning.
But I just removed it in this PR, to address this comment .
Since the default value of allowInsecureConnections is false, absence of this attributes is the same with setting it to false.

Copy link
Member

Choose a reason for hiding this comment

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

In other words, yes we have a test that validates the absence of the attribute results in the default value:

Assert.Equal(PackageSource.DefaultAllowInsecureConnections, loadedSource.AllowInsecureConnections);

@@ -1099,7 +1106,21 @@ public void SearchCommand_WhenSearchWithHttpSources_Warns()
Assert.True(result.Success, $"{result.AllOutput}");
Assert.Contains("No results found.", $"{result.AllOutput}");
Assert.DoesNotContain(">", $"{result.AllOutput}");
Assert.Contains("WARNING: You are running the 'search' operation with an 'HTTP' source", result.AllOutput);

string acutalOutputWithoutSpace = SettingsTestUtils.RemoveWhitespace(result.Output);
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: acutal should be actual

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry! Fixed the typo just now.

@heng-liu
Copy link
Contributor Author

Hi @nkolev92 @zivkan , could you take another look? Thanks!

@heng-liu heng-liu merged commit 74ccbc3 into dev-feature-optoutHttpWarnings Aug 28, 2023
@heng-liu heng-liu deleted the dev-hengliu-optoutHttpWarnings-searchList branch August 28, 2023 16:42
heng-liu added a commit that referenced this pull request Aug 28, 2023
heng-liu added a commit that referenced this pull request Sep 8, 2023
heng-liu added a commit that referenced this pull request Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants