예제 #1
0
        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);
        }
예제 #2
0
        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());
        }
예제 #3
0
        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>();
        }