mirror of
https://github.com/Govor-team/Govor.git
synced 2026-11-16 20:56:03 +00:00
Expose chat read positions and E2EE errors
Add optional chat activity and read-position details to the unread-count endpoint. Return stable E2EE rejection codes for stale timestamps and untrusted signing devices, with tests for both behaviors.
This commit is contained in:
@@ -2,6 +2,7 @@ using AutoMapper;
|
||||
using Govor.API.Common.SignalR.Helpers;
|
||||
using Govor.API.Hubs;
|
||||
using Govor.API.Hubs.Infrastructure;
|
||||
using Govor.Application.E2ee;
|
||||
using Govor.Application.Exceptions.VerifyFriendship;
|
||||
using Govor.Application.Infrastructure.Common;
|
||||
using Govor.Application.Messages;
|
||||
@@ -106,6 +107,21 @@ public class ChatsHubTests
|
||||
Assert.That((await _hub.Send(new(){EncryptedContent="cipher"})).Status,Is.EqualTo(HubResultStatus.BadRequest));
|
||||
}
|
||||
|
||||
[TestCase(E2eeProtocol.SigningDeviceRejectedError, HubResultStatus.Forbidden)]
|
||||
[TestCase(E2eeProtocol.TimestampOutOfRangeError, HubResultStatus.BadRequest)]
|
||||
[TestCase(E2eeProtocol.DevicesChangedError, HubResultStatus.BadRequest)]
|
||||
public async Task SendReturnsSafeE2eeRejectionCodeWithoutNotifying(string code, HubResultStatus status)
|
||||
{
|
||||
Exception error = status == HubResultStatus.Forbidden
|
||||
? new UnauthorizedAccessException(code) : new ArgumentException(code);
|
||||
_send.Setup(x => x.SendMessageAsync(It.IsAny<SendMessage>()))
|
||||
.ReturnsAsync(new SendMessageResult(false, error, null!));
|
||||
var response = await _hub.Send(new() { RecipientId = _chat, EncryptedContent = "cipher" });
|
||||
Assert.That(response.Status, Is.EqualTo(status));
|
||||
Assert.That(response.ErrorMessage, Is.EqualTo(code));
|
||||
_notifier.VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ReadMapsCurrentReadersViewAndNotifies()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user