public async Task BeingAndResetToken_ResetPost_JsonNewResetToken() { string old_tok = "Prev"; using (IdentityWsDbContext ef = CreateEf()) { Being being = new Being { PasswordResetToken = old_tok, PasswordResetTokenValidUntil = now.UtcNow.AddMinutes(2) }; ef.Aliases.Add(new Alias { EmailAddress = "*****@*****.**", Being = being }); await ef.SaveChangesAsync(); AliasesController patient = new AliasesController(ef, dummyLog, now, dummyRunner); IActionResult result = await patient.ResetPost("*****@*****.**"); result.Should().BeOfType <JsonResult>() .Which.Value.Should().BeOfType <Dictionary <string, string> >() .Which["resetToken"].Should().NotBe(old_tok, "a new token should have been generated"); being.PasswordResetTokenValidUntil.Should().Be(now.UtcNow.AddHours(1), "the validity period should also reset"); } }
public async Task NoBeing_ResetPost_NotFound() { using (IdentityWsDbContext ef = CreateEf()) { AliasesController patient = new AliasesController(ef, dummyLog, now, dummyRunner); IActionResult result = await patient.ResetPost("*****@*****.**"); result.Should().BeOfType <NotFoundResult>("the being does not exist"); } }