-
Notifications
You must be signed in to change notification settings - Fork 0
fix/base-url-scheme-0.1.1 #49
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
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Changelog | ||
|
|
||
| ## 0.1.1 — 2025-09-13 | ||
|
|
||
| ### Highlights | ||
| - Fixes “URI with undefined scheme” when `phoenixd.base_url` lacks an HTTP scheme by defaulting to `http://`. | ||
| - Centralizes configuration via shared `Configuration` util (env vars take precedence over `app.properties`). | ||
|
|
||
| ### Changes | ||
| - fix: normalize base_url scheme and use shared Configuration | ||
| - F:phoenixd-rest/src/main/java/xyz/tcheeric/phoenixd/operation/AbstractOperation.java | ||
| - F:phoenixd-rest/src/test/java/xyz/tcheeric/phoenixd/operation/BaseUrlNormalizationTest.java | ||
| - F:phoenixd-test/src/test/java/xyz/tcheeric/phoenixd/test/TestUtils.java | ||
| - docs: document scheme defaulting for `phoenixd.base_url` | ||
| - F:docs/reference/configuration.md | ||
| - build: bump version to 0.1.1 | ||
| - F:pom.xml | ||
| - F:phoenixd-rest/pom.xml | ||
| - F:phoenixd-test/pom.xml | ||
| - F:phoenixd-base/pom.xml | ||
| - F:phoenixd-model/pom.xml | ||
| - F:phoenixd-mock/pom.xml | ||
|
|
||
| ### Behavior Notes | ||
| - `phoenixd.base_url` without a scheme now resolves as `http://...`. | ||
| - If `phoenixd.base_url` is unset or blank, an `IllegalArgumentException` is thrown during request construction. | ||
|
|
||
| ### Configuration | ||
| - Env vars (preferred): `PHOENIXD_USERNAME`, `PHOENIXD_PASSWORD`, `PHOENIXD_BASE_URL`, `PHOENIXD_TIMEOUT`. | ||
| - Or `app.properties` on the classpath with `phoenixd.username`, `phoenixd.password`, `phoenixd.base_url`, `phoenixd.timeout`. | ||
|
|
||
| ### Testing | ||
| - Command: `mvn -q verify` | ||
| - Note: In restricted sandboxes, tests that open loopback sockets (MockWebServer) may fail with `SocketException: Operation not permitted`. In a normal dev/CI environment, the test suite is expected to pass. | ||
|
|
||
| ### API Changes | ||
| - None. | ||
|
|
||
| ### Security | ||
| - No new dependencies; no changes to security-sensitive logic. | ||
|
|
||
| ### Migration | ||
| - No breaking changes. If you relied on rejecting schemeless base URLs, be aware they now default to `http://`. | ||
|
|
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
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
28 changes: 28 additions & 0 deletions
28
phoenixd-rest/src/test/java/xyz/tcheeric/phoenixd/operation/BaseUrlNormalizationTest.java
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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package xyz.tcheeric.phoenixd.operation; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import xyz.tcheeric.phoenixd.common.rest.util.Configuration; | ||
| import xyz.tcheeric.phoenixd.operation.impl.PostOperation; | ||
|
|
||
| import java.lang.reflect.Field; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| public class BaseUrlNormalizationTest { | ||
|
|
||
| // Verifies base_url without scheme defaults to http | ||
| @Test | ||
| void baseUrlWithoutSchemeDefaultsToHttp() throws Exception { | ||
| Field configField = AbstractOperation.class.getDeclaredField("CONFIG"); | ||
| configField.setAccessible(true); | ||
| Configuration cfg = (Configuration) configField.get(null); | ||
| cfg.getProperties().setProperty("phoenixd.base_url", "localhost:9999"); | ||
| cfg.getProperties().setProperty("phoenixd.username", "user"); | ||
| cfg.getProperties().setProperty("phoenixd.password", "pass"); | ||
|
|
||
| PostOperation op = new PostOperation("/items", "data"); | ||
| assertThat(op.getHttpRequest().uri().getScheme()).isEqualTo("http"); | ||
| assertThat(op.getHttpRequest().uri().toString()).isEqualTo("http://localhost:9999/items"); | ||
| } | ||
| } | ||
|
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Preserve base URL paths when resolving request URIs
The new
buildUrialways prefixes the supplied path with/and feeds it toURI.create(normalizedBase).resolve(normalizedPath). For base URLs that include a non-root path likehttps://example.com/api,resolve("/items")discards the/apiprefix and produceshttps://example.com/items, whereas the previousbaseUrl + pathconcatenation correctly yieldedhttps://example.com/api/items. Deployments that rely on a path segment inphoenixd.base_urlwill now send every request to the wrong endpoint. Consider resolving a relative path (without the leading slash) or concatenating after normalizing the scheme so the base path is preserved.Useful? React with 👍 / 👎.