Add unit tests for RancherHubConnector and various exporters
- Implemented tests for RancherHubConnector to validate fetching documents, handling errors, and managing state. - Added tests for CsafExporter to ensure deterministic serialization of CSAF documents. - Created tests for CycloneDX exporters and reconciler to verify correct handling of VEX claims and output structure. - Developed OpenVEX exporter tests to confirm the generation of canonical OpenVEX documents and statement merging logic. - Introduced Rust file caching and license scanning functionality, including a cache key structure and hash computation. - Added sample Cargo.toml and LICENSE files for testing Rust license scanning functionality.
This commit is contained in:
		@@ -1,4 +1,6 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using StellaOps.Scanner.Analyzers.Lang.Rust;
 | 
			
		||||
using StellaOps.Scanner.Analyzers.Lang.Tests.Harness;
 | 
			
		||||
using StellaOps.Scanner.Analyzers.Lang.Tests.TestUtilities;
 | 
			
		||||
@@ -31,4 +33,27 @@ public sealed class RustLanguageAnalyzerTests
 | 
			
		||||
            cancellationToken,
 | 
			
		||||
            usageHints);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Fact]
 | 
			
		||||
    public async Task AnalyzerIsThreadSafeUnderConcurrencyAsync()
 | 
			
		||||
    {
 | 
			
		||||
        var cancellationToken = TestContext.Current.CancellationToken;
 | 
			
		||||
        var fixturePath = TestPaths.ResolveFixture("lang", "rust", "simple");
 | 
			
		||||
 | 
			
		||||
        var analyzers = new ILanguageAnalyzer[]
 | 
			
		||||
        {
 | 
			
		||||
            new RustLanguageAnalyzer()
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        var workers = Math.Max(Environment.ProcessorCount, 4);
 | 
			
		||||
        var tasks = Enumerable.Range(0, workers)
 | 
			
		||||
            .Select(_ => LanguageAnalyzerTestHarness.RunToJsonAsync(fixturePath, analyzers, cancellationToken));
 | 
			
		||||
 | 
			
		||||
        var results = await Task.WhenAll(tasks);
 | 
			
		||||
        var baseline = results[0];
 | 
			
		||||
        foreach (var result in results)
 | 
			
		||||
        {
 | 
			
		||||
            Assert.Equal(baseline, result);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user