Skip to content

Commit

Permalink
Merge branch 'CA-SBOM-DEV' into DependencymappingforMAVEN for Resolvi…
Browse files Browse the repository at this point in the history
…ng conflicts
  • Loading branch information
karthika-g committed Jul 28, 2023
2 parents 55abc44 + 929aeef commit b13ce27
Show file tree
Hide file tree
Showing 7 changed files with 27,671 additions and 18 deletions.
84 changes: 84 additions & 0 deletions src/LCT.PackageIdentifier.UTest/LCT.PackageIdentifier.UTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,90 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>-->
<ItemGroup>
<ProjectReference Include="..\LCT.PackageIdentifier\LCT.PackageIdentifier.csproj" />
<ProjectReference Include="..\UnitTestUtilities\UnitTestUtilities.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="PackageIdentifierUTTestFiles\CycloneDX2_Python.cdx.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\Cyclonedx_Debian.cdx.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\Cyclonedx2_Debian.cdx.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\CycloneDX2_NPM.cdx.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\CycloneDX_NPM.cdx.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\CycloneDX_Python.cdx.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\Duplicate_Cyclonedx.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\MavenDevDependency\bom-without.cdx.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\MavenDevDependency\bom.cdx.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\MavenDevDependency\WithDev\bom-without.cdx.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\MavenDevDependency\WithDev\bom.cdx.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\MavenDevDependency\WithOneInputFile\bom-without.cdx.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\package-lock16.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\POM.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\project.assets.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\SourceDetails_Cyclonedx.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\TestDir\DupDir\package-lock.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\TestDir\DupDir\package.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\packages.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\packages.lock.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\TestDir\package-lock.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\TestDir\package.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\TestDir\SubDir\package-lock.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\TestDir\SubDir\package.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\Cyclonedx_Maven.cdx.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PackageIdentifierUTTestFiles\Cyclonedx2_Maven.cdx.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LCT.PackageIdentifier\LCT.PackageIdentifier.csproj" />
<ProjectReference Include="..\UnitTestUtilities\UnitTestUtilities.csproj" />
Expand Down
62 changes: 59 additions & 3 deletions src/LCT.PackageIdentifier.UTest/MavenParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void ParsePackageFile_PackageLockWithDuplicateComponents_ReturnsCountOfDu
Bom bom = MavenProcessor.ParsePackageFile(appSettings);

//Assert
Assert.That(bom.Components.Count, Is.EqualTo(2), "Returns the count of components");
Assert.That(bom.Components.Count, Is.EqualTo(1), "Returns the count of components");
Assert.That(bom.Dependencies.Count, Is.EqualTo(4), "Returns the count of dependencies");

}
Expand Down Expand Up @@ -175,7 +175,7 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData_SuccessFully()
var components = new List<Component>() { component1 };
string[] reooListArr = { "siparty-release-maven-egll", "org1-bintray-maven-remote-cache" };
CommonAppSettings appSettings = new();
appSettings.Maven = new Common.Model.Config() { JfrogMavenRepoList = reooListArr };
appSettings.Maven = new Config() { JfrogMavenRepoList = reooListArr };
AqlResult aqlResult = new()
{
Name = "junit-junit-1.0.0.tgz",
Expand Down Expand Up @@ -214,7 +214,7 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData2_SuccessFully(
var components = new List<Component>() { component1 };
string[] reooListArr = { "siparty-release-maven-egll", "org1-bintray-maven-remote-cache" };
CommonAppSettings appSettings = new();
appSettings.Maven = new Common.Model.Config() { JfrogMavenRepoList = reooListArr };
appSettings.Maven = new Config() { JfrogMavenRepoList = reooListArr };
AqlResult aqlResult = new()
{
Name = "junit-junit-1.0.0.tgz",
Expand All @@ -238,5 +238,61 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData2_SuccessFully(
// Assert
Assert.That(actual, Is.Not.Null);
}

[Test]
public void DevDependencyIdentificationLogic_ReturnsCountOfDevDependentcomponents_SuccessFully()
{
//Arrange
string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string outFolder = Path.GetDirectoryName(exePath);
string filepath = outFolder + @"\PackageIdentifierUTTestFiles\MavenDevDependency";
string[] Includes = { "*.cdx.json" };
string[] Excludes = { "lol" };

CommonAppSettings appSettings = new CommonAppSettings()
{
PackageFilePath = filepath,
ProjectType = "MAVEN",
RemoveDevDependency = true,
Maven = new Config() { Include = Includes, Exclude = Excludes }
};

MavenProcessor MavenProcessor = new MavenProcessor();

//Act
Bom bom = MavenProcessor.ParsePackageFile(appSettings);

//Assert
Assert.That(BomCreator.bomKpiData.DevDependentComponents, Is.EqualTo(6), "Returns the count of components");

}
[Test]
public void DevDependencyIdentificationLogic_ReturnsCountOfComponents_WithoutDevdependency()
{
//Arrange
string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string outFolder = Path.GetDirectoryName(exePath);
string filepath = outFolder + @"\PackageIdentifierUTTestFiles\MavenDevDependency\WithOneInputFile";
string[] Includes = { "*.cdx.json" };
string[] Excludes = { "lol" };

CommonAppSettings appSettings = new CommonAppSettings()
{
PackageFilePath = filepath,
ProjectType = "MAVEN",
RemoveDevDependency = true,
Maven = new Config() { Include = Includes, Exclude = Excludes }
};

MavenProcessor MavenProcessor = new MavenProcessor();

//Act
Bom bom = MavenProcessor.ParsePackageFile(appSettings);

//Assert
Assert.That(BomCreator.bomKpiData.DevDependentComponents, Is.EqualTo(0), "Returns the count of components");

}

}
}
Loading

0 comments on commit b13ce27

Please sign in to comment.