public void Throws_when_the_registration_claim_is_missing(
     ConfirmYourIdentityModel sut,
     ClaimsPrincipal user)
 {
     sut.Invoking(x => x.OnGetAsync(new AuthenticatedUser(user)))
     .Should().Throw <Exception>().WithMessage("There is no `registration_id` claim.");
 }
        public void Throws_when_the_registration_claim_is_not_a_guid(
            ConfirmYourIdentityModel sut,
            ClaimsPrincipal user,
            string notAGuid)
        {
            user.AddIdentity(new ClaimsIdentity(new[]
            {
                new Claim("registration_id", notAGuid)
            }));

            sut.Invoking(x => x.OnGetAsync(new AuthenticatedUser(user)))
            .Should().Throw <Exception>()
            .WithMessage($"`{notAGuid}` in claim `registration_id` is not a valid identifier");
        }
Ejemplo n.º 3
0
        public async Task WhenTheApprenticeVerifiesTheirIdentityWith(Table table)
        {
            _postedRegistration             = table.CreateInstance(() => new ConfirmYourIdentityModel(null));
            _postedRegistration.DateOfBirth =
                new DateModel(DateTime.Parse(table.Rows[0]["Date of Birth"]));

            await _context.Web.Post("ConfirmYourIdentity",
                                    new FormUrlEncodedContent(new Dictionary <string, string>
            {
                { "FirstName", _postedRegistration.FirstName },
                { "LastName", _postedRegistration.LastName },
                { "DateOfBirth.Day", _postedRegistration?.DateOfBirth?.Day.ToString() },
                { "DateOfBirth.Month", _postedRegistration?.DateOfBirth?.Month.ToString() },
                { "DateOfBirth.Year", _postedRegistration?.DateOfBirth?.Year.ToString() },
            }));
        }
        public async Task The_page_shows_my_email_address(
            [Frozen] Mock <IOuterApiClient> api,
            ConfirmYourIdentityModel sut,
            ClaimsPrincipal user,
            VerifyRegistrationResponse registration)
        {
            user.AddIdentity(new ClaimsIdentity(new[]
            {
                new Claim("registration_id", registration.ApprenticeId.ToString())
            }));
            registration.HasCompletedVerification = false;
            api.Setup(x => x.GetRegistration(registration.ApprenticeId)).Returns(Task.FromResult(registration));

            await sut.OnGetAsync(new AuthenticatedUser(user));

            sut.EmailAddress.Should().Be(registration.Email);
        }