예제 #1
0
        public void Arrange()
        {
            base.Arrange(
                addEpaoClaim: true,
                addUkprnClaim: false,
                contactsPrivileges: new List <ContactsPrivilege>
            {
                // the contact has the explict 'Change Organisation Details' privilege
                ChangeOrganisationDetailsContactsPrivilege
            });

            ContactsApiClient.Setup(c => c.GetAllContactsForOrganisation(EpaoId, null))
            .ReturnsAsync(new List <ContactResponse>());

            ContactsApiClient.Setup(c => c.GetByUsername(ValidPrimaryContact))
            .ReturnsAsync(new ContactResponse
            {
                OrganisationId = OrganisationOneId,
                Username       = ValidPrimaryContact
            });

            ContactsApiClient.Setup(c => c.GetByUsername(InvalidPrimaryContactEmpty))
            .ReturnsAsync((ContactResponse)null);

            ContactsApiClient.Setup(c => c.GetByUsername(InvalidPrimaryContactWrongOrganisation))
            .ReturnsAsync(new ContactResponse
            {
                OrganisationId = OrganisationTwoId,
                Username       = ValidPrimaryContact
            });
        }
        public void Arrange()
        {
            base.Arrange(
                addEpaoClaim: true,
                addUkprnClaim: false,
                contactsPrivileges: new List <ContactsPrivilege>
            {
                // the contact has the explict 'Change Organisation Details' privilege
                ChangeOrganisationDetailsContactsPrivilege
            });

            ContactsApiClient.Setup(c => c.GetAllContactsForOrganisation(EpaoId, null))
            .ReturnsAsync(new List <ContactResponse>());

            ContactsApiClient.Setup(c => c.GetByUsername(ValidPrimaryContact))
            .ReturnsAsync(new ContactResponse
            {
                Id             = Guid.NewGuid(),
                OrganisationId = OrganisationOneId,
                Username       = ValidPrimaryContact
            });

            ContactsApiClient.Setup(c => c.GetByUsername(ValidPrimaryContactSameOrganisation))
            .ReturnsAsync(new ContactResponse
            {
                Id             = ValidPrimaryContactIdSameOrganisation,
                OrganisationId = OrganisationOneId,
                Username       = ValidPrimaryContactSameOrganisation
            });

            OrganisationApiClient.Setup(c => c.UpdateEpaOrganisationPrimaryContact(It.IsAny <UpdateEpaOrganisationPrimaryContactRequest>()))
            .ReturnsAsync(new List <ContactResponse>());
        }
        public async Task GivenEditOrganisationStandard_WhenEditingOrganisationStandard_ThenReturnContacts()
        {
            //Act
            var actionResult = await Sut.EditOrganisationStandard(organisationStandardId);

            //Assert
            ContactsApiClient.Verify(c => c.GetAllContactsForOrganisation(OrganisationOneOrganisationId, null), Times.Once);
            var result = actionResult as ViewResult;
            var registerViewAndEditOrganisationStandardViewModel = result.Model as RegisterViewAndEditOrganisationStandardViewModel;

            registerViewAndEditOrganisationStandardViewModel.Contacts.Should().HaveCount(2);
        }
예제 #4
0
        public async Task Then_UnauthorizedResult_is_returned()
        {
            ContactsApiClient.Setup(apiClient => apiClient.GetById(CallingUserId)).ReturnsAsync(new ContactResponse
            {
                Id             = CallingUserId,
                OrganisationId = DifferentOrganisationId
            });

            var result = await Controller.Details(UserId);

            result.Should().BeOfType <UnauthorizedResult>();
        }
예제 #5
0
        public async Task <IActionResult> Details(Guid contactId)
        {
            var securityCheckpoint = await SecurityCheckAndGetContact(contactId);

            if (!securityCheckpoint.isValid)
            {
                return(Unauthorized());
            }

            var vm = Mapper.Map <UserViewModel>(securityCheckpoint.contact);

            vm.AssignedPrivileges = await ContactsApiClient.GetContactPrivileges(contactId);

            return(View("~/Views/ManageUsers/UserDetails/User.cshtml", vm));
        }
예제 #6
0
 public DataSideEffects(ContactsApiClient client)
 {
     this.client = client;
 }