mirror of https://github.com/renaissanceorg/dante
Client
- Renamed `authenticate(string username, string password)` to `authenticate_impl(string username, string password)` - Implemented `authenticate(string username, string password)` (Still a work-in-progress) Client (unitests) - Updated unittest for auth testing - Authenticate before sending a message
This commit is contained in:
parent
3b0b1d8466
commit
a42ae467c0
|
@ -106,7 +106,7 @@ public class DanteClient
|
|||
return makeRequest(msg);
|
||||
}
|
||||
|
||||
public Future authenticate(string username, string password)
|
||||
public Future authenticate_impl(string username, string password)
|
||||
{
|
||||
import davinci.c2s.auth;
|
||||
import davinci;
|
||||
|
@ -121,6 +121,28 @@ public class DanteClient
|
|||
return makeRequest(msg);
|
||||
}
|
||||
|
||||
public void authenticate(string username, string password)
|
||||
{
|
||||
import davinci.c2s.auth : AuthMessage;
|
||||
import davinci;
|
||||
BaseMessage response = cast(BaseMessage)authenticate_impl(username, password).await().getValue().value.object;
|
||||
|
||||
// TODO: For absolute sanity we should check that
|
||||
// ... it actually decoded to the type we EXPECT
|
||||
// ... to be here (this would safeguard against
|
||||
// ... bad server implementations)
|
||||
// TODO: Make teh below a `mixin template`
|
||||
Command responseCommand = response.getCommand();
|
||||
AuthMessage chanMemResp = cast(AuthMessage)responseCommand;
|
||||
|
||||
if(chanMemResp is null)
|
||||
{
|
||||
throw ProtocolException.expectedMessageKind(AuthMessage.classinfo, responseCommand);
|
||||
}
|
||||
|
||||
// TODO: Check authentication status here
|
||||
}
|
||||
|
||||
public Future enumerateChannels_imp(ulong offset, ubyte limit)
|
||||
{
|
||||
import davinci.c2s.channels : ChannelEnumerateRequest;
|
||||
|
@ -385,7 +407,7 @@ unittest
|
|||
DanteClient client = new DanteClient(new UnixAddress("/tmp/renaissance.sock"));
|
||||
client.start();
|
||||
|
||||
Future fut = client.authenticate("deavmi", "testpassword");
|
||||
Future fut = client.authenticate_impl("deavmi", "testpassword");
|
||||
|
||||
writeln("Awaitinf future...");
|
||||
Result res = fut.await();
|
||||
|
@ -417,6 +439,17 @@ unittest
|
|||
DanteClient client = new DanteClient(new UnixAddress("/tmp/renaissance.sock"));
|
||||
client.start();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
client.authenticate("deavmi", "testpassword");
|
||||
}
|
||||
catch(DanteException e)
|
||||
{
|
||||
writeln("Got exception: ", e);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
writeln("Joining channel #general...");
|
||||
|
|
Loading…
Reference in New Issue