Use UTC for system dates in Umbraco (#19822)
* Persist and expose Umbraco system dates as UTC (#19705) * Updated persistence DTOs defining default dates to use UTC. * Remove ForceToUtc = false from all persistence DTO attributes (default when not specified is true). * Removed use of SpecifyKind setting dates to local. * Removed unnecessary Utc suffixes on properties. * Persist current date time with UtcNow. * Removed further necessary Utc suffixes and fixed failing unit tests. * Added migration for SQL server to update database date default constraints. * Added comment justifying not providing a migration for SQLite default date constraints. * Ensure UTC for datetimes created from persistence DTOs. * Ensure UTC when creating dates for published content rendering in Razor and outputting in delivery API. * Fixed migration SQL syntax. * Introduced AuditItemFactory for creating entries for the backoffice document history, so we can control the UTC setting on the retrieved persisted dates. * Ensured UTC dates are retrieved for document versions. * Ensured UTC is returned for backoffice display of last edited and published for variant content. * Fixed SQLite syntax for default current datetime. * Apply suggestions from code review Co-authored-by: Laura Neto <12862535+lauraneto@users.noreply.github.com> * Further updates from code review. --------- Co-authored-by: Laura Neto <12862535+lauraneto@users.noreply.github.com> * Migrate system dates from local server time to UTC (#19798) * Add settings for the migration. * Add migration and implement for SQL server. * Implement for SQLite. * Fixes from testing with SQL Server. * Fixes from testing with SQLite. * Code tidy. * Cleaned up usings. * Removed audit log date from conversion. * Removed webhook log date from conversion. * Updated update date initialization on saving dictionary items. * Updated filter on log queries. * Use timezone ID instead of system name to work cross-culture. --------- Co-authored-by: Laura Neto <12862535+lauraneto@users.noreply.github.com>
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
// using Moq;
|
||||
// using NUnit.Framework;
|
||||
// using Umbraco.Cms.Core.Cache;
|
||||
// using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
// using Umbraco.Cms.Core.PropertyEditors;
|
||||
// using Umbraco.Cms.Core.PublishedCache;
|
||||
// using Umbraco.Cms.Infrastructure.PublishedCache;
|
||||
// using Umbraco.Cms.Infrastructure.PublishedCache.DataSource;
|
||||
//
|
||||
// namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.DeliveryApi;
|
||||
//
|
||||
// FIXME: Reintroduce if relevant
|
||||
// [TestFixture]
|
||||
// public class CacheTests
|
||||
// {
|
||||
// [TestCase(PropertyCacheLevel.Snapshot, false, 1)]
|
||||
// [TestCase(PropertyCacheLevel.Snapshot, true, 1)]
|
||||
// [TestCase(PropertyCacheLevel.Elements, false, 1)]
|
||||
// [TestCase(PropertyCacheLevel.Elements, true, 1)]
|
||||
// [TestCase(PropertyCacheLevel.Element, false, 1)]
|
||||
// [TestCase(PropertyCacheLevel.Element, true, 1)]
|
||||
// [TestCase(PropertyCacheLevel.None, false, 4)]
|
||||
// [TestCase(PropertyCacheLevel.None, true, 4)]
|
||||
// public void PublishedElementProperty_CachesDeliveryApiValueConversion(PropertyCacheLevel cacheLevel, bool expanding, int expectedConverterHits)
|
||||
// {
|
||||
// var contentType = new Mock<IPublishedContentType>();
|
||||
// contentType.SetupGet(c => c.PropertyTypes).Returns(Array.Empty<IPublishedPropertyType>());
|
||||
//
|
||||
// var contentNode = new ContentNode(123, Guid.NewGuid(), contentType.Object, 1, string.Empty, 1, 1, DateTime.Now, 1);
|
||||
// var contentData = new ContentData("bla", "bla", 1, DateTime.Now, 1, 1, true, new Dictionary<string, PropertyData[]>(), null);
|
||||
//
|
||||
// var elementCache = new FastDictionaryAppCache();
|
||||
// var snapshotCache = new FastDictionaryAppCache();
|
||||
// var publishedSnapshotMock = new Mock<IPublishedSnapshot>();
|
||||
// publishedSnapshotMock.SetupGet(p => p.ElementsCache).Returns(elementCache);
|
||||
// publishedSnapshotMock.SetupGet(p => p.SnapshotCache).Returns(snapshotCache);
|
||||
//
|
||||
// var publishedSnapshot = publishedSnapshotMock.Object;
|
||||
// var publishedSnapshotAccessor = new Mock<IPublishedSnapshotAccessor>();
|
||||
// publishedSnapshotAccessor.Setup(p => p.TryGetPublishedSnapshot(out publishedSnapshot)).Returns(true);
|
||||
//
|
||||
// var content = new PublishedContent(
|
||||
// contentNode,
|
||||
// contentData,
|
||||
// publishedSnapshotAccessor.Object,
|
||||
// Mock.Of<IVariationContextAccessor>(),
|
||||
// Mock.Of<IPublishedModelFactory>());
|
||||
//
|
||||
// var propertyType = new Mock<IPublishedPropertyType>();
|
||||
// var invocationCount = 0;
|
||||
// propertyType.SetupGet(p => p.CacheLevel).Returns(cacheLevel);
|
||||
// propertyType.SetupGet(p => p.DeliveryApiCacheLevel).Returns(cacheLevel);
|
||||
// propertyType.SetupGet(p => p.DeliveryApiCacheLevelForExpansion).Returns(cacheLevel);
|
||||
// propertyType
|
||||
// .Setup(p => p.ConvertInterToDeliveryApiObject(It.IsAny<IPublishedElement>(), It.IsAny<PropertyCacheLevel>(), It.IsAny<object?>(), It.IsAny<bool>(), It.IsAny<bool>()))
|
||||
// .Returns(() => $"Delivery API value: {++invocationCount}");
|
||||
//
|
||||
// var prop1 = new Property(propertyType.Object, content, publishedSnapshotAccessor.Object);
|
||||
// var results = new List<string>();
|
||||
// results.Add(prop1.GetDeliveryApiValue(expanding)!.ToString());
|
||||
// results.Add(prop1.GetDeliveryApiValue(expanding)!.ToString());
|
||||
// results.Add(prop1.GetDeliveryApiValue(expanding)!.ToString());
|
||||
// results.Add(prop1.GetDeliveryApiValue(expanding)!.ToString());
|
||||
//
|
||||
// Assert.AreEqual("Delivery API value: 1", results.First());
|
||||
// Assert.AreEqual(expectedConverterHits, results.Distinct().Count());
|
||||
//
|
||||
// propertyType.Verify(
|
||||
// p => p.ConvertInterToDeliveryApiObject(
|
||||
// It.IsAny<IPublishedElement>(),
|
||||
// It.IsAny<PropertyCacheLevel>(),
|
||||
// It.IsAny<object?>(),
|
||||
// It.IsAny<bool>(),
|
||||
// It.IsAny<bool>()),
|
||||
// Times.Exactly(expectedConverterHits));
|
||||
// }
|
||||
// }
|
||||
@@ -679,7 +679,7 @@ internal sealed class ContentServiceTests : UmbracoIntegrationTestWithContent
|
||||
|
||||
// Act
|
||||
Thread.Sleep(new TimeSpan(0, 0, 0, 2));
|
||||
var contents = ContentService.GetContentForExpiration(DateTime.Now).ToList();
|
||||
var contents = ContentService.GetContentForExpiration(DateTime.UtcNow).ToList();
|
||||
|
||||
// Assert
|
||||
Assert.That(contents, Is.Not.Null);
|
||||
@@ -711,10 +711,10 @@ internal sealed class ContentServiceTests : UmbracoIntegrationTestWithContent
|
||||
{
|
||||
// Arrange
|
||||
// Act
|
||||
var contents = ContentService.GetContentForRelease(DateTime.Now).ToList();
|
||||
var contents = ContentService.GetContentForRelease(DateTime.UtcNow).ToList();
|
||||
|
||||
// Assert
|
||||
Assert.That(DateTime.Now.AddMinutes(-5) <= DateTime.Now);
|
||||
Assert.That(DateTime.UtcNow.AddMinutes(-5) <= DateTime.UtcNow);
|
||||
Assert.That(contents, Is.Not.Null);
|
||||
Assert.That(contents.Any(), Is.True);
|
||||
Assert.That(contents.Count(), Is.EqualTo(1));
|
||||
@@ -1308,7 +1308,7 @@ internal sealed class ContentServiceTests : UmbracoIntegrationTestWithContent
|
||||
content.SetCultureName("name-fr", langFr.IsoCode);
|
||||
content.SetCultureName("name-da", langDa.IsoCode);
|
||||
|
||||
content.PublishCulture(CultureImpact.Explicit(langFr.IsoCode, langFr.IsDefault), DateTime.Now, PropertyEditorCollection);
|
||||
content.PublishCulture(CultureImpact.Explicit(langFr.IsoCode, langFr.IsDefault), DateTime.UtcNow, PropertyEditorCollection);
|
||||
var result = ContentService.CommitDocumentChanges(content);
|
||||
Assert.IsTrue(result.Success);
|
||||
content = ContentService.GetById(content.Id);
|
||||
@@ -1316,7 +1316,7 @@ internal sealed class ContentServiceTests : UmbracoIntegrationTestWithContent
|
||||
Assert.IsFalse(content.IsCulturePublished(langDa.IsoCode));
|
||||
|
||||
content.UnpublishCulture(langFr.IsoCode);
|
||||
content.PublishCulture(CultureImpact.Explicit(langDa.IsoCode, langDa.IsDefault), DateTime.Now, PropertyEditorCollection);
|
||||
content.PublishCulture(CultureImpact.Explicit(langDa.IsoCode, langDa.IsDefault), DateTime.UtcNow, PropertyEditorCollection);
|
||||
|
||||
result = ContentService.CommitDocumentChanges(content);
|
||||
Assert.IsTrue(result.Success);
|
||||
|
||||
@@ -33,7 +33,7 @@ internal sealed partial class UserServiceCrudTests
|
||||
Assert.IsTrue(creationResult.Success);
|
||||
var createdUser = creationResult.Result.CreatedUser;
|
||||
|
||||
createdUser!.LastLoginDate = DateTime.Now;
|
||||
createdUser!.LastLoginDate = DateTime.UtcNow;
|
||||
userService.Save(createdUser);
|
||||
|
||||
var result = await userService.DeleteAsync(Constants.Security.SuperUserKey, createdUser.Key);
|
||||
|
||||
@@ -61,9 +61,9 @@ internal sealed class NPocoBulkInsertTests : UmbracoIntegrationTest
|
||||
{
|
||||
ServerAddress = "address" + i,
|
||||
ServerIdentity = "computer" + i,
|
||||
DateRegistered = DateTime.Now,
|
||||
DateRegistered = DateTime.UtcNow,
|
||||
IsActive = true,
|
||||
DateAccessed = DateTime.Now
|
||||
DateAccessed = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ internal sealed class NPocoBulkInsertTests : UmbracoIntegrationTest
|
||||
{
|
||||
ServerAddress = "address" + i,
|
||||
ServerIdentity = "computer" + i,
|
||||
DateRegistered = DateTime.Now,
|
||||
DateRegistered = DateTime.UtcNow,
|
||||
IsActive = true,
|
||||
DateAccessed = DateTime.Now
|
||||
DateAccessed = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
|
||||
@@ -121,9 +121,9 @@ internal sealed class NPocoBulkInsertTests : UmbracoIntegrationTest
|
||||
{
|
||||
ServerAddress = "address" + i,
|
||||
ServerIdentity = "computer" + i,
|
||||
DateRegistered = DateTime.Now,
|
||||
DateRegistered = DateTime.UtcNow,
|
||||
IsActive = true,
|
||||
DateAccessed = DateTime.Now
|
||||
DateAccessed = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
|
||||
@@ -155,9 +155,9 @@ internal sealed class NPocoBulkInsertTests : UmbracoIntegrationTest
|
||||
{
|
||||
ServerAddress = "address" + i,
|
||||
ServerIdentity = "computer" + i,
|
||||
DateRegistered = DateTime.Now,
|
||||
DateRegistered = DateTime.UtcNow,
|
||||
IsActive = true,
|
||||
DateAccessed = DateTime.Now
|
||||
DateAccessed = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
|
||||
@@ -185,9 +185,9 @@ internal sealed class NPocoBulkInsertTests : UmbracoIntegrationTest
|
||||
{
|
||||
ServerAddress = "address" + i,
|
||||
ServerIdentity = "computer" + i,
|
||||
DateRegistered = DateTime.Now,
|
||||
DateRegistered = DateTime.UtcNow,
|
||||
IsActive = true,
|
||||
DateAccessed = DateTime.Now,
|
||||
DateAccessed = DateTime.UtcNow,
|
||||
IsSchedulingPublisher = true
|
||||
});
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ internal sealed class DocumentRepositoryTest : UmbracoIntegrationTest
|
||||
|
||||
// publish = new edit version
|
||||
content1.SetValue("title", "title");
|
||||
content1.PublishCulture(CultureImpact.Invariant, DateTime.Now, PropertyEditorCollection);
|
||||
content1.PublishCulture(CultureImpact.Invariant, DateTime.UtcNow, PropertyEditorCollection);
|
||||
content1.PublishedState = PublishedState.Publishing;
|
||||
repository.Save(content1);
|
||||
|
||||
@@ -303,7 +303,7 @@ internal sealed class DocumentRepositoryTest : UmbracoIntegrationTest
|
||||
new { id = content1.Id }));
|
||||
|
||||
// publish = version
|
||||
content1.PublishCulture(CultureImpact.Invariant, DateTime.Now, PropertyEditorCollection);
|
||||
content1.PublishCulture(CultureImpact.Invariant, DateTime.UtcNow, PropertyEditorCollection);
|
||||
content1.PublishedState = PublishedState.Publishing;
|
||||
repository.Save(content1);
|
||||
|
||||
@@ -347,7 +347,7 @@ internal sealed class DocumentRepositoryTest : UmbracoIntegrationTest
|
||||
// publish = new version
|
||||
content1.Name = "name-4";
|
||||
content1.SetValue("title", "title-4");
|
||||
content1.PublishCulture(CultureImpact.Invariant, DateTime.Now, PropertyEditorCollection);
|
||||
content1.PublishCulture(CultureImpact.Invariant, DateTime.UtcNow, PropertyEditorCollection);
|
||||
content1.PublishedState = PublishedState.Publishing;
|
||||
repository.Save(content1);
|
||||
|
||||
@@ -767,7 +767,7 @@ internal sealed class DocumentRepositoryTest : UmbracoIntegrationTest
|
||||
// publish them all
|
||||
foreach (var content in result)
|
||||
{
|
||||
content.PublishCulture(CultureImpact.Invariant, DateTime.Now, PropertyEditorCollection);
|
||||
content.PublishCulture(CultureImpact.Invariant, DateTime.UtcNow, PropertyEditorCollection);
|
||||
repository.Save(content);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ internal sealed class KeyValueRepositoryTests : UmbracoIntegrationTest
|
||||
// Insert new key/value
|
||||
using (var scope = provider.CreateCoreScope())
|
||||
{
|
||||
var keyValue = new KeyValue { Identifier = "foo", Value = "bar", UpdateDate = DateTime.Now };
|
||||
var keyValue = new KeyValue { Identifier = "foo", Value = "bar", UpdateDate = DateTime.UtcNow };
|
||||
var repo = CreateRepository(provider);
|
||||
repo.Save(keyValue);
|
||||
scope.Complete();
|
||||
@@ -47,7 +47,7 @@ internal sealed class KeyValueRepositoryTests : UmbracoIntegrationTest
|
||||
var repo = CreateRepository(provider);
|
||||
var keyValue = repo.Get("foo");
|
||||
keyValue.Value = "buzz";
|
||||
keyValue.UpdateDate = DateTime.Now;
|
||||
keyValue.UpdateDate = DateTime.UtcNow;
|
||||
repo.Save(keyValue);
|
||||
scope.Complete();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
|
||||
|
||||
var node = new NodeDto // create bogus item so we can add a notification
|
||||
{
|
||||
CreateDate = DateTime.Now,
|
||||
CreateDate = DateTime.UtcNow,
|
||||
Level = 1,
|
||||
NodeObjectType = Constants.ObjectTypes.ContentItem,
|
||||
ParentId = -1,
|
||||
@@ -69,8 +69,8 @@ internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
|
||||
Password = "test",
|
||||
UserName = "test",
|
||||
UserLanguage = "en",
|
||||
CreateDate = DateTime.Now,
|
||||
UpdateDate = DateTime.Now
|
||||
CreateDate = DateTime.UtcNow,
|
||||
UpdateDate = DateTime.UtcNow,
|
||||
};
|
||||
ScopeAccessor.AmbientScope.Database.Insert(userDto);
|
||||
|
||||
@@ -81,7 +81,7 @@ internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
|
||||
{
|
||||
var node = new NodeDto
|
||||
{
|
||||
CreateDate = DateTime.Now,
|
||||
CreateDate = DateTime.UtcNow,
|
||||
Level = 1,
|
||||
NodeObjectType = Constants.ObjectTypes.ContentItem,
|
||||
ParentId = -1,
|
||||
@@ -113,7 +113,7 @@ internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
|
||||
|
||||
var node1 = new NodeDto
|
||||
{
|
||||
CreateDate = DateTime.Now,
|
||||
CreateDate = DateTime.UtcNow,
|
||||
Level = 1,
|
||||
NodeObjectType = Constants.ObjectTypes.ContentItem,
|
||||
ParentId = -1,
|
||||
@@ -128,7 +128,7 @@ internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
|
||||
var entity1 = Mock.Of<IEntity>(e => e.Id == node1.NodeId);
|
||||
var node2 = new NodeDto
|
||||
{
|
||||
CreateDate = DateTime.Now,
|
||||
CreateDate = DateTime.UtcNow,
|
||||
Level = 1,
|
||||
NodeObjectType = Constants.ObjectTypes.ContentItem,
|
||||
ParentId = -1,
|
||||
@@ -152,8 +152,8 @@ internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
|
||||
Password = "test",
|
||||
UserName = "test" + i,
|
||||
UserLanguage = "en",
|
||||
CreateDate = DateTime.Now,
|
||||
UpdateDate = DateTime.Now
|
||||
CreateDate = DateTime.UtcNow,
|
||||
UpdateDate = DateTime.UtcNow
|
||||
};
|
||||
ScopeAccessor.AmbientScope.Database.Insert(userDto);
|
||||
var userNew = Mock.Of<IUser>(e => e.Id == userDto.Id);
|
||||
@@ -176,7 +176,7 @@ internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
|
||||
|
||||
var node1 = new NodeDto
|
||||
{
|
||||
CreateDate = DateTime.Now,
|
||||
CreateDate = DateTime.UtcNow,
|
||||
Level = 1,
|
||||
NodeObjectType = Constants.ObjectTypes.ContentItem,
|
||||
ParentId = -1,
|
||||
@@ -191,7 +191,7 @@ internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
|
||||
var entity1 = Mock.Of<IEntity>(e => e.Id == node1.NodeId);
|
||||
var node2 = new NodeDto
|
||||
{
|
||||
CreateDate = DateTime.Now,
|
||||
CreateDate = DateTime.UtcNow,
|
||||
Level = 1,
|
||||
NodeObjectType = Constants.ObjectTypes.ContentItem,
|
||||
ParentId = -1,
|
||||
@@ -215,8 +215,8 @@ internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
|
||||
Password = "test",
|
||||
UserName = "test" + i,
|
||||
UserLanguage = "en",
|
||||
CreateDate = DateTime.Now,
|
||||
UpdateDate = DateTime.Now
|
||||
CreateDate = DateTime.UtcNow,
|
||||
UpdateDate = DateTime.UtcNow
|
||||
};
|
||||
ScopeAccessor.AmbientScope.Database.Insert(userDto);
|
||||
var userNew = Mock.Of<IUser>(e => e.Id == userDto.Id);
|
||||
@@ -244,8 +244,8 @@ internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
|
||||
Password = "test",
|
||||
UserName = "test",
|
||||
UserLanguage = "en",
|
||||
CreateDate = DateTime.Now,
|
||||
UpdateDate = DateTime.Now
|
||||
CreateDate = DateTime.UtcNow,
|
||||
UpdateDate = DateTime.UtcNow
|
||||
};
|
||||
ScopeAccessor.AmbientScope.Database.Insert(userDto);
|
||||
|
||||
@@ -256,7 +256,7 @@ internal sealed class NotificationsRepositoryTest : UmbracoIntegrationTest
|
||||
{
|
||||
var node = new NodeDto
|
||||
{
|
||||
CreateDate = DateTime.Now,
|
||||
CreateDate = DateTime.UtcNow,
|
||||
Level = 1,
|
||||
NodeObjectType = Constants.ObjectTypes.ContentItem,
|
||||
ParentId = -1,
|
||||
|
||||
@@ -39,7 +39,7 @@ internal sealed class ServerRegistrationRepositoryTest : UmbracoIntegrationTest
|
||||
{
|
||||
var repository = CreateRepository(provider);
|
||||
|
||||
var server = new ServerRegistration("http://shazwazza.com", "COMPUTER1", DateTime.Now);
|
||||
var server = new ServerRegistration("http://shazwazza.com", "COMPUTER1", DateTime.UtcNow);
|
||||
|
||||
Assert.That(() => repository.Save(server), Throws.InstanceOf<DbException>());
|
||||
}
|
||||
@@ -156,7 +156,7 @@ internal sealed class ServerRegistrationRepositoryTest : UmbracoIntegrationTest
|
||||
var repository = CreateRepository(provider);
|
||||
|
||||
// Act
|
||||
var server = new ServerRegistration("http://shazwazza.com", "COMPUTER4", DateTime.Now);
|
||||
var server = new ServerRegistration("http://shazwazza.com", "COMPUTER4", DateTime.UtcNow);
|
||||
repository.Save(server);
|
||||
|
||||
// Assert
|
||||
@@ -237,9 +237,9 @@ internal sealed class ServerRegistrationRepositoryTest : UmbracoIntegrationTest
|
||||
{
|
||||
var repository = CreateRepository(provider);
|
||||
|
||||
repository.Save(new ServerRegistration("http://localhost", "COMPUTER1", DateTime.Now) { IsActive = true });
|
||||
repository.Save(new ServerRegistration("http://www.mydomain.com", "COMPUTER2", DateTime.Now));
|
||||
repository.Save(new ServerRegistration("https://www.another.domain.com", "Computer3", DateTime.Now));
|
||||
repository.Save(new ServerRegistration("http://localhost", "COMPUTER1", DateTime.UtcNow) { IsActive = true });
|
||||
repository.Save(new ServerRegistration("http://www.mydomain.com", "COMPUTER2", DateTime.UtcNow));
|
||||
repository.Save(new ServerRegistration("https://www.another.domain.com", "Computer3", DateTime.UtcNow));
|
||||
scope.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,12 +651,12 @@ internal sealed class TagRepositoryTest : UmbracoIntegrationTest
|
||||
ContentTypeRepository.Save(contentType);
|
||||
|
||||
var content1 = ContentBuilder.CreateSimpleContent(contentType);
|
||||
content1.PublishCulture(CultureImpact.Invariant, DateTime.Now, GetRequiredService<PropertyEditorCollection>());
|
||||
content1.PublishCulture(CultureImpact.Invariant, DateTime.UtcNow, GetRequiredService<PropertyEditorCollection>());
|
||||
content1.PublishedState = PublishedState.Publishing;
|
||||
DocumentRepository.Save(content1);
|
||||
|
||||
var content2 = ContentBuilder.CreateSimpleContent(contentType);
|
||||
content2.PublishCulture(CultureImpact.Invariant, DateTime.Now, GetRequiredService<PropertyEditorCollection>());
|
||||
content2.PublishCulture(CultureImpact.Invariant, DateTime.UtcNow, GetRequiredService<PropertyEditorCollection>());
|
||||
content2.PublishedState = PublishedState.Publishing;
|
||||
content2.Trashed = true;
|
||||
DocumentRepository.Save(content2);
|
||||
|
||||
@@ -425,7 +425,7 @@ internal sealed class UserRepositoryTest : UmbracoIntegrationTest
|
||||
|
||||
// manually update this record to be in the past
|
||||
ScopeAccessor.AmbientScope.Database.Execute(ScopeAccessor.AmbientScope.SqlContext.Sql()
|
||||
.Update<UserLoginDto>(u => u.Set(x => x.LoggedOutUtc, DateTime.UtcNow.AddDays(-100)))
|
||||
.Update<UserLoginDto>(u => u.Set(x => x.LoggedOut, DateTime.UtcNow.AddDays(-100)))
|
||||
.Where<UserLoginDto>(x => x.SessionId == sessionId));
|
||||
|
||||
var isValid = repository.ValidateLoginSession(user.Id, sessionId);
|
||||
|
||||
@@ -26,7 +26,7 @@ internal sealed class AuditEntryServiceTests : UmbracoIntegrationTest
|
||||
expected.PerformingUserKey.Value,
|
||||
expected.PerformingDetails,
|
||||
expected.PerformingIp,
|
||||
expected.EventDateUtc,
|
||||
expected.EventDate,
|
||||
expected.AffectedUserKey.Value,
|
||||
expected.AffectedDetails,
|
||||
expected.EventType,
|
||||
@@ -42,7 +42,7 @@ internal sealed class AuditEntryServiceTests : UmbracoIntegrationTest
|
||||
Assert.AreEqual(expected.PerformingUserId, actual.PerformingUserId);
|
||||
Assert.AreEqual(expected.PerformingUserKey, actual.PerformingUserKey);
|
||||
Assert.AreEqual(expected.PerformingDetails, actual.PerformingDetails);
|
||||
Assert.AreEqual(expected.EventDateUtc, actual.EventDateUtc);
|
||||
Assert.AreEqual(expected.EventDate, actual.EventDate);
|
||||
Assert.AreEqual(expected.AffectedUserId, actual.AffectedUserId);
|
||||
Assert.AreEqual(expected.AffectedUserKey, actual.AffectedUserKey);
|
||||
Assert.AreEqual(expected.AffectedDetails, actual.AffectedDetails);
|
||||
@@ -80,7 +80,7 @@ internal sealed class AuditEntryServiceTests : UmbracoIntegrationTest
|
||||
Assert.AreEqual(Constants.Security.SuperUserKey, actual.PerformingUserKey);
|
||||
Assert.AreEqual("performingDetails", actual.PerformingDetails);
|
||||
Assert.AreEqual("performingIp", actual.PerformingIp);
|
||||
Assert.AreEqual(eventDateUtc, actual.EventDateUtc);
|
||||
Assert.AreEqual(eventDateUtc, actual.EventDate);
|
||||
Assert.AreEqual(Constants.Security.UnknownUserId, actual.AffectedUserId);
|
||||
Assert.AreEqual(null, actual.AffectedUserKey);
|
||||
Assert.AreEqual("affectedDetails", actual.AffectedDetails);
|
||||
|
||||
@@ -60,7 +60,7 @@ internal class ContentVersionCleanupServiceTest : UmbracoIntegrationTest
|
||||
Debug.Assert(before.ContentVersions == 12); // 10 historic + current draft + current published
|
||||
Debug.Assert(before.PropertyData == 12 * 3); // CreateSimpleContentType = 3 props
|
||||
|
||||
ContentVersionService.PerformContentVersionCleanup(DateTime.Now.AddHours(1));
|
||||
ContentVersionService.PerformContentVersionCleanup(DateTime.UtcNow.AddHours(1));
|
||||
|
||||
var after = GetReport();
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ internal sealed class ExternalLoginServiceTests : UmbracoIntegrationTest
|
||||
UserService.Save(user);
|
||||
|
||||
var providerKey = Guid.NewGuid().ToString("N");
|
||||
var latest = DateTime.Now.AddDays(-1);
|
||||
var oldest = DateTime.Now.AddDays(-10);
|
||||
var latest = DateTime.UtcNow.AddDays(-1);
|
||||
var oldest = DateTime.UtcNow.AddDays(-10);
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ internal sealed class MemberServiceTests : UmbracoIntegrationTest
|
||||
[Test]
|
||||
public void Can_Set_Last_Login_Date()
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var now = DateTime.UtcNow;
|
||||
var memberType = MemberTypeService.Get("member");
|
||||
IMember member = new Member("xname", "xemail", "xusername", "xrawpassword", memberType, true)
|
||||
{
|
||||
@@ -142,7 +142,7 @@ internal sealed class MemberServiceTests : UmbracoIntegrationTest
|
||||
[Test]
|
||||
public void Can_Set_Last_Lockout_Date()
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var now = DateTime.UtcNow;
|
||||
var memberType = MemberTypeService.Get("member");
|
||||
IMember member =
|
||||
new Member("xname", "xemail", "xusername", "xrawpassword", memberType, true) { LastLockoutDate = now };
|
||||
@@ -161,7 +161,7 @@ internal sealed class MemberServiceTests : UmbracoIntegrationTest
|
||||
[Test]
|
||||
public void Can_set_Last_Login_Date()
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var now = DateTime.UtcNow;
|
||||
var memberType = MemberTypeService.Get("member");
|
||||
IMember member =
|
||||
new Member("xname", "xemail", "xusername", "xrawpassword", memberType, true) { LastLoginDate = now };
|
||||
@@ -180,7 +180,7 @@ internal sealed class MemberServiceTests : UmbracoIntegrationTest
|
||||
[Test]
|
||||
public void Can_Set_Last_Password_Change_Date()
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var now = DateTime.UtcNow;
|
||||
var memberType = MemberTypeService.Get("member");
|
||||
IMember member = new Member("xname", "xemail", "xusername", "xrawpassword", memberType, true)
|
||||
{
|
||||
|
||||
@@ -226,7 +226,7 @@ internal sealed class RelationServiceTests : UmbracoIntegrationTest
|
||||
{
|
||||
var rs = RelationService;
|
||||
|
||||
var date = DateTime.Now.AddDays(-10);
|
||||
var date = DateTime.UtcNow.AddDays(-10);
|
||||
var newRelations = CreateRelations(10);
|
||||
foreach (var r in newRelations)
|
||||
{
|
||||
@@ -238,7 +238,7 @@ internal sealed class RelationServiceTests : UmbracoIntegrationTest
|
||||
RelationService.Save(newRelations);
|
||||
Assert.IsTrue(newRelations.All(x => x.UpdateDate == date));
|
||||
|
||||
var newDate = DateTime.Now.AddDays(-5);
|
||||
var newDate = DateTime.UtcNow.AddDays(-5);
|
||||
foreach (var r in newRelations)
|
||||
{
|
||||
r.UpdateDate = newDate;
|
||||
|
||||
@@ -725,7 +725,7 @@ internal sealed class UserServiceTests : UmbracoIntegrationTest
|
||||
public void Count_All_Online_Users()
|
||||
{
|
||||
var users = UserBuilder.CreateMulipleUsers(10,
|
||||
(i, member) => member.LastLoginDate = DateTime.Now.AddMinutes(i * -2));
|
||||
(i, member) => member.LastLoginDate = DateTime.UtcNow.AddMinutes(i * -2));
|
||||
UserService.Save(users);
|
||||
|
||||
var customUser = UserBuilder.CreateUser();
|
||||
|
||||
Reference in New Issue
Block a user