public async Task WithEncryptionCipherMismatch_ShouldLeaveMessageEncryptedAndLogError(Protocol protocol) { var loggerSink = new TestLoggerSink(); ILogger logger = new IO.Ably.DefaultLogger.InternalLogger(LogLevel.Error, loggerSink); logger.LogLevel.ShouldBeEquivalentTo(LogLevel.Error); logger.IsDebug.ShouldBeEquivalentTo(false); var client = await GetRestClient(protocol, options => { options.Logger = logger; // pass the logger into the client }); var opts = GetOptions(examples); opts.Logger = logger; var channel1 = client.Channels.Get("persisted:encryption", opts); var payload = "test payload"; await channel1.PublishAsync("test", payload); var channel2 = client.Channels.Get("persisted:encryption", new ChannelOptions(logger, true)); var message = (await channel2.HistoryAsync()).Items.First(); loggerSink.LastLoggedLevel.Should().Be(LogLevel.Error); message.Encoding.Should().Be("utf-8/cipher+aes-128-cbc"); }
public ClosedStateSpecs(ITestOutputHelper output) : base(output) { var sink = new TestLoggerSink(); _logger = new IO.Ably.DefaultLogger.InternalLogger(Defaults.DefaultLogLevel, sink); _context = new FakeConnectionContext(); _state = new ConnectionClosedState(_context, _logger); }
public void ACustomLoggerCanBeProvided() { var logger = new IO.Ably.DefaultLogger.InternalLogger(); var sink = new TestLoggerSink(); logger.LoggerSink = sink; logger.Error("Boo"); sink.LastLevel.Should().Be(LogLevel.Error); sink.LastMessage.Should().Contain("Boo"); }
public async Task WithEncryptionCipherAlgorithmMismatch_ShouldLeaveMessageEncryptedAndLogError(Protocol protocol) { var loggerSink = new TestLoggerSink(); var logger = new IO.Ably.DefaultLogger.InternalLogger(Defaults.DefaultLogLevel, loggerSink); var client = await GetRestClient(protocol); var channel1 = client.Channels.Get("persisted:encryption", GetOptions(examples)); var payload = "test payload"; await channel1.PublishAsync("test", payload); var channel2 = client.Channels.Get("persisted:encryption", new ChannelOptions(logger, true, new CipherParams(Crypto.GenerateRandomKey(128, CipherMode.CBC)))); var message = (await channel2.HistoryAsync()).Items.First(); loggerSink.LastLoggedLevel.Should().Be(LogLevel.Error); loggerSink.LastMessage.Should().Contain("Error decrypting payload"); message.Encoding.Should().Be("utf-8/cipher+aes-128-cbc"); }
public void DefaultLogLevelShouldBeWarning() { var logger = new IO.Ably.DefaultLogger.InternalLogger(); logger.LogLevel.Should().Be(LogLevel.Warning); }
public void DefaultLoggerSinkShouldbeSetup() { var logger = new IO.Ably.DefaultLogger.InternalLogger(); logger.LoggerSink.Should().BeOfType <DefaultLoggerSink>(); }