public void GetByIdentifier_Null() { // Init var repo = new AuthorizationRepository(); #region Prepare records // Record #1 repo.Add(new MemoryAuthorization { Identifier = new MemoryIdentifier { Type = "dns", Value = "some.test.com", }, Status = AuthorizationStatus.Invalid, }); // Record #3 repo.Add(new MemoryAuthorization { Identifier = new MemoryIdentifier { Type = "dns", Value = "some.test2.com", }, Status = AuthorizationStatus.Pending, }); // Record #3 repo.Add(new MemoryAuthorization { Identifier = new MemoryIdentifier { Type = "dns", Value = "some.test.com", }, Status = AuthorizationStatus.Pending, }); #endregion // Get authz by Id var identifier = new Identifier { Type = "DNS", // check case insensitive Value = "Some.Test.Com" }; var res = repo.GetByIdentifier(0, identifier); // wrong id Assert.Equal(3, res.Id); }
/// <inheritdoc/> public IAuthorization GetActual(int accountId, Identifier identifier) { // Get auth from repository var authz = AuthorizationRepository.GetByIdentifier(accountId, identifier); if (authz == null) { return(null); } var updatedAuthz = RefreshStatus(authz); if (authz.Status == AuthorizationStatus.Invalid || authz.Status == AuthorizationStatus.Expired || authz.Status == AuthorizationStatus.Revoked || authz.Status == AuthorizationStatus.Deactivated) { return(null); } return(updatedAuthz); }