Exemplo n.º 1
0
 public void AuthenticationExceptionTestsv311()
 {
     Assert.Throws(typeof(NotSupportedException), () =>
     {
         MqttMsgAuthentication authentication = new();
         authentication.GetBytes(MqttProtocolVersion.Version_3_1_1);
     });
     Assert.Throws(typeof(NotSupportedException), () =>
     {
         MqttMsgAuthentication authentication = new();
         authentication.GetBytes(MqttProtocolVersion.Version_3_1);
     });
     Assert.Throws(typeof(NotSupportedException), () =>
     {
         MokChannel mokChannel = new MokChannel(new byte[1] {
             42
         });
         MqttMsgAuthentication authentication = MqttMsgAuthentication.Parse(42, MqttProtocolVersion.Version_3_1_1, mokChannel);
     });
     Assert.Throws(typeof(NotSupportedException), () =>
     {
         MokChannel mokChannel = new MokChannel(new byte[1] {
             42
         });
         MqttMsgAuthentication authentication = MqttMsgAuthentication.Parse(42, MqttProtocolVersion.Version_3_1, mokChannel);
     });
 }
Exemplo n.º 2
0
        public void AuthenticationBasicDecodeTestsv5()
        {
            // Arrange
            byte[] encodedCorrect = new byte[] { 47, 24, 45, 21, 0, 9, 83, 111, 109, 101, 116, 104, 105, 110, 103, 22, 0, 5, 1, 2, 3, 4, 5, 31, 0, 22, 66,
                                                 101, 99, 97, 117, 115, 101, 32, 105, 116, 39, 115, 32, 108, 105, 107, 101, 32, 116, 104, 97, 116 };
            MokChannel mokChannel = new(encodedCorrect);
            // Act
            MqttMsgAuthentication authentication = MqttMsgAuthentication.Parse(240, MqttProtocolVersion.Version_5, mokChannel);

            // Assert
            Assert.Equal(authentication.AuthenticationMethod, "Something");
            Assert.Equal(authentication.AuthenticationData, new byte[] { 1, 2, 3, 4, 5 });
            Assert.Equal((byte)authentication.ReasonCode, (byte)MqttReasonCode.ContinueAuthentication);
            Assert.Equal(authentication.Reason, "Because it's like that");
        }