public async Task <IActionResult> AddEndpointToConsultationAsync(AddEndpointConsultationRequest request) { var conference = await GetConference(request.ConferenceId); var username = User.Identity.Name?.ToLower().Trim(); var requestedBy = conference.Participants.SingleOrDefault(x => x.Username.Trim().Equals(username, StringComparison.CurrentCultureIgnoreCase)); if (requestedBy == null) { return(Unauthorized("You must be a VHO or a member of the conference")); } try { await _consultationNotifier.NotifyConsultationResponseAsync(conference, request.RoomLabel, request.EndpointId, ConsultationAnswer.Transferring); await _videoApiClient.JoinEndpointToConsultationAsync(new EndpointConsultationRequest { ConferenceId = request.ConferenceId, RequestedById = requestedBy.Id, EndpointId = request.EndpointId, RoomLabel = request.RoomLabel }); } catch (VideoApiException e) { await _consultationNotifier.NotifyConsultationResponseAsync(conference, request.RoomLabel, request.EndpointId, ConsultationAnswer.Failed); _logger.LogError(e, "Join endpoint to consultation error"); return(StatusCode(e.StatusCode)); } return(Accepted()); }
public async Task should_return_call_videoapi_response_error_joining() { // Arrange SetupControllerWithClaims(_testConference.Participants[1].Username); var request = new AddEndpointConsultationRequest { ConferenceId = _testConference.Id, EndpointId = Guid.NewGuid(), RoomLabel = "RoomLabel" }; var apiException = new VideoApiException <ProblemDetails>("Bad Request", (int)HttpStatusCode.BadRequest, "Please provide a valid conference Id", null, default, null);
public async Task should_return_unauthorised_not_in_conference() { // Arrange SetupControllerWithClaims("*****@*****.**"); var request = new AddEndpointConsultationRequest { ConferenceId = _testConference.Id }; // Act var result = await _sut.AddEndpointToConsultationAsync(request); // Assert result.Should().BeOfType <UnauthorizedObjectResult>(); }
public async Task should_return_accepted() { // Arrange SetupControllerWithClaims("*****@*****.**"); var request = new AddEndpointConsultationRequest { ConferenceId = _testConference.Id, EndpointId = Guid.NewGuid(), RoomLabel = "RoomLabel" }; // Act var result = await _sut.AddEndpointToConsultationAsync(request); // Assert result.Should().BeOfType <AcceptedResult>(); }
public async Task should_return_call_JoinEndpointToConsultationAsync_with_correct_params() { // Arrange SetupControllerWithClaims(_testConference.Participants[1].Username); var request = new AddEndpointConsultationRequest { ConferenceId = _testConference.Id, EndpointId = Guid.NewGuid(), RoomLabel = "RoomLabel" }; // Act var result = await _sut.AddEndpointToConsultationAsync(request); // Assert result.Should().BeOfType <AcceptedResult>(); _mocker.Mock <IVideoApiClient>().Verify(x => x.JoinEndpointToConsultationAsync(It.Is <EndpointConsultationRequest>(r => r.EndpointId == request.EndpointId && r.ConferenceId == request.ConferenceId && r.RequestedById == _testConference.Participants[1].Id)), Times.Once); _mocker.Mock <IConsultationNotifier>().Verify(x => x.NotifyConsultationResponseAsync(_testConference, request.RoomLabel, request.EndpointId, ConsultationAnswer.Transferring)); }