Skip to content

Commit

Permalink
Remove check for AbsoluteUri from startRecording (Azure#33850)
Browse files Browse the repository at this point in the history
* Remove check for AbsoluteUri from startRecording

* Remove unused import

* Remove unused import

* Remove unused import

---------

Co-authored-by: fariba haghbin <[email protected]>
  • Loading branch information
fhaghbin-msft and fariba625 authored Mar 30, 2023
1 parent 20df5af commit 0fa61e1
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousFileChannel;
Expand Down Expand Up @@ -115,10 +113,6 @@ public Mono<Response<RecordingStateResult>> startRecordingWithResponse(StartReco

Mono<Response<RecordingStateResult>> startRecordingWithResponseInternal(StartRecordingOptions options, Context context) {
try {
String callbackUrl = options.getRecordingStateCallbackUrl();
if (callbackUrl != null && !callbackUrl.isEmpty() && !Boolean.TRUE.equals(new URI(callbackUrl).isAbsolute())) {
throw logger.logExceptionAsError(new InvalidParameterException("'recordingStateCallbackUri' has to be an absolute Uri"));
}
StartCallRecordingRequestInternal request = getStartCallRecordingRequest(options);

return withContext(contextValue -> {
Expand All @@ -134,8 +128,6 @@ Mono<Response<RecordingStateResult>> startRecordingWithResponseInternal(StartRec
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
} catch (URISyntaxException ex) {
return monoError(logger, new RuntimeException(ex));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,16 @@
package com.azure.communication.callautomation;

import com.azure.communication.callautomation.models.CallingServerErrorException;
import com.azure.communication.callautomation.models.RecordingChannel;
import com.azure.communication.callautomation.models.RecordingContent;
import com.azure.communication.callautomation.models.RecordingFormat;
import com.azure.communication.callautomation.models.RecordingState;
import com.azure.communication.callautomation.models.RecordingStateResult;
import com.azure.communication.callautomation.models.ServerCallLocator;
import com.azure.communication.callautomation.models.StartRecordingOptions;
import com.azure.communication.common.CommunicationIdentifier;
import com.azure.communication.common.CommunicationUserIdentifier;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.reactivestreams.Publisher;
import reactor.test.StepVerifier;

import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -33,28 +26,6 @@ public void setup() {
callRecording = callingServerClient.getCallRecordingAsync();
}

@Test
public void startRecordingRelativeUriFails() {
validateError(InvalidParameterException.class,
callRecording.startRecording(new StartRecordingOptions(new ServerCallLocator(SERVER_CALL_ID))
.setRecordingStateCallbackUrl("/not/absolute/uri")
));
}

@Test
public void startRecordingWithFullParamsFails() {
StartRecordingOptions startRecordingOptions = new StartRecordingOptions(new ServerCallLocator(SERVER_CALL_ID))
.setRecordingContent(RecordingContent.AUDIO_VIDEO)
.setRecordingChannel(RecordingChannel.MIXED)
.setRecordingFormat(RecordingFormat.MP4)
.setRecordingStateCallbackUrl("/not/absolute/uri")
.setAudioChannelParticipantOrdering(new ArrayList<CommunicationIdentifier>(Arrays.asList(
new CommunicationUserIdentifier("rawId1"),
new CommunicationUserIdentifier("rawId2"))));

validateError(InvalidParameterException.class, callRecording.startRecordingWithResponse(startRecordingOptions));
}

@Test
public void recordingOperationsTest() {
CallAutomationAsyncClient callingServerClient = CallAutomationUnitTestBase.getCallAutomationAsyncClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,14 @@
package com.azure.communication.callautomation;

import com.azure.communication.callautomation.models.CallingServerErrorException;
import com.azure.communication.callautomation.models.RecordingChannel;
import com.azure.communication.callautomation.models.RecordingContent;
import com.azure.communication.callautomation.models.RecordingFormat;
import com.azure.communication.callautomation.models.RecordingState;
import com.azure.communication.callautomation.models.RecordingStateResult;
import com.azure.communication.callautomation.models.ServerCallLocator;
import com.azure.communication.callautomation.models.StartRecordingOptions;
import com.azure.communication.common.CommunicationIdentifier;
import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.core.util.Context;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand All @@ -32,31 +24,6 @@ public void setup() {
CallAutomationClient callAutomationClient = CallAutomationUnitTestBase.getCallAutomationClient(new ArrayList<>());
callRecording = callAutomationClient.getCallRecording();
}
@Test
public void startRecordingRelativeUriFails() {
assertThrows(
InvalidParameterException.class,
() -> callRecording.startRecording(new StartRecordingOptions(new ServerCallLocator(SERVER_CALL_ID))
.setRecordingStateCallbackUrl("/not/absolute/uri")
));
}

@Test
public void startRecordingWithFullParamsFails() {
StartRecordingOptions startRecordingOptions = new StartRecordingOptions(new ServerCallLocator(SERVER_CALL_ID))
.setRecordingContent(RecordingContent.AUDIO_VIDEO)
.setRecordingChannel(RecordingChannel.MIXED)
.setRecordingFormat(RecordingFormat.MP4)
.setRecordingStateCallbackUrl("/not/absolute/uri")
.setAudioChannelParticipantOrdering(new ArrayList<CommunicationIdentifier>(Arrays.asList(
new CommunicationUserIdentifier("rawId1"),
new CommunicationUserIdentifier("rawId2"))));

assertThrows(
InvalidParameterException.class,
() -> callRecording.startRecordingWithResponse(startRecordingOptions, Context.NONE)
);
}

@Test
public void recordingOperationsTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousFileChannel;
Expand Down Expand Up @@ -114,10 +112,6 @@ public Mono<Response<RecordingStateResult>> startRecordingWithResponse(StartReco

Mono<Response<RecordingStateResult>> startRecordingWithResponseInternal(StartRecordingOptions options, Context context) {
try {
String callbackUrl = options.getRecordingStateCallbackUrl();
if (callbackUrl != null && !callbackUrl.isEmpty() && !Boolean.TRUE.equals(new URI(callbackUrl).isAbsolute())) {
throw logger.logExceptionAsError(new InvalidParameterException("'recordingStateCallbackUri' has to be an absolute Uri"));
}
StartCallRecordingRequestInternal request = getStartCallRecordingRequest(options);

return withContext(contextValue -> {
Expand All @@ -131,8 +125,6 @@ Mono<Response<RecordingStateResult>> startRecordingWithResponseInternal(StartRec
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
} catch (URISyntaxException ex) {
return monoError(logger, new RuntimeException(ex));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,16 @@
package com.azure.communication.callingserver;

import com.azure.communication.callingserver.models.CallingServerErrorException;
import com.azure.communication.callingserver.models.ChannelAffinity;
import com.azure.communication.callingserver.models.RecordingChannel;
import com.azure.communication.callingserver.models.RecordingContent;
import com.azure.communication.callingserver.models.RecordingFormat;
import com.azure.communication.callingserver.models.RecordingState;
import com.azure.communication.callingserver.models.RecordingStateResult;
import com.azure.communication.callingserver.models.ServerCallLocator;
import com.azure.communication.callingserver.models.StartRecordingOptions;
import com.azure.communication.common.CommunicationUserIdentifier;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.reactivestreams.Publisher;
import reactor.test.StepVerifier;

import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -33,28 +26,6 @@ public void setup() {
callRecording = callingServerClient.getCallRecordingAsync();
}

@Test
public void startRecordingRelativeUriFails() {
validateError(InvalidParameterException.class,
callRecording.startRecording(new StartRecordingOptions(new ServerCallLocator(SERVER_CALL_ID))
.setRecordingStateCallbackUrl("/not/absolute/uri")
));
}

@Test
public void startRecordingWithFullParamsFails() {
StartRecordingOptions startRecordingOptions = new StartRecordingOptions(new ServerCallLocator(SERVER_CALL_ID))
.setRecordingContent(RecordingContent.AUDIO_VIDEO)
.setRecordingChannel(RecordingChannel.MIXED)
.setRecordingFormat(RecordingFormat.MP4)
.setRecordingStateCallbackUrl("/not/absolute/uri")
.setChannelAffinity(new ArrayList<ChannelAffinity>(Arrays.asList(
new ChannelAffinity(0, new CommunicationUserIdentifier("rawId1")),
new ChannelAffinity(1, new CommunicationUserIdentifier("rawId2")))));

validateError(InvalidParameterException.class, callRecording.startRecordingWithResponse(startRecordingOptions));
}

@Test
public void recordingOperationsTest() {
CallAutomationAsyncClient callingServerClient = CallAutomationUnitTestBase.getCallAutomationAsyncClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,14 @@
package com.azure.communication.callingserver;

import com.azure.communication.callingserver.models.CallingServerErrorException;
import com.azure.communication.callingserver.models.ChannelAffinity;
import com.azure.communication.callingserver.models.RecordingChannel;
import com.azure.communication.callingserver.models.RecordingContent;
import com.azure.communication.callingserver.models.RecordingFormat;
import com.azure.communication.callingserver.models.RecordingState;
import com.azure.communication.callingserver.models.RecordingStateResult;
import com.azure.communication.callingserver.models.ServerCallLocator;
import com.azure.communication.callingserver.models.StartRecordingOptions;
import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.core.util.Context;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand All @@ -32,31 +24,6 @@ public void setup() {
CallAutomationClient callAutomationClient = CallAutomationUnitTestBase.getCallAutomationClient(new ArrayList<>());
callRecording = callAutomationClient.getCallRecording();
}
@Test
public void startRecordingRelativeUriFails() {
assertThrows(
InvalidParameterException.class,
() -> callRecording.startRecording(new StartRecordingOptions(new ServerCallLocator(SERVER_CALL_ID))
.setRecordingStateCallbackUrl("/not/absolute/uri")
));
}

@Test
public void startRecordingWithFullParamsFails() {
StartRecordingOptions startRecordingOptions = new StartRecordingOptions(new ServerCallLocator(SERVER_CALL_ID))
.setRecordingContent(RecordingContent.AUDIO_VIDEO)
.setRecordingChannel(RecordingChannel.MIXED)
.setRecordingFormat(RecordingFormat.MP4)
.setRecordingStateCallbackUrl("/not/absolute/uri")
.setChannelAffinity(new ArrayList<ChannelAffinity>(Arrays.asList(
new ChannelAffinity(0, new CommunicationUserIdentifier("rawId1")),
new ChannelAffinity(1, new CommunicationUserIdentifier("rawId2")))));

assertThrows(
InvalidParameterException.class,
() -> callRecording.startRecordingWithResponse(startRecordingOptions, Context.NONE)
);
}

@Test
public void recordingOperationsTest() {
Expand Down

0 comments on commit 0fa61e1

Please sign in to comment.