-
Notifications
You must be signed in to change notification settings - Fork 841
[TNZ-27070]: Fix UAA on standard ports #3621
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a73f11c
[TNZ-27070]: Fix UAA on standard ports with mismatching Location and …
joemahady-comm a01150e
[TNZ-27070]: Fix UAA on standard ports
joemahady-comm c00cc04
[TNZ-27070]: Tidy code
joemahady-comm 8a87453
[TNZ-27070]: Clean up code
joemahady-comm a987d14
[TNZ-27070]: refactor tests after review
joemahady-comm 2c5b35c
[TNZ-27070]: refactor tests
joemahady-comm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.fail; | ||
| import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; | ||
| import static org.cloudfoundry.identity.uaa.util.UaaUrlUtils.normalizeUrlForPortComparison; | ||
| import static org.mockito.Mockito.mock; | ||
|
|
||
| @ExtendWith(PollutionPreventionExtension.class) | ||
|
|
@@ -710,4 +711,54 @@ private static Map<String, String> getUnsuccessfulUrls(List<String> urls, boolea | |
| private static List<String> convertToHttps(List<String> urls) { | ||
| return urls.stream().map(url -> url.replace("http:", "https:")).toList(); | ||
| } | ||
|
|
||
joemahady-comm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Tests for normalizeUrlForPortComparison method | ||
| @ParameterizedTest(name = "normalizeUrlForPortComparison: \"{0}\" should become \"{1}\"") | ||
| @CsvSource({ | ||
| // Standard port removal | ||
| "'http://example.com:80/path', 'http://example.com/path'", | ||
| "'https://example.com:443/path', 'https://example.com/path'", | ||
|
|
||
| // Non-standard ports preserved | ||
| "'http://example.com:8080/path', 'http://example.com:8080/path'", | ||
| "'https://example.com:8443/path', 'https://example.com:8443/path'", | ||
|
|
||
| // URLs without explicit ports remain unchanged | ||
| "'http://example.com/path', 'http://example.com/path'", | ||
| "'https://example.com/path', 'https://example.com/path'", | ||
|
|
||
| // Query parameters and fragments preserved | ||
| "'http://example.com:80/path?param1=value1¶m2=value2', 'http://example.com/path?param1=value1¶m2=value2'", | ||
| "'https://example.com:443/path#section1', 'https://example.com/path#section1'", | ||
|
|
||
| // Complex URLs with user info | ||
| "'http://user:[email protected]:80/path/to/resource?query=value#fragment', 'http://user:[email protected]/path/to/resource?query=value#fragment'", | ||
|
|
||
| // Subdomains preserved | ||
| "'https://subdomain.example.com:443/path', 'https://subdomain.example.com/path'", | ||
|
|
||
| // Different schemes keep non-standard ports | ||
| "'ftp://example.com:80/path', 'ftp://example.com:80/path'", | ||
|
|
||
| // SAML-specific URL | ||
| "'https://uaa.example.com:443/saml/SSO/alias/provider-name?RelayState=https://app.example.com¶m=value#section', 'https://uaa.example.com/saml/SSO/alias/provider-name?RelayState=https://app.example.com¶m=value#section'", | ||
|
|
||
| // Malformed URLs return unchanged | ||
| "'not-a-valid-url', 'not-a-valid-url'", | ||
| "'http://[invalid:url:with:colons:everywhere', 'http://[invalid:url:with:colons:everywhere'", | ||
| "'http://example.com:80/path with spaces and special chars!@#$%^&*()', 'http://example.com:80/path with spaces and special chars!@#$%^&*()'", | ||
|
|
||
| // Empty string | ||
| "'', ''" | ||
| }) | ||
| void normalizeUrlForPortComparison_parameterizedTests(String inputUrl, String expectedUrl) { | ||
| String result = normalizeUrlForPortComparison(inputUrl); | ||
| assertThat(result).isNotNull().isEqualTo(expectedUrl); // Ensure we never return null for non-null input | ||
| } | ||
|
|
||
| @Test | ||
| void normalizeUrlForPortComparison_withNullUrl_returnsNull() { | ||
| String result = normalizeUrlForPortComparison(null); | ||
| assertThat(result).isNull(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.