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

compatibility with zamzar-mock 0.0.13 #16

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
entrypoint: [ "/bin/sh", "-c", "sleep infinity" ]
environment:
- API_KEY=GiVUYsF4A8ssq93FR48H
- API_URL=http://mock:8080
- API_URL=http://mock:8080/v1
volumes:
- '.:/usr/src/zamzar-java'
working_dir: '/usr/src/zamzar-java'
Expand Down
12 changes: 9 additions & 3 deletions src/test/java/com/zamzar/api/ZamzarApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public abstract class ZamzarApiTest {

protected static final String API_URL = Optional.ofNullable(System.getenv("API_URL")).orElse("http://localhost:8080");
protected static final String API_URL = Optional.ofNullable(System.getenv("API_URL")).orElse("http://localhost:8080/v1");

protected static final String API_KEY = Optional.ofNullable(System.getenv("API_KEY")).orElse("GiVUYsF4A8ssq93FR48H");

Expand Down Expand Up @@ -65,8 +65,14 @@ public void clearGeneratedFiles() throws IOException {
public void resetZamzarMock() throws IOException {
// Construct the URL for to reset the mock
// See: https://github.com/zamzar/zamzar-mock/blob/main/README.md
final URL url = new URL(API_URL + "/__admin/scenarios/reset");
final HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
final URL baseUrl = new URL(API_URL);
final URL resetUrl = new URL(
baseUrl.getProtocol(),
baseUrl.getHost(),
baseUrl.getPort(),
"/__admin/scenarios/reset"
);
final HttpURLConnection httpURLConnection = (HttpURLConnection) resetUrl.openConnection();

httpURLConnection.setRequestMethod("POST");
httpURLConnection.setRequestProperty("Authorization", "Bearer " + API_KEY);
Expand Down