Skip to content

Conversation

@duanemay
Copy link
Member

@duanemay duanemay commented Dec 5, 2025

relax url matching for differences in different environments

Copilot AI review requested due to automatic review settings December 5, 2025 15:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR relaxes the URL matching assertion in the notAutoLoginAfterResetPassword test to accommodate different environment configurations. However, the change introduces significant security and validation concerns.

Key Change:

  • Modified URL assertion from startsWith("https://example.redirect.com/?code=") to contains("://example.redirect.com/?code=")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

webDriver.clickAndWait(By.xpath("//input[@value='Sign in']"));

assertThat(webDriver.getCurrentUrl()).startsWith("https://example.redirect.com/?code=");
assertThat(webDriver.getCurrentUrl()).contains("://example.redirect.com/?code=");
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The change from startsWith("https://example.redirect.com/?code=") to contains("://example.redirect.com/?code=") weakens the assertion in a potentially problematic way:

  1. Protocol validation is removed: The original assertion enforced HTTPS, which is critical for OAuth authorization codes to prevent man-in-the-middle attacks. The new assertion allows HTTP or any other protocol.

  2. URL structure validation is weakened: The original startsWith ensures the redirect URL begins with the expected pattern. The new contains could match URLs like http://malicious.com?next=http://example.redirect.com/?code= where the legitimate redirect is embedded elsewhere in the URL.

If the goal is to handle different environments (http in dev/test, https in production), consider a more specific assertion like:

assertThat(webDriver.getCurrentUrl()).matches("^https?://example\\.redirect\\.com/\\?code=.*");

This maintains validation that the URL starts with the expected host while allowing both protocols.

Suggested change
assertThat(webDriver.getCurrentUrl()).contains("://example.redirect.com/?code=");
assertThat(webDriver.getCurrentUrl()).matches("^https?://example\\.redirect\\.com/\\?code=.*");

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

I like this

strehle
strehle previously approved these changes Dec 10, 2025
Copy link
Member

@strehle strehle left a comment

Choose a reason for hiding this comment

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

I would use copilt suggestions but you can decide

@github-project-automation github-project-automation bot moved this from Inbox to Pending Merge | Prioritized in Foundational Infrastructure Working Group Dec 10, 2025
@fhanik fhanik merged commit a45039b into develop Dec 11, 2025
26 checks passed
@fhanik fhanik deleted the reset_pass_it branch December 11, 2025 14:06
@github-project-automation github-project-automation bot moved this from Pending Merge | Prioritized to Done in Foundational Infrastructure Working Group Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants