Exemplo n.º 1
0
        public void WhenMethodAndSeveritiesEmpty_ThenCreateFilterStringSkipsCriteria()
        {
            var filter = AuditLogAdapter.CreateFilterString(
                null,
                Enumerable.Empty <ulong>(),
                Enumerable.Empty <string>(),
                Enumerable.Empty <string>(),
                new DateTime(2020, 1, 2, 3, 4, 5, 6, DateTimeKind.Utc));

            Assert.AreEqual(
                "resource.type=\"gce_instance\" " +
                "AND timestamp > \"2020-01-02T03:04:05.0060000Z\"",
                filter);
        }
Exemplo n.º 2
0
        public void WhenZonesSpecified_ThenCreateFilterStringAddsCriteria()
        {
            var filter = AuditLogAdapter.CreateFilterString(
                new[] { "us-central1-a" },
                null,
                Enumerable.Empty <string>(),
                Enumerable.Empty <string>(),
                new DateTime(2020, 1, 2, 3, 4, 5, 6, DateTimeKind.Utc));

            Assert.AreEqual(
                "resource.labels.zone=(\"us-central1-a\") " +
                "AND resource.type=\"gce_instance\" " +
                "AND timestamp > \"2020-01-02T03:04:05.0060000Z\"",
                filter);
        }
Exemplo n.º 3
0
        public void WhenInstanceIdSpecified_ThenCreateFilterStringAddsCriteria()
        {
            var filter = AuditLogAdapter.CreateFilterString(
                null,
                new[] { 123454321234ul },
                Enumerable.Empty <string>(),
                Enumerable.Empty <string>(),
                new DateTime(2020, 1, 2, 3, 4, 5, 6, DateTimeKind.Utc));

            Assert.AreEqual(
                "resource.labels.instance_id=(\"123454321234\") " +
                "AND resource.type=\"gce_instance\" " +
                "AND timestamp > \"2020-01-02T03:04:05.0060000Z\"",
                filter);
        }
Exemplo n.º 4
0
        public void WhenMethodAndSeveritiesSpecified_ThenCreateFilterStringAddsCriteria()
        {
            var filter = AuditLogAdapter.CreateFilterString(
                null,
                null,
                new[] { "method-1", "method-2" },
                new[] { "INFO", "ERROR" },
                new DateTime(2020, 1, 2, 3, 4, 5, 6, DateTimeKind.Utc));

            Assert.AreEqual(
                "protoPayload.methodName=(\"method-1\" OR \"method-2\") " +
                "AND severity=(\"INFO\" OR \"ERROR\") AND resource.type=\"gce_instance\" " +
                "AND timestamp > \"2020-01-02T03:04:05.0060000Z\"",
                filter);
        }