Skip to content

Commit

Permalink
fix: Relax downloadRecording validation
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Dec 19, 2024
1 parent 8a93a6c commit a689f6d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
src/test/resources/com/vonage/client/test/keys/application_key binary
src/test/resources/com/vonage/client/test/keys/application_key2 binary
src/test/resources/com/vonage/client/test/keys/application_key2 binary
*.sh linguist-vendored
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

# [8.15.1] - 2024-12-19
- Removed hardcoded domain validation from `VoiceClient.downloadRecordingRaw`

# [8.15.0] - 2024-12-03
- Added proxy support to `HttpConfig.Builder`
- Basic auth in header instead of query params in SMS API
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.vonage</groupId>
<artifactId>server-sdk</artifactId>
<version>8.15.0</version>
<version>8.15.1</version>

<name>Vonage Java Server SDK</name>
<description>Java client for Vonage APIs</description>
Expand Down Expand Up @@ -86,7 +86,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.11.3</version>
<version>5.11.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -228,7 +228,7 @@

<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.1</version>
<version>3.11.2</version>
<configuration>
<linksource>true</linksource>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/vonage/client/HttpWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class HttpWrapper {
private static final String
CLIENT_NAME = "vonage-java-sdk",
CLIENT_VERSION = "8.15.0",
CLIENT_VERSION = "8.15.1",
JAVA_VERSION = System.getProperty("java.version"),
USER_AGENT = String.format("%s/%s java/%s", CLIENT_NAME, CLIENT_VERSION, JAVA_VERSION);

Expand Down
7 changes: 1 addition & 6 deletions src/main/java/com/vonage/client/voice/VoiceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,7 @@ public void removeDtmfListener(String uuid) throws VoiceResponseException {
* @since 7.11.0
*/
public byte[] downloadRecordingRaw(String recordingUrl) {
if (validateUrl(recordingUrl).contains(".nexmo.com/v1/files")) {
return downloadRecording.execute(recordingUrl);
}
else {
throw new IllegalArgumentException("Invalid recording URL");
}
return downloadRecording.execute(validateUrl(recordingUrl));
}

/**
Expand Down
16 changes: 2 additions & 14 deletions src/test/java/com/vonage/client/voice/VoiceClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public void testDownloadRecording() throws Exception {
String recordingId = UUID.randomUUID().toString();
String content = "<BINARY>";
stubResponse(200, content);
String url = "https://api.nexmo.com/v1/files/" + recordingId;
String url = "https://api-eu.vonage.com/v1/files/" + recordingId;
Path temp = Files.createTempFile(null, null);
Files.delete(temp);

Expand All @@ -421,24 +421,12 @@ public void testDownloadRecording() throws Exception {
assertTrue(Files.exists(recordingPath));
assertArrayEquals(content.getBytes(), Files.readAllBytes(recordingPath));

stubResponseAndAssertThrows(content, () ->
client.saveRecording("ftp:///myserver.co.uk/rec.mp3", recordingPath),
IllegalArgumentException.class
);
stubResponseAndAssertThrows(content, () ->
client.saveRecording("http://example.org/recording.wav", recordingPath),
IllegalArgumentException.class
);
stubResponseAndAssertThrows(content, () ->
client.saveRecording("https://example.org/recording.wav", recordingPath),
IllegalArgumentException.class
);
stubResponseAndAssertThrows(content, () ->
client.saveRecording(url, null),
NullPointerException.class
);
stubResponseAndAssertThrows(content, () ->
client.saveRecording("not-a-url", recordingPath),
client.saveRecording(";not_a url£", recordingPath),
IllegalArgumentException.class
);
}
Expand Down

0 comments on commit a689f6d

Please sign in to comment.