mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkServerTest: CommandTest tries invalid netid and command without authority too
This commit is contained in:
parent
038e3c1969
commit
bba4ebd154
@ -631,6 +631,27 @@ public void CommandMessageCallsCommandTest()
|
||||
Assert.That(comp0.called, Is.EqualTo(0));
|
||||
Assert.That(comp1.called, Is.EqualTo(1));
|
||||
|
||||
// sending a command without authority should fail
|
||||
// (= if connectionToClient is not what we received the data on)
|
||||
identity.connectionToClient = new ULocalConnectionToClient(); // set wrong authority
|
||||
comp0.called = 0;
|
||||
comp1.called = 0;
|
||||
Transport.activeTransport.OnServerDataReceived.Invoke(0, segment, 0);
|
||||
Assert.That(comp0.called, Is.EqualTo(0));
|
||||
Assert.That(comp1.called, Is.EqualTo(0));
|
||||
identity.connectionToClient = connection; // restore authority
|
||||
|
||||
// sending a component with wrong netId should fail
|
||||
message.netId += 1; // wrong netid
|
||||
writer = new NetworkWriter();
|
||||
MessagePacker.Pack(message, writer); // need to serialize the message again with wrong netid
|
||||
ArraySegment<byte> segmentWrongNetId = writer.ToArraySegment();
|
||||
comp0.called = 0;
|
||||
comp1.called = 0;
|
||||
Transport.activeTransport.OnServerDataReceived.Invoke(0, segmentWrongNetId, 0);
|
||||
Assert.That(comp0.called, Is.EqualTo(0));
|
||||
Assert.That(comp1.called, Is.EqualTo(0));
|
||||
|
||||
// clean up
|
||||
NetworkIdentity.spawned.Clear();
|
||||
NetworkBehaviour.ClearDelegates();
|
||||
|
Loading…
Reference in New Issue
Block a user