Пример #1
0
        public async Task ExtractOwnershipFromK8sAudit()
        {
            // Arrange
            await using var context = JosekiTestsDb.CreateUniqueContext();

            var cache     = new OwnershipCache(context, new MemoryCache(new MemoryCacheOptions()));
            var processor = new ExtractOwnershipProcessor(context, cache);

            context.Ownership.Count().Should().Be(0, "ownership list should be empty");

            var auditMetaPath = Path.Combine("audits", "samples", "k8s_audit.json");

            var audit = new Audit
            {
                MetadataKube = new MetadataKube
                {
                    Id      = 1,
                    AuditId = string.Empty,
                    Date    = DateTime.Now,
                    JSON    = File.ReadAllText(auditMetaPath),
                },
            };

            await processor.Process(audit, CancellationToken.None);

            var list = context.Ownership.ToList();

            context.Ownership.Count().Should().Be(2, "ownership list should have 2 items");
        }
Пример #2
0
        public async Task ExtractOwnershipFromAzskAudit()
        {
            // Arrange
            await using var context = JosekiTestsDb.CreateUniqueContext();

            context.Ownership.Count().Should().Be(0, "ownership list should be empty");

            var cache         = new OwnershipCache(context, new MemoryCache(new MemoryCacheOptions()));
            var processor     = new ExtractOwnershipProcessor(context, cache);
            var auditMetaPath = Path.Combine("audits", "samples", "azsk_audit.json");

            var audit = new Audit
            {
                MetadataAzure = new MetadataAzure
                {
                    Id      = 1,
                    AuditId = string.Empty,
                    Date    = DateTime.Now,
                    JSON    = File.ReadAllText(auditMetaPath),
                },
            };

            await processor.Process(audit, CancellationToken.None);

            var list = context.Ownership.ToList();

            context.Ownership.Count().Should().Be(17, "ownership list should have 17 items");

            foreach (var expectedComponentId in azskAuditComponentIds)
            {
                var item = context.Ownership.FirstOrDefault(x => x.ComponentId == expectedComponentId);
                item.Should().NotBe(null, expectedComponentId);
            }
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AzskAuditProcessor"/> class.
 /// </summary>
 /// <param name="blobStorage">Blob Storage implementation.</param>
 /// <param name="db">Joseki database implementation.</param>
 /// <param name="cache">Checks cache object.</param>
 /// <param name="postProcessor">ExtractOwnershipProcessor.</param>
 public AzskAuditProcessor(IBlobStorageProcessor blobStorage, IJosekiDatabase db, ChecksCache cache, ExtractOwnershipProcessor postProcessor)
 {
     this.blobStorage = blobStorage;
     this.db          = db;
     this.cache       = cache;
     this.extractOwnershipProcessor = postProcessor;
 }