Skip to content

Commit 851e4f0

Browse files
committed
Resolved issues in test cases
1 parent f7d06a9 commit 851e4f0

File tree

13 files changed

+216941
-0
lines changed

13 files changed

+216941
-0
lines changed

TestFiles/IntegrationTestFiles/DependencyTestFiles/Npm/cdx_dep.json

Lines changed: 65957 additions & 0 deletions
Large diffs are not rendered by default.

TestFiles/IntegrationTestFiles/DependencyTestFiles/Npm/package-lock.json

Lines changed: 20024 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TestFiles/IntegrationTestFiles/DependencyTestFiles/Nuget/cdx_dep.json

Lines changed: 8565 additions & 0 deletions
Large diffs are not rendered by default.

TestFiles/IntegrationTestFiles/DependencyTestFiles/Nuget/project.assets.json

Lines changed: 10458 additions & 0 deletions
Large diffs are not rendered by default.

TestFiles/IntegrationTestFiles/DependencyTestFiles/Python/cdx_dep.json

Lines changed: 4386 additions & 0 deletions
Large diffs are not rendered by default.

TestFiles/IntegrationTestFiles/DependencyTestFiles/Python/poetry.lock

Lines changed: 3185 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// SPDX-FileCopyrightText: 2025 Siemens AG
3+
//
4+
// SPDX-License-Identifier: MIT
5+
6+
// --------------------------------------------------------------------------------------------------------------------
7+
8+
using CycloneDX.Models;
9+
using NUnit.Framework;
10+
using System.IO;
11+
using TestUtilities;
12+
13+
namespace SW360IntegrationTest.NPM
14+
{
15+
[TestFixture, Order(46)]
16+
public class PackageIdentifierDepSBOMNpm
17+
{
18+
private string CCTLocalBomTestFile { get; set; }
19+
private string OutFolder { get; set; }
20+
private static readonly TestParam testParameters = new TestParam();
21+
22+
[SetUp]
23+
public void Setup()
24+
{
25+
OutFolder = TestHelper.OutFolder;
26+
27+
CCTLocalBomTestFile = Path.GetFullPath(Path.Combine(OutFolder, "..", "..", "src", "SW360IntegrationTest", "PackageIdentifierTestFiles", "DepNpm", "CCTLocalBOMNpmInitial.json"));
28+
29+
if (!Directory.Exists(Path.GetFullPath(Path.Combine(OutFolder, "..", "DependencyBOMs"))))
30+
{
31+
Directory.CreateDirectory(Path.GetFullPath(Path.Combine(OutFolder, "..", "DependencyBOMs")));
32+
}
33+
}
34+
35+
[Test, Order(1)]
36+
public void TestBOMCreatorexe()
37+
{
38+
string packagjsonPath = Path.GetFullPath(Path.Combine(OutFolder, "..", "..", "TestFiles", "IntegrationTestFiles", "DependencyTestFiles", "Npm"));
39+
string bomPath = Path.GetFullPath(Path.Combine(OutFolder, "..", "DependencyBOMs"));
40+
41+
// Test BOM Creator ran with exit code 0
42+
Assert.AreEqual(0, TestHelper.RunBOMCreatorExe(new string[]{
43+
TestConstant.PackageFilePath, packagjsonPath,
44+
TestConstant.BomFolderPath, bomPath,
45+
TestConstant.Sw360Token, testParameters.SW360AuthTokenValue,
46+
TestConstant.SW360AuthTokenType, testParameters.SW360AuthTokenType,
47+
TestConstant.SW360URL, testParameters.SW360URL,
48+
TestConstant.SW360ProjectID, testParameters.SW360ProjectID,
49+
TestConstant.SW360ProjectName, testParameters.SW360ProjectName,
50+
TestConstant.JFrogApiURL, testParameters.JfrogApi,
51+
TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey,
52+
TestConstant.JfrogNpmInternalRepo,"Npm-test",
53+
TestConstant.ProjectType, "Npm",
54+
TestConstant.TelemetryEnable, testParameters.TelemetryEnable,
55+
TestConstant.Mode,""}),
56+
"Test to run Package Identifier EXE execution");
57+
}
58+
59+
[Test, Order(2)]
60+
public void TestLocalBOMCreation()
61+
{
62+
bool fileExist = false;
63+
64+
// Expected
65+
ComponentJsonParsor expected = new ComponentJsonParsor();
66+
expected.Read(CCTLocalBomTestFile);
67+
68+
// Actual
69+
string generatedBOM = Path.GetFullPath(Path.Combine(OutFolder, "..", "DependencyBOMs", $"{testParameters.SW360ProjectName}_Bom.cdx.json"));
70+
if (File.Exists(generatedBOM))
71+
{
72+
fileExist = true;
73+
74+
ComponentJsonParsor actual = new ComponentJsonParsor();
75+
actual.Read(generatedBOM);
76+
77+
foreach (var item in expected.Components)
78+
{
79+
foreach (var i in actual.Components)
80+
{
81+
if ((i.Name == item.Name) && (i.Group == item.Group) && (i.Version == item.Version))
82+
{
83+
Component component = i;
84+
Assert.AreEqual(item.Name, component.Name);
85+
Assert.AreEqual(item.Version, component.Version);
86+
Assert.AreEqual(item.Purl, component.Purl);
87+
Assert.AreEqual(item.BomRef, component.BomRef);
88+
}
89+
}
90+
}
91+
Assert.AreEqual(expected.BoM.Dependencies.Count, actual.BoM.Dependencies.Count);
92+
}
93+
94+
Assert.IsTrue(fileExist, "Test to BOM file present");
95+
}
96+
}
97+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// SPDX-FileCopyrightText: 2025 Siemens AG
3+
//
4+
// SPDX-License-Identifier: MIT
5+
6+
// --------------------------------------------------------------------------------------------------------------------
7+
using CycloneDX.Models;
8+
using NUnit.Framework;
9+
using System.IO;
10+
using TestUtilities;
11+
12+
namespace SW360IntegrationTest.Nuget
13+
{
14+
[TestFixture, Order(46)]
15+
public class PackageIdentifierDepSBOMNuget
16+
{
17+
18+
private string CCTLocalBomTestFile { get; set; }
19+
private string OutFolder { get; set; }
20+
TestParamNuget testParameters;
21+
22+
[SetUp]
23+
public void Setup()
24+
{
25+
OutFolder = TestHelper.OutFolder;
26+
27+
CCTLocalBomTestFile = Path.GetFullPath(Path.Combine(OutFolder, "..", "..", "src", "SW360IntegrationTest", "PackageIdentifierTestFiles", "DepNuget", "CCTLocalBOMNugetInitial.json"));
28+
29+
if (!Directory.Exists(Path.GetFullPath(Path.Combine(OutFolder, "..", "DependencyBOMs"))))
30+
{
31+
Directory.CreateDirectory(Path.GetFullPath(Path.Combine(OutFolder, "..", "DependencyBOMs")));
32+
}
33+
testParameters = new TestParamNuget();
34+
}
35+
36+
[Test, Order(1)]
37+
public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess()
38+
{
39+
string packagejsonPath = Path.GetFullPath(Path.Combine(OutFolder, "..", "..", "TestFiles", "IntegrationTestFiles", "SystemTest1stIterationData", "Nuget"));
40+
string bomPath = Path.GetFullPath(Path.Combine(OutFolder, "..", "DependencyBOMs"));
41+
42+
// Test BOM Creator ran with exit code 0
43+
Assert.AreEqual(0, TestHelper.RunBOMCreatorExe(new string[]{
44+
TestConstant.PackageFilePath, packagejsonPath,
45+
TestConstant.BomFolderPath, bomPath,
46+
TestConstant.Sw360Token, testParameters.SW360AuthTokenValue,
47+
TestConstant.SW360AuthTokenType, testParameters.SW360AuthTokenType,
48+
TestConstant.SW360URL, testParameters.SW360URL,
49+
TestConstant.SW360ProjectID, testParameters.SW360ProjectID,
50+
TestConstant.SW360ProjectName, testParameters.SW360ProjectName,
51+
TestConstant.JFrogApiURL, testParameters.JfrogApi,
52+
TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey,
53+
TestConstant.TelemetryEnable, testParameters.TelemetryEnable,
54+
TestConstant.JfrogNugetInternalRepo,"Nuget-test",
55+
TestConstant.ProjectType,"Nuget",
56+
TestConstant.Mode,""}),
57+
"Test to run Package Identifier EXE execution");
58+
}
59+
60+
61+
[Test, Order(2)]
62+
public void LocalBOMCreation_AfterSuccessfulExeRun_ReturnsSuccess()
63+
{
64+
bool fileExist = false;
65+
66+
// Expected
67+
ComponentJsonParsor expected = new ComponentJsonParsor();
68+
expected.Read(CCTLocalBomTestFile);
69+
70+
// Actual
71+
string generatedBOM = Path.GetFullPath(Path.Combine(OutFolder, "..", "DependencyBOMs", $"{testParameters.SW360ProjectName}_Bom.cdx.json"));
72+
if (File.Exists(generatedBOM))
73+
{
74+
fileExist = true;
75+
76+
ComponentJsonParsor actual = new ComponentJsonParsor();
77+
actual.Read(generatedBOM);
78+
79+
foreach (var item in expected.Components)
80+
{
81+
82+
foreach (var i in actual.Components)
83+
{
84+
if ((i.Name == item.Name) && (i.Version == item.Version))
85+
{
86+
Component component = i;
87+
Assert.AreEqual(item.Name, component.Name);
88+
Assert.AreEqual(item.Version, component.Version);
89+
Assert.AreEqual(item.Purl, component.Purl);
90+
Assert.AreEqual(item.BomRef, component.BomRef);
91+
}
92+
}
93+
94+
}
95+
Assert.AreEqual(expected.BoM.Dependencies.Count, actual.BoM.Dependencies.Count);
96+
}
97+
98+
Assert.IsTrue(fileExist, "Test to BOM file present");
99+
}
100+
}
101+
}

0 commit comments

Comments
 (0)