コード例 #1
0
            public void WithInvalidKey_Throws()
            {
                var options = new ChannelOptions(new CipherParams(Crypto.DefaultAlgorithm, new byte[] { 1, 2, 3 }));
                var encoder = new CipherEncoder();
                var error   = Assert.Throws <AblyException>(delegate
                {
                    encoder.Encode(new Message {
                        Data = "string"
                    }, options.ToDecodingContext());
                });

                error.InnerException.Should().BeOfType <CryptographicException>();
            }
コード例 #2
0
            public void WithInvalidKeyLength_Throws()
            {
                var options = new ChannelOptions(new CipherParams(Crypto.DefaultAlgorithm, new byte[] { }, keyLength: 10));
                var encoder = new CipherEncoder(Protocol.MsgPack);
                var error   = Assert.Throws <AblyException>(delegate
                {
                    encoder.Encode(new Message()
                    {
                        Data = "string"
                    }, options);
                });

                error.InnerException.Should().BeOfType <CryptographicException>();
            }
コード例 #3
0
            public void WithInvalidAlgorithm_Throws()
            {
                var keyGen = new Rfc2898DeriveBytes("password", 8);
                var key    = keyGen.GetBytes(Crypto.DefaultKeylength / 8);

                var options = new ChannelOptions(new CipherParams("mgg", key));
                var encoder = new CipherEncoder();
                var error   = Assert.Throws <AblyException>(() =>
                {
                    encoder.Encode(new Message {
                        Data = "string"
                    }, options.ToDecodingContext());
                });

                error.Message.Should().Contain("Currently only the AES encryption algorithm is supported");
            }