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

Allow insecure requests on debug builds via OSU_INSECURE_REQUESTS environment variable #6283

Merged
merged 8 commits into from
May 15, 2024

Conversation

smoogipoo
Copy link
Contributor

@smoogipoo smoogipoo commented May 13, 2024

  • Adds the environment variable (OSU_INSECURE_REQUESTS).
  • WebRequest.AllowInsecureRequests updated to act as an override of the environment variable.
  • Added validation to OnlineStore.GetAsync(). This existed originally but was removed and incorrectly reverted at some point. Can't seem to pinpoint the exact commit where this happened.
  • Adjusted OnlineStore to check for either http or http schemes. Added tests.

WIki entry: https://github.com/ppy/osu-framework/wiki/Environment-variables#osu_insecure_requests

Odd case that Rider misses.
Comment on lines +33 to +39
host = "127.0.0.1:8080";
protocols = new[] { default_protocol };
}
else
{
host = "httpbin.org";
protocols = new[] { default_protocol, "https" };
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

This feels a bit weird no?

... like I'd have to check how the tests are being run as to whether this is getting full test coverage or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is copied from TestWebRequest, so I can't provide much other than this is how it's been done so far. Do you have any suggestions?

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I tried changing this to skip the "https" tests rather than not list them at all, but it's only marginally better. I don't have any better ideas so let's let this one pass.

byte[]? result = store.Get(null);
Assert.That(result, Is.Null);
}
}
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I'd hope for test coverage of file:// not working.

@smoogipoo
Copy link
Contributor Author

Goes without saying but hold off on merging this. The linux test is weird and suffers from DebugUtils being referenced slightly too early 🫢

With the way the test runner works, this attribute ends up calling into
FrameworkEnvironment during test _discovery_. At this point, the
"currently executing test" is an adhoc test internal to NUnit, leading
`DebugUtils.NUnitTestAssembly` to discover the incorrect assembly.
@smoogipoo
Copy link
Contributor Author

I did not mean to force push...

In this test, the web request triggers an exception which should be
correctly caught by the store methods.
@smoogipoo
Copy link
Contributor Author

c035127 should fix the Release-mode test on Linux, but consider it a bit of an RFC. The main purpose is to delay poking FrameworkEnvironment until it's actually needed.

The commit message contains an explanation of why it was done.

@peppy peppy self-requested a review May 15, 2024 23:49
@peppy peppy merged commit 3e8a5fc into ppy:master May 15, 2024
21 checks passed
@peppy peppy self-requested a review May 15, 2024 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants