-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VIH-11041 detect if any participant of endpoint are screened when inv…
…iting to a new or existing consultation
- Loading branch information
Shaed Parkar
committed
Oct 16, 2024
1 parent
ec8904a
commit b8437b5
Showing
23 changed files
with
624 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,14 +23,18 @@ public static Conference BuildConferenceForTest() | |
.With(x => x.Username = "[email protected]") | ||
.Build(), | ||
Builder<Participant>.CreateNew().With(x => x.Role = Role.Individual) | ||
.With(x => x.Id = Guid.NewGuid()).With(x => x.Username = "[email protected]").Build(), | ||
.With(x => x.Id = Guid.NewGuid()).With(x => x.Username = "[email protected]") | ||
.With(x => x.ExternalReferenceId = Guid.NewGuid().ToString()).Build(), | ||
Builder<Participant>.CreateNew().With(x => x.Role = Role.Representative) | ||
.With(x=> x.Username = "[email protected]") | ||
.With(x => x.Id = Guid.NewGuid()).Build(), | ||
.With(x => x.Id = Guid.NewGuid()) | ||
.With(x => x.ExternalReferenceId = Guid.NewGuid().ToString()).Build(), | ||
Builder<Participant>.CreateNew().With(x => x.Role = Role.Individual) | ||
.With(x => x.Id = Guid.NewGuid()).Build(), | ||
.With(x => x.Id = Guid.NewGuid()) | ||
.With(x => x.ExternalReferenceId = Guid.NewGuid().ToString()).Build(), | ||
Builder<Participant>.CreateNew().With(x => x.Role = Role.Representative) | ||
.With(x => x.Id = Guid.NewGuid()).Build(), | ||
.With(x => x.Id = Guid.NewGuid()) | ||
.With(x => x.ExternalReferenceId = Guid.NewGuid().ToString()).Build(), | ||
Builder<Participant>.CreateNew() | ||
.With(x => x.Role = Role.StaffMember).With(x => x.Id = Guid.NewGuid()) | ||
.With(x => x.Username = "[email protected]") | ||
|
@@ -39,11 +43,14 @@ public static Conference BuildConferenceForTest() | |
Endpoints = new List<Endpoint> | ||
{ | ||
Builder<Endpoint>.CreateNew().With(x => x.Id = Guid.NewGuid()).With(x => x.DisplayName = "EP1") | ||
.With(x=> x.DefenceAdvocateUsername = "[email protected]").Build(), | ||
.With(x=> x.DefenceAdvocateUsername = "[email protected]") | ||
.With(x => x.ExternalReferenceId = Guid.NewGuid().ToString()).Build(), | ||
Builder<Endpoint>.CreateNew().With(x => x.Id = Guid.NewGuid()).With(x => x.DisplayName = "EP2") | ||
.With(x=> x.DefenceAdvocateUsername = "[email protected]").Build(), | ||
.With(x=> x.DefenceAdvocateUsername = "[email protected]") | ||
.With(x => x.ExternalReferenceId = Guid.NewGuid().ToString()).Build(), | ||
Builder<Endpoint>.CreateNew().With(x => x.Id = Guid.NewGuid()).With(x => x.DisplayName = "EP3") | ||
.With(x=> x.DefenceAdvocateUsername = "[email protected]").Build(), | ||
.With(x=> x.DefenceAdvocateUsername = "[email protected]") | ||
.With(x => x.ExternalReferenceId = Guid.NewGuid().ToString()).Build(), | ||
} | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Security.Claims; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
@@ -96,11 +97,12 @@ public async Task should_return_accepted_if_user_is_in_consultation() | |
var cp = new ClaimsPrincipalBuilder().WithRole(AppRoles.RepresentativeRole) | ||
.WithUsername("[email protected]").Build(); | ||
_sut = SetupControllerWithClaims(cp); | ||
var participant = _testConference.Participants.First(x => x.Role == Role.Individual); | ||
|
||
var request = new InviteToConsultationRequest | ||
{ | ||
ConferenceId = _testConference.Id, | ||
ParticipantId = _testConference.Participants[0].Id, | ||
ParticipantId = participant.Id, | ||
RoomLabel = "Room1" | ||
}; | ||
|
||
|
@@ -112,7 +114,42 @@ public async Task should_return_accepted_if_user_is_in_consultation() | |
_mocker.Mock<IConsultationNotifier>() | ||
.Verify( | ||
x => x.NotifyConsultationRequestAsync(_testConference, "Room1", _testConference.Participants[2].Id, | ||
_testConference.Participants[0].Id), Times.Once); | ||
participant.Id), Times.Once); | ||
} | ||
|
||
[Test] | ||
public async Task should_return_forbidden_if_invitee_is_screened_from_existing_participant_in_room() | ||
{ | ||
// arrange | ||
var cp = new ClaimsPrincipalBuilder().WithRole(AppRoles.RepresentativeRole) | ||
.WithUsername("[email protected]").Build(); | ||
_sut = SetupControllerWithClaims(cp); | ||
|
||
var roomLabel = "RoomLabel1"; | ||
var individual = _testConference.Participants.Find(x => x.Role == Role.Individual); | ||
var endpoint = _testConference.Endpoints[0]; | ||
individual.ProtectFrom.Add(endpoint.ExternalReferenceId); | ||
var rep = _testConference.Participants.Find(x => x.Role == Role.Representative); | ||
|
||
rep.CurrentRoom = new ConsultationRoom {Label = roomLabel}; | ||
rep.Username = "[email protected]"; | ||
endpoint.CurrentRoom = new ConsultationRoom {Label = roomLabel}; | ||
|
||
var request = new InviteToConsultationRequest | ||
{ | ||
ConferenceId = _testConference.Id, | ||
RoomLabel = roomLabel, | ||
ParticipantId = individual.Id | ||
}; | ||
|
||
// act | ||
var result = await _sut.InviteToConsultationAsync(request, CancellationToken.None); | ||
|
||
// assert | ||
result.Should().BeOfType<ForbidResult>(); | ||
|
||
_mocker.Mock<IConsultationNotifier>().Verify( | ||
x => x.NotifyConsultationRequestAsync(_testConference, roomLabel, Guid.Empty, individual.Id), Times.Never); | ||
} | ||
|
||
private ConsultationsController SetupControllerWithClaims(ClaimsPrincipal claimsPrincipal) | ||
|
Oops, something went wrong.