mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-05 23:34:09 +02:00
feat: add password protection for channels
- Updated IChatService to include password parameter in JoinChannelAsync method. - Modified ChannelDto and related models to support password functionality. - Implemented password handling in ChannelService for channel creation and membership validation. - Enhanced IrcCommandHandler to manage channel join requests with passwords. - Added ChannelPasswordDialog for user input when joining protected channels. - Created database migration to add PasswordHash column to Channels table. - Updated tests to cover new password functionality in channel joining and management.
This commit is contained in:
@@ -193,7 +193,7 @@ public class CommandHandlerTests
|
||||
{
|
||||
var handler = CreateHandler();
|
||||
string? capturedChannel = null;
|
||||
handler.OnJoinChannel += ch => { capturedChannel = ch; return Task.CompletedTask; };
|
||||
handler.OnJoinChannel += (ch, _) => { capturedChannel = ch; return Task.CompletedTask; };
|
||||
|
||||
await handler.HandleAsync("/join #random");
|
||||
Assert.Equal("random", capturedChannel);
|
||||
@@ -204,12 +204,25 @@ public class CommandHandlerTests
|
||||
{
|
||||
var handler = CreateHandler();
|
||||
string? capturedChannel = null;
|
||||
handler.OnJoinChannel += ch => { capturedChannel = ch; return Task.CompletedTask; };
|
||||
handler.OnJoinChannel += (ch, _) => { capturedChannel = ch; return Task.CompletedTask; };
|
||||
|
||||
await handler.HandleAsync("/join random");
|
||||
Assert.Equal("random", capturedChannel);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_Join_WithPassword_PassesPassword()
|
||||
{
|
||||
var handler = CreateHandler();
|
||||
string? capturedChannel = null;
|
||||
string? capturedPassword = null;
|
||||
handler.OnJoinChannel += (ch, pw) => { capturedChannel = ch; capturedPassword = pw; return Task.CompletedTask; };
|
||||
|
||||
await handler.HandleAsync("/join #secret hunter2");
|
||||
Assert.Equal("secret", capturedChannel);
|
||||
Assert.Equal("hunter2", capturedPassword);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HandleAsync_Join_NoArgs_ReturnsError()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user