public async Task should_return_accepted_if_user_is_in_consultation() { // Arrange var cp = new ClaimsPrincipalBuilder().WithRole(AppRoles.RepresentativeRole) .WithUsername("*****@*****.**").Build(); _sut = SetupControllerWithClaims(cp); var request = new InviteToConsultationRequest { ConferenceId = _testConference.Id, ParticipantId = _testConference.Participants[0].Id, RoomLabel = "Room1" }; // Act var result = await _sut.InviteToConsultationAsync(request); // Assert result.Should().BeOfType <AcceptedResult>(); _mocker.Mock <IConsultationNotifier>() .Verify( x => x.NotifyConsultationRequestAsync(_testConference, "Room1", _testConference.Participants[2].Id, _testConference.Participants[0].Id), Times.Once); }
public async Task <IActionResult> InviteToConsultationAsync(InviteToConsultationRequest 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 && !User.IsInRole(AppRoles.VhOfficerRole)) { return(Unauthorized("You must be a VHO or a member of the conference")); } await _consultationNotifier.NotifyConsultationRequestAsync(conference, request.RoomLabel, requestedBy?.Id ?? Guid.Empty, request.ParticipantId); return(Accepted()); }
public async Task should_return_unauthorized_if_user_is_not_in_conference_or_vh_officer() { // Arrange var cp = new ClaimsPrincipalBuilder().WithRole(AppRoles.RepresentativeRole) .WithUsername("*****@*****.**").Build(); _sut = SetupControllerWithClaims(cp); var request = new InviteToConsultationRequest { ConferenceId = _testConference.Id, ParticipantId = _testConference.Participants[0].Id, RoomLabel = "Room1" }; // Act var result = await _sut.InviteToConsultationAsync(request); // Assert result.Should().BeOfType <UnauthorizedObjectResult>(); }