From a109509a30dacbfd758ed853b7c42012ef914d12 Mon Sep 17 00:00:00 2001 From: Karthika Geethanand <40568919+karthika-g@users.noreply.github.com> Date: Mon, 10 Jul 2023 16:13:09 +0530 Subject: [PATCH] Unit Test modification for AQL (#57) * Update compile.yml * Update compile.yml * Update compile.yml * hotfix 3.1.2 for artifactory repository name info for NuGet packages (#55) * Update CA_UsageDocument.md * Hotfix v3.1.2 - Bug fix for getting correct artifactory repo name from Jfrog for NuGet (#54) * Update compile.yml * Artifactory Repo identification bug fix * Usage document update * Unit test case update * nuspec version change * nuspec file change * Warn message changed to info --------- Co-authored-by: MadanReddyK <125262006+MadanReddyK@users.noreply.github.com> --------- Co-authored-by: MadanReddyK <125262006+MadanReddyK@users.noreply.github.com> * modified the UT for AQL --------- Co-authored-by: MadanReddyK <125262006+MadanReddyK@users.noreply.github.com> --- .github/workflows/compile.yml | 2 +- .../MavenParserTests.cs | 30 +++++----- .../NpmProcessorUTest.cs | 30 +++++----- .../NugetParserTests.cs | 57 ++++++++++--------- src/LCT.Services.UTest/JFrogServiceUTest.cs | 4 +- 5 files changed, 62 insertions(+), 61 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 59c7cd52..9992b972 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -7,8 +7,8 @@ on: - cron: "30 0 * * 5" jobs: + build: - runs-on: self-hosted defaults: diff --git a/src/LCT.PackageIdentifier.UTest/MavenParserTests.cs b/src/LCT.PackageIdentifier.UTest/MavenParserTests.cs index e531690c..fd05faeb 100644 --- a/src/LCT.PackageIdentifier.UTest/MavenParserTests.cs +++ b/src/LCT.PackageIdentifier.UTest/MavenParserTests.cs @@ -87,14 +87,14 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData_Succes component1.Version = "1.0.0"; var components = new List() { component1 }; ComponentIdentification component = new() { comparisonBOMData = components }; - string[] reooListArr = { "energy-dev-npm-egll", "energy-release-npm-egll" }; + string[] reooListArr = { "internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-1.0.0.tgz", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "energy-dev-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -123,14 +123,14 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData2_Succe component1.Version = "1.0.0"; var components = new List() { component1 }; ComponentIdentification component = new() { comparisonBOMData = components }; - string[] reooListArr = { "energy-dev-npm-egll", "energy-release-npm-egll" }; + string[] reooListArr = { "internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common_license-1.0.0.tgz", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "energy-dev-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -161,14 +161,14 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData3_Succe }; var components = new List() { component1 }; ComponentIdentification componentIdentification = new() { comparisonBOMData = components }; - string[] reooListArr = { "energy-dev-npm-egll", "energy-release-npm-egll" }; + string[] reooListArr = {"internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common-1.0.0.tgz", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "energy-dev-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -199,14 +199,14 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData_SuccessFully() Version = "1.0.0" }; var components = new List() { component1 }; - string[] reooListArr = { "siparty-release-npm-egll", "org1-npmjs-npm-remote-cache" }; + string[] reooListArr = { "internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new(); appSettings.Maven = new Common.Model.Config() { JfrogMavenRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common-1.0.0.tgz", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "siparty-release-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -238,14 +238,14 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData2_SuccessFully( Version = "1.0.0" }; var components = new List() { component1 }; - string[] reooListArr = { "siparty-release-npm-egll", "org1-npmjs-npm-remote-cache" }; + string[] reooListArr = { "internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new(); appSettings.Maven = new Common.Model.Config() { JfrogMavenRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common-1.0.0.tgz", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "siparty-release-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; diff --git a/src/LCT.PackageIdentifier.UTest/NpmProcessorUTest.cs b/src/LCT.PackageIdentifier.UTest/NpmProcessorUTest.cs index abee7c62..3d8466e1 100644 --- a/src/LCT.PackageIdentifier.UTest/NpmProcessorUTest.cs +++ b/src/LCT.PackageIdentifier.UTest/NpmProcessorUTest.cs @@ -31,14 +31,14 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData_Succes component1.Version = "1.0.0"; var components = new List() { component1 }; ComponentIdentification component = new() { comparisonBOMData = components }; - string[] reooListArr = { "energy-dev-npm-egll", "energy-release-npm-egll" }; + string[] reooListArr = { "internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-1.0.0.tgz", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "energy-dev-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -67,14 +67,14 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData2_Succe component1.Version = "1.0.0"; var components = new List() { component1 }; ComponentIdentification component = new() { comparisonBOMData = components }; - string[] reooListArr = { "energy-dev-npm-egll", "energy-release-npm-egll" }; + string[] reooListArr = { "internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common_license-1.0.0.tgz", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "energy-dev-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -105,14 +105,14 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData3_Succe }; var components = new List() { component1 }; ComponentIdentification componentIdentification = new() { comparisonBOMData = components }; - string[] reooListArr = { "energy-dev-npm-egll", "energy-release-npm-egll" }; + string[] reooListArr = { "internalrepo1", "internalrepo1" }; CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common-1.0.0.tgz", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "energy-dev-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -143,14 +143,14 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData_SuccessFully() Version = "1.0.0" }; var components = new List() { component1 }; - string[] reooListArr = { "siparty-release-npm-egll", "org1-npmjs-npm-remote-cache" }; + string[] reooListArr = { "internalrepo1", "internalrepo1" }; CommonAppSettings appSettings = new(); appSettings.Npm = new Common.Model.Config() { JfrogNpmRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common-1.0.0.tgz", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "siparty-release-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -182,14 +182,14 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData2_SuccessFully( Version = "1.0.0" }; var components = new List() { component1 }; - string[] reooListArr = { "siparty-release-npm-egll", "org1-npmjs-npm-remote-cache" }; + string[] reooListArr = { "internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new(); appSettings.Npm = new Common.Model.Config() { JfrogNpmRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common-1.0.0.tgz", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "siparty-release-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; diff --git a/src/LCT.PackageIdentifier.UTest/NugetParserTests.cs b/src/LCT.PackageIdentifier.UTest/NugetParserTests.cs index 97de4054..228af2b7 100644 --- a/src/LCT.PackageIdentifier.UTest/NugetParserTests.cs +++ b/src/LCT.PackageIdentifier.UTest/NugetParserTests.cs @@ -230,14 +230,14 @@ public async Task IdentificationOfInternalComponents_Nuget_ReturnsComponentData_ component1.Version = "1.0.0"; var components = new List() { component1 }; ComponentIdentification component = new() { comparisonBOMData = components }; - string[] reooListArr = { "energy-dev-npm-egll", "energy-release-npm-egll" }; + string[] reooListArr = { "internalrepo1", "internalrepo1" }; CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-1.0.0.nupkg", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "energy-dev-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -267,14 +267,14 @@ public async Task IdentificationOfInternalComponents_Nuget_ReturnsComponentData2 component1.Version = "1.0.0"; var components = new List() { component1 }; ComponentIdentification component = new() { comparisonBOMData = components }; - string[] reooListArr = { "energy-dev-npm-egll", "energy-release-npm-egll" }; + string[] reooListArr = { "internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common_license-1.0.0.nupkg", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "energy-dev-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -305,14 +305,14 @@ public async Task IdentificationOfInternalComponents_ReturnsComponentData3_Succe }; var components = new List() { component1 }; ComponentIdentification componentIdentification = new() { comparisonBOMData = components }; - string[] reooListArr = { "energy-dev-npm-egll", "energy-release-npm-egll" }; + string[] reooListArr = { "internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new() { InternalRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common-1.0.0.nupkg", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "energy-dev-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -343,14 +343,14 @@ public async Task GetJfrogRepoDetailsOfAComponent_ReturnsWithData_SuccessFully() Version = "1.0.0" }; var components = new List() { component1 }; - string[] reooListArr = { "siparty-release-npm-egll", "org1-npmjs-npm-remote-cache" }; + string[] reooListArr = { "internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new(); appSettings.Nuget = new LCT.Common.Model.Config() { JfrogNugetRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common-1.0.0.nupkg", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "siparty-release-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -382,14 +382,14 @@ public async Task GetJfrogRepoDetailsOfAComponent_Nuget_ReturnsWithData2_Success Version = "1.0.0" }; var components = new List() { component1 }; - string[] reooListArr = { "siparty-release-npm-egll", "org1-npmjs-npm-remote-cache" }; + string[] reooListArr = {"internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new(); appSettings.Nuget = new Config() { JfrogNugetRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common-1.0.0.nupkg", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "siparty-release-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -421,14 +421,14 @@ public async Task GetArtifactoryRepoName_Nuget_ReturnsRepoName_SuccessFully() Version = "1.0.0" }; var components = new List() { component1 }; - string[] reooListArr = { "siparty-release-npm-egll", "org1-npmjs-npm-remote-cache" }; + string[] reooListArr = {"internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new(); appSettings.Nuget = new Config() { JfrogNugetRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common-1.0.0.nupkg", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "siparty-release-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new List() { aqlResult }; @@ -460,14 +460,14 @@ public async Task GetArtifactoryRepoName_Nuget_ReturnsRepoName_ReturnsFailure() Version = "1.0.0" }; var components = new List() { component1 }; - string[] reooListArr = { "siparty-release-npm-egll", "org1-npmjs-npm-remote-cache" }; + string[] reooListArr = {"internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new(); appSettings.Nuget = new Config() { JfrogNugetRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animation-test-1.0.0.nupkg", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "siparty-release-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new () { aqlResult }; @@ -499,14 +499,14 @@ public async Task GetArtifactoryRepoName_Nuget_ReturnsRepoName_ReturnsSuccess() Version = "1.0.0" }; var components = new List() { component1 }; - string[] reooListArr = { "siparty-release-npm-egll", "org1-npmjs-npm-remote-cache" }; + string[] reooListArr = {"internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new(); appSettings.Nuget = new Config() { JfrogNugetRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animations-common.1.0.0.nupkg", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "siparty-release-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new() { aqlResult }; @@ -524,7 +524,8 @@ public async Task GetArtifactoryRepoName_Nuget_ReturnsRepoName_ReturnsSuccess() var reponameActual = actual.First(x => x.Properties[0].Name == "internal:siemens:clearing:repo-url").Properties[0].Value; - Assert.That("siparty-release-npm-egll", Is.EqualTo(reponameActual)); + + Assert.That("internalrepo1", Is.EqualTo(reponameActual)); } [Test] public async Task GetArtifactoryRepoName_Nuget_ReturnsNotFound_ReturnsFailure() @@ -538,14 +539,14 @@ public async Task GetArtifactoryRepoName_Nuget_ReturnsNotFound_ReturnsFailure() Version = "1.0.0" }; var components = new List() { component1 }; - string[] reooListArr = { "siparty-release-npm-egll", "org1-npmjs-npm-remote-cache" }; + string[] reooListArr = { "internalrepo1", "internalrepo2" }; CommonAppSettings appSettings = new(); appSettings.Nuget = new Config() { JfrogNugetRepoList = reooListArr }; AqlResult aqlResult = new() { Name = "animation-common.1.0.0.nupkg", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", - Repo = "siparty-release-npm-egll" + Path = "@testfolder/-/folder", + Repo = "internalrepo1" }; List results = new() { aqlResult }; diff --git a/src/LCT.Services.UTest/JFrogServiceUTest.cs b/src/LCT.Services.UTest/JFrogServiceUTest.cs index 1df98a90..4a4a81b9 100644 --- a/src/LCT.Services.UTest/JFrogServiceUTest.cs +++ b/src/LCT.Services.UTest/JFrogServiceUTest.cs @@ -29,8 +29,8 @@ public async Task GetInternalComponentDataByRepo_GetsRepoInfo_Successfully() AqlResult aqlResult = new AqlResult() { - Name = "saap-api-node-2.26.3-LicenseClearing.16.sha-058fada.tgz", - Path = "@siemens-gds/saap-api-node/-/@siemens-gds", + Name = "api-node-2.26.3-LicenseClearing.16.sha-058fada.tgz", + Path = "@testfolder/-/folder", Repo = "energy-dev-npm-egll" };