Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -14,6 +14,8 @@ using StellaOps.Concelier.SbomIntegration.Models;
|
||||
using StellaOps.Concelier.SbomIntegration.Parsing;
|
||||
using Xunit;
|
||||
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Concelier.SbomIntegration.Tests;
|
||||
|
||||
public class SbomParserTests
|
||||
@@ -28,7 +30,8 @@ public class SbomParserTests
|
||||
|
||||
#region CycloneDX Tests
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ParseAsync_CycloneDX_ExtractsPurls()
|
||||
{
|
||||
// Arrange
|
||||
@@ -75,7 +78,8 @@ public class SbomParserTests
|
||||
result.Purls.Should().Contain("pkg:npm/express@4.18.2");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ParseAsync_CycloneDX_HandlesNestedComponents()
|
||||
{
|
||||
// Arrange
|
||||
@@ -112,7 +116,8 @@ public class SbomParserTests
|
||||
result.Purls.Should().Contain("pkg:npm/child@2.0.0");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ParseAsync_CycloneDX_SkipsComponentsWithoutPurl()
|
||||
{
|
||||
// Arrange
|
||||
@@ -148,7 +153,8 @@ public class SbomParserTests
|
||||
result.UnresolvedComponents[0].Name.Should().Be("without-purl");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ParseAsync_CycloneDX_DeduplicatesPurls()
|
||||
{
|
||||
// Arrange
|
||||
@@ -178,7 +184,8 @@ public class SbomParserTests
|
||||
result.Purls.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ParseAsync_CycloneDX17_ExtractsPurls()
|
||||
{
|
||||
// Arrange - CycloneDX 1.7 format
|
||||
@@ -220,7 +227,8 @@ public class SbomParserTests
|
||||
|
||||
#region SPDX Tests
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ParseAsync_SPDX_ExtractsPurls()
|
||||
{
|
||||
// Arrange
|
||||
@@ -269,7 +277,8 @@ public class SbomParserTests
|
||||
result.Purls.Should().Contain("pkg:npm/express@4.18.2");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ParseAsync_SPDX_IgnoresNonPurlExternalRefs()
|
||||
{
|
||||
// Arrange
|
||||
@@ -313,7 +322,8 @@ public class SbomParserTests
|
||||
|
||||
#region Format Detection Tests
|
||||
|
||||
[Theory]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Theory]
|
||||
[InlineData("1.4")]
|
||||
[InlineData("1.5")]
|
||||
[InlineData("1.6")]
|
||||
@@ -340,7 +350,8 @@ public class SbomParserTests
|
||||
result.SpecVersion.Should().Be(specVersion);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task DetectFormatAsync_SPDX2_DetectsFormat()
|
||||
{
|
||||
// Arrange
|
||||
@@ -362,7 +373,8 @@ public class SbomParserTests
|
||||
result.SpecVersion.Should().Be("SPDX-2.3");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task DetectFormatAsync_UnknownFormat_ReturnsNotDetected()
|
||||
{
|
||||
// Arrange
|
||||
@@ -381,7 +393,8 @@ public class SbomParserTests
|
||||
result.IsDetected.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task DetectFormatAsync_InvalidJson_ReturnsNotDetected()
|
||||
{
|
||||
// Arrange
|
||||
@@ -400,7 +413,8 @@ public class SbomParserTests
|
||||
|
||||
#region PURL Ecosystem Tests
|
||||
|
||||
[Theory]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Theory]
|
||||
[InlineData("pkg:npm/lodash@4.17.21")]
|
||||
[InlineData("pkg:pypi/requests@2.28.0")]
|
||||
[InlineData("pkg:maven/org.apache.commons/commons-lang3@3.12.0")]
|
||||
@@ -440,7 +454,8 @@ public class SbomParserTests
|
||||
|
||||
#region Edge Cases
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ParseAsync_EmptyComponents_ReturnsEmptyPurls()
|
||||
{
|
||||
// Arrange
|
||||
@@ -462,7 +477,8 @@ public class SbomParserTests
|
||||
result.TotalComponents.Should().Be(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ParseAsync_NullStream_ThrowsArgumentNullException()
|
||||
{
|
||||
// Act & Assert
|
||||
@@ -470,7 +486,8 @@ public class SbomParserTests
|
||||
_parser.ParseAsync(null!, SbomFormat.CycloneDX));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ParseAsync_ExtractsCpes()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
Reference in New Issue
Block a user