public async Task SignUp_SessionCrated() { // Arrange await Task.Delay(TimeSpan.FromSeconds(5)); using IdentityApp app = _testContext.CreateApp <IdentityApp>(); await app.TestContext.StartMagnetAsync(); string mobileNr = "+41798074288"; string email = $"{Guid.NewGuid().ToString("N").Substring(0, 6)}@magic-media.io"; // Act SignUpPage page = app.Open <SignUpPage>($"{app.TestContext.HostUrl}SignUp"); page.SignUp(email, mobileNr); ValidateMobilePage validatePage = app.WaitForPage <ValidateMobilePage>(); SmsMessage sms = await app.TestContext.MagnetSession.WaitForSms(mobileNr); var code = ParseSecurityCode(sms.Body); validatePage.EnterCode(code); SignUpCompletedPage completed = app.WaitForPage <SignUpCompletedPage>(); // Assert completed.SuccessAlert.Text.Should().Be("Registration completed"); SignUpSession session = await GetSessionAsync(email); session.State.Should().Be("Completed"); }
public async Task <Guid> SendSmsCodeAsync( string email, string mobile, CancellationToken cancellationToken) { var secret = Password.GenerateRandomPassword(32, false); var code = _totpCodeService.Generate(secret); await _smsService.SendSmsAsync(mobile, $"Your Code: {code}", cancellationToken); var session = new SignUpSession { Id = Guid.NewGuid(), Email = email, Mobile = mobile, Secret = secret, State = "ValidationStarted" }; await _identityDbContext.SignUpSessions.InsertOneAsync( session, options : null, cancellationToken); return(session.Id); }
private async Task <SignUpSession> GetSessionAsync(string email) { IIdentityDbContext db = _testContext.GetDbContext(); SignUpSession session = await db.SignUpSessions.AsQueryable() .Where(x => x.Email == email) .FirstOrDefaultAsync(); return(session); }