Exemple #1
0
        private void PublishKeepAlive(IModel ch)
        {
            var keepAlive = _sensuClientConfigurationReader.Configuration.Config["client"];

            keepAlive["timestamp"] = SensuClientHelper.CreateTimeStamp();
            keepAlive["version"]   = Version; // Undocumented stuff to send the client version
            keepAlive["plugins"]   = "";

            List <string> redactlist = null;

            redactlist = SensuClientHelper.GetRedactlist((JObject)keepAlive);

            var payload = SensuClientHelper.RedactSensitiveInformaton(keepAlive, redactlist);

            Log.Debug("Publishing keepalive");
            var properties = new BasicProperties
            {
                ContentType  = "application/octet-stream",
                Priority     = 0,
                DeliveryMode = 1
            };

            try
            {
                ch.BasicPublish("", "keepalives", properties, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload)));
            }
            catch (Exception)
            {
                Log.Error("Lost MQ connection when trying to publish keepalives!");
            }
        }
Exemple #2
0
        public void should_return_empty_redactlist_when_client_has_no_redact_key()
        {
            string        jsonparams = @"{
                client: { 
              }
            }";
            var           check      = JObject.Parse(jsonparams);
            List <string> redactlist = null;

            redactlist = SensuClientHelper.GetRedactlist(check);
            Assert.That(redactlist, Is.Null);
        }
Exemple #3
0
        public void should_not_brake_when_empty_client_redact_string()
        {
            string        jsonparams = @"{
                client: { 
                redact: ''
              }
            }";
            var           check      = JObject.Parse(jsonparams);
            List <string> redactlist = null;

            redactlist = SensuClientHelper.GetRedactlist(check);
            Assert.That(redactlist, Is.Null);
        }
Exemple #4
0
        public void should_be_able_to_parse_redact_string_to_list()
        {
            string        jsonparams = @"{
                client: { 
                redact: 'password passwd pass api_key secret'
              }
            }";
            var           check      = JObject.Parse(jsonparams);
            List <string> redactlist = null;

            redactlist = SensuClientHelper.GetRedactlist(check);
            redactlist.ShouldContain("password");
        }