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

Use HTTPS in test.com test URL #8338

Draft
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Draft

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Dec 7, 2022

Description

I got a runtime warning when running the unit tests:

image

Testing instructions

If CI is green we're good. This can be further verified by running the unit tests locally and verifying there's no warning about test.com


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

I noticed a runtime warning in the Wormholy library:

> App Transport Security has blocked a cleartext HTTP connection
> totest.comsince [sic] it is insecure. Use HTTPS instead or add this domain
> to Exception Domains in your Info.plist.
@mokagio mokagio force-pushed the mokagio/use-https-for-test-site branch from ce85caf to 56cb936 Compare December 7, 2022 19:23
@@ -6,6 +6,9 @@ import Yosemite

/// Test cases for `AuthenticationManager`.
final class AuthenticationManagerTests: XCTestCase {

let testSiteURL = "https://test.com"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

DRYed the value while at it.

DRYing literals in unit tests can sometimes backfire because it reduces readability, or rather how expressive the tests are.

In this case, though, the URL is not used in any assertion so there's no loss of clarity.

@mokagio mokagio marked this pull request as ready for review December 7, 2022 19:27
@wpmobilebot
Copy link
Collaborator

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr8338-56cb936 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

Copy link
Contributor

@crazytonyli crazytonyli left a comment

Choose a reason for hiding this comment

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

I'm curious did you happen to check which test case(s) visited the test.com URL, and should it be doing that during unit test (I'm guessing no?)?

@mokagio
Copy link
Contributor Author

mokagio commented Dec 8, 2022

I'm curious did you happen to check which test case(s) visited the test.com URL...

I didn't drill into them, but they are all in the diff. Meaning the code that I changed were the tests cases hitting test.com themselves

..., and should it be doing that during unit test (I'm guessing no?)?

I'm guessing no, too. This might be something we should research further, e.g. by running the tests with the network off.

Or, given the warning originated from Wormholy, which is a network debugging library, maybe that's expected? Although, I think the two things might be unrelated—Wormholy was hit, but that, too, was an oversight in a test that should have been configured to bypass the network altogether.

cc @pmusolino as Wormholy's author and WooCommerce contributor.

Comment on lines 210 to +213
func test_it_can_display_jetpack_error_for_org_site_credentials_sign_in() {
// Given
let manager = AuthenticationManager()
let testSite = "http://test.com"
let siteInfo = WordPressComSiteInfo(remote: ["isWordPress": true, "hasJetpack": false, "urlAfterRedirects": testSite])
let siteInfo = WordPressComSiteInfo(remote: ["isWordPress": true, "hasJetpack": false, "urlAfterRedirects": testSiteURL])
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 test failed 2 out of 2 times in CI 🤔

Maybe there's more work I need to do. Reverting to draft.

@mokagio mokagio marked this pull request as draft December 8, 2022 12:18
@crazytonyli
Copy link
Contributor

I didn't drill into them, but they are all in the diff. Meaning the code that I changed were the tests cases hitting test.com themselves

Ooh, I might've misread the code. I thought not all of them actually send HTTP request to the site URL, like some may just need a URL string to create a type or call a function.

I was more curious if your observation here exposed a potentially overlooked test set up, like missing a stub for this test.com HTTP request. However, IMO, even if it's an overlook, it's probably okay not to stub the request as it's not affecting the test case obviously.

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.

None yet

3 participants