1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 08:32:50 -05:00

Merge branch 'km/pm-10600-full-notification-content' into km/pm-10564

# Conflicts:
#	src/Core/Models/PushNotification.cs
#	src/Core/Services/IPushNotificationService.cs
#	src/Core/Services/NoopImplementations/NoopPushNotificationService.cs
#	test/Core.Test/NotificationCenter/Commands/CreateNotificationCommandTest.cs
#	test/Core.Test/NotificationHub/NotificationHubPushNotificationServiceTests.cs
#	test/Core.Test/Services/AzureQueuePushNotificationServiceTests.cs
This commit is contained in:
Maciej Zieniuk
2024-11-26 16:04:43 +00:00
23 changed files with 213 additions and 156 deletions

View File

@ -43,10 +43,10 @@ public class CreateNotificationCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.CreateAsync(notification));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
}
[Theory]
@ -64,9 +64,9 @@ public class CreateNotificationCommandTest
Assert.Equal(notification.CreationDate, notification.RevisionDate);
await sutProvider.GetDependency<IPushNotificationService>()
.Received(1)
.PushSyncNotificationAsync(newNotification);
.PushNotificationAsync(newNotification);
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
}
}

View File

@ -53,10 +53,10 @@ public class CreateNotificationStatusCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.CreateAsync(notificationStatus));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -70,10 +70,10 @@ public class CreateNotificationStatusCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.CreateAsync(notificationStatus));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -87,10 +87,10 @@ public class CreateNotificationStatusCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.CreateAsync(notificationStatus));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -106,9 +106,9 @@ public class CreateNotificationStatusCommandTest
Assert.Equal(notificationStatus, newNotificationStatus);
await sutProvider.GetDependency<IPushNotificationService>()
.Received(1)
.PushSyncNotificationStatusAsync(notification, notificationStatus);
.PushNotificationStatusAsync(notification, notificationStatus);
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
}

View File

@ -66,10 +66,10 @@ public class MarkNotificationDeletedCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -83,10 +83,10 @@ public class MarkNotificationDeletedCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -101,10 +101,10 @@ public class MarkNotificationDeletedCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -119,10 +119,10 @@ public class MarkNotificationDeletedCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -137,10 +137,10 @@ public class MarkNotificationDeletedCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkDeletedAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -164,11 +164,11 @@ public class MarkNotificationDeletedCommandTest
.CreateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(1)
.PushSyncNotificationStatusAsync(notification,
.PushNotificationStatusAsync(notification,
Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -185,11 +185,11 @@ public class MarkNotificationDeletedCommandTest
.UpdateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(notificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(1)
.PushSyncNotificationStatusAsync(notification,
.PushNotificationStatusAsync(notification,
Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(notificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
private static void AssertNotificationStatus(NotificationStatus expectedNotificationStatus,

View File

@ -66,10 +66,10 @@ public class MarkNotificationReadCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -83,10 +83,10 @@ public class MarkNotificationReadCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -101,10 +101,10 @@ public class MarkNotificationReadCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -119,10 +119,10 @@ public class MarkNotificationReadCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -137,10 +137,10 @@ public class MarkNotificationReadCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.MarkReadAsync(notificationId));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -164,11 +164,11 @@ public class MarkNotificationReadCommandTest
.CreateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(1)
.PushSyncNotificationStatusAsync(notification,
.PushNotificationStatusAsync(notification,
Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(expectedNotificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
[Theory]
@ -185,11 +185,11 @@ public class MarkNotificationReadCommandTest
.UpdateAsync(Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(notificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(1)
.PushSyncNotificationStatusAsync(notification,
.PushNotificationStatusAsync(notification,
Arg.Do<NotificationStatus>(ns => AssertNotificationStatus(notificationStatus, ns)));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
}
private static void AssertNotificationStatus(NotificationStatus expectedNotificationStatus,

View File

@ -48,10 +48,10 @@ public class UpdateNotificationCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.UpdateAsync(notification));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
}
[Theory]
@ -65,10 +65,10 @@ public class UpdateNotificationCommandTest
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.UpdateAsync(notification));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationAsync(Arg.Any<Notification>());
.PushNotificationAsync(Arg.Any<Notification>());
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
}
[Theory]
@ -106,9 +106,9 @@ public class UpdateNotificationCommandTest
DateTime.UtcNow - n.RevisionDate < TimeSpan.FromMinutes(1)));
await sutProvider.GetDependency<IPushNotificationService>()
.Received(1)
.PushSyncNotificationAsync(notification);
.PushNotificationAsync(notification);
await sutProvider.GetDependency<IPushNotificationService>()
.Received(0)
.PushSyncNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
.PushNotificationStatusAsync(Arg.Any<Notification>(), Arg.Any<NotificationStatus>());
}
}