From f82238cfd31f0dee4f4dbdb9f4031e94b7337d7b Mon Sep 17 00:00:00 2001 From: Viji Date: Wed, 24 Jul 2024 11:34:06 +0530 Subject: [PATCH 1/4] version update in ca tool projects --- doc/UsageDoc/CA_UsageDocument.md | 2 +- .../LCT.ArtifactoryUploader.csproj | 1 + src/ArtifactoryUploader/Program.cs | 13 +++++++++++++ .../LCT.APICommunications.csproj | 1 + src/LCT.Common/LCT.Common.csproj | 1 + src/LCT.Common/Model/CatoolInfo.cs | 16 ++++++++++++++++ src/LCT.Common/appSettings.json | 2 +- .../LCT.CycloneDxProcessor.csproj | 1 + src/LCT.Facade/LCT.Facade.csproj | 1 + .../CycloneBomProcessorTests.cs | 8 +++++--- src/LCT.PackageIdentifier/BomCreator.cs | 13 ++++++++++--- src/LCT.PackageIdentifier/CycloneBomProcessor.cs | 8 ++++++-- .../Interface/IBomCreator.cs | 4 +++- .../LCT.PackageIdentifier.csproj | 1 + src/LCT.PackageIdentifier/Program.cs | 15 ++++++++++++++- .../LCT.SW360PackageCreator.csproj | 1 + src/LCT.SW360PackageCreator/Program.cs | 12 ++++++++++++ src/LCT.Services/LCT.Services.csproj | 1 + 18 files changed, 89 insertions(+), 12 deletions(-) create mode 100644 src/LCT.Common/Model/CatoolInfo.cs diff --git a/doc/UsageDoc/CA_UsageDocument.md b/doc/UsageDoc/CA_UsageDocument.md index b87dd0f8..ade3f548 100644 --- a/doc/UsageDoc/CA_UsageDocument.md +++ b/doc/UsageDoc/CA_UsageDocument.md @@ -237,7 +237,7 @@ Currently LTA support is not provided for SBOM, hence until that is implemented ``` { - "CaVersion": "6.2.0", + "CaVersion": "", "TimeOut": 200, "ProjectType": "", "SW360ProjectName": "", diff --git a/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj b/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj index 49c58f26..f2be23ab 100644 --- a/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj +++ b/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj @@ -4,6 +4,7 @@ Exe net8.0 ArtifactoryUploader + 7.0.0 diff --git a/src/ArtifactoryUploader/Program.cs b/src/ArtifactoryUploader/Program.cs index 2c5750fc..7a69617d 100644 --- a/src/ArtifactoryUploader/Program.cs +++ b/src/ArtifactoryUploader/Program.cs @@ -23,6 +23,7 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Threading.Tasks; +using LCT.Common.Model; namespace ArtifactoryUploader { @@ -44,6 +45,7 @@ static async Task Main(string[] args) string FolderPath = InitiateLogger(appSettings); settingsManager.CheckRequiredArgsToRun(appSettings, "Uploader"); + CatoolInfo caToolVersion = GetCatoolVersionFromProjectfile(); Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Artifactory Uploader >>>>>====================", null); Logger.Logger.Log(null, Level.Notice, $"\nStart of Artifactory Uploader execution: {DateTime.Now}", null); @@ -55,6 +57,8 @@ static async Task Main(string[] args) Logger.Logger.Log(null, Level.Info, $"Input Parameters used in Artifactory Uploader:\n\t", null); Logger.Logger.Log(null, Level.Notice, $"\tBomFilePath:\t\t {appSettings.BomFilePath}\n\t" + + $"CaToolVersion\t\t --> {caToolVersion.CatoolVersion}\n\t" + + $"CaToolRunningPath\t --> {caToolVersion.CatoolRunningLocation}\n\t" + $"JFrogUrl:\t\t {appSettings.JFrogApi}\n\t" + $"Release:\t\t {appSettings.Release}\n\t" + $"LogFolderPath:\t\t {Path.GetFullPath(FolderPath)}\n", null); @@ -77,6 +81,15 @@ static async Task Main(string[] args) Logger.Logger.Log(null, Level.Notice, $"End of Artifactory Uploader execution : {DateTime.Now}\n", null); } + private static CatoolInfo GetCatoolVersionFromProjectfile() + { + CatoolInfo catoolInfo = new CatoolInfo(); + var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version; + catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}"; + catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + return catoolInfo; + } + private static string InitiateLogger(CommonAppSettings appSettings) { string FolderPath; diff --git a/src/LCT.APICommunications/LCT.APICommunications.csproj b/src/LCT.APICommunications/LCT.APICommunications.csproj index 675263d8..78f1d279 100644 --- a/src/LCT.APICommunications/LCT.APICommunications.csproj +++ b/src/LCT.APICommunications/LCT.APICommunications.csproj @@ -3,6 +3,7 @@ Library net8.0 + 7.0.0 diff --git a/src/LCT.Common/LCT.Common.csproj b/src/LCT.Common/LCT.Common.csproj index 486a8aa5..fb2cc9d9 100644 --- a/src/LCT.Common/LCT.Common.csproj +++ b/src/LCT.Common/LCT.Common.csproj @@ -3,6 +3,7 @@ Library net8.0 + 7.0.0 diff --git a/src/LCT.Common/Model/CatoolInfo.cs b/src/LCT.Common/Model/CatoolInfo.cs new file mode 100644 index 00000000..80faa6be --- /dev/null +++ b/src/LCT.Common/Model/CatoolInfo.cs @@ -0,0 +1,16 @@ +// -------------------------------------------------------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2024 Siemens AG +// +// SPDX-License-Identifier: MIT +// -------------------------------------------------------------------------------------------------------------------- + + +namespace LCT.Common.Model +{ + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public class CatoolInfo + { + public string CatoolVersion { get; set; } + public string CatoolRunningLocation { get; set; } + } +} \ No newline at end of file diff --git a/src/LCT.Common/appSettings.json b/src/LCT.Common/appSettings.json index d67393b1..f3aa2960 100644 --- a/src/LCT.Common/appSettings.json +++ b/src/LCT.Common/appSettings.json @@ -5,7 +5,7 @@ // -------------------------------------------------------------------------------------------------------------------- { - "CaVersion": "7.0.0", + "CaVersion": "", "TimeOut": 200, "ProjectType": "", "SW360ProjectName": "", diff --git a/src/LCT.CycloneDxProcessor/LCT.CycloneDxProcessor.csproj b/src/LCT.CycloneDxProcessor/LCT.CycloneDxProcessor.csproj index 84aab0c6..82dd43e2 100644 --- a/src/LCT.CycloneDxProcessor/LCT.CycloneDxProcessor.csproj +++ b/src/LCT.CycloneDxProcessor/LCT.CycloneDxProcessor.csproj @@ -2,6 +2,7 @@ netstandard2.0 + 7.0.0 diff --git a/src/LCT.Facade/LCT.Facade.csproj b/src/LCT.Facade/LCT.Facade.csproj index 82d7907d..ece08d21 100644 --- a/src/LCT.Facade/LCT.Facade.csproj +++ b/src/LCT.Facade/LCT.Facade.csproj @@ -2,6 +2,7 @@ net8.0 + 7.0.0 diff --git a/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs b/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs index 3294a806..100169b2 100644 --- a/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs +++ b/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs @@ -39,8 +39,9 @@ public void SetMetadataInComparisonBOM_GivenBOMWithEmptyMetadata_FillsInMetadata { CaVersion = "1.2.3" }; + CatoolInfo caToolInformation = new CatoolInfo() { CatoolVersion = "6.0.0", CatoolRunningLocation="" }; //Act - Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases); + Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases, caToolInformation); //Assert Assert.That(2, Is.EqualTo(files.Metadata.Tools.Count), "Returns bom with metadata "); @@ -92,9 +93,10 @@ public void SetMetadataInComparisonBOM_GivenBOMWithMetadata_AddsNewMetadataInfoI Version = projectReleases.Version, Type = Component.Classification.Application }; - + + CatoolInfo caToolInformation = new CatoolInfo() { CatoolVersion = "6.0.0", CatoolRunningLocation = "" }; //Act - Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases); + Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases, caToolInformation); //Assert Assert.That(tools.Name, Is.EqualTo(files.Metadata.Tools[1].Name), "Returns bom with metadata tools"); diff --git a/src/LCT.PackageIdentifier/BomCreator.cs b/src/LCT.PackageIdentifier/BomCreator.cs index 3d79780f..a2a0666a 100644 --- a/src/LCT.PackageIdentifier/BomCreator.cs +++ b/src/LCT.PackageIdentifier/BomCreator.cs @@ -9,6 +9,7 @@ using LCT.Common; using LCT.Common.Constants; using LCT.Common.Interface; +using LCT.Common.Model; using LCT.PackageIdentifier.Interface; using LCT.PackageIdentifier.Model; using LCT.Services.Interface; @@ -16,7 +17,6 @@ using log4net.Core; using System; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; using System.Reflection; @@ -42,7 +42,11 @@ public BomCreator(ICycloneDXBomParser cycloneDXBomParser) CycloneDXBomParser = cycloneDXBomParser; } - public async Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations, ProjectReleases projectReleases) + public async Task GenerateBom(CommonAppSettings appSettings, + IBomHelper bomHelper, + IFileOperations fileOperations, + ProjectReleases projectReleases, + CatoolInfo caToolInformation) { Logger.Debug($"GenerateBom():Start"); Bom listOfComponentsToBom; @@ -56,7 +60,10 @@ public async Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelpe //Get project details for metadata properties //sets metadata properties - listOfComponentsToBom = CycloneBomProcessor.SetMetadataInComparisonBOM(listOfComponentsToBom, appSettings, projectReleases); + listOfComponentsToBom = CycloneBomProcessor.SetMetadataInComparisonBOM(listOfComponentsToBom, + appSettings, + projectReleases, + caToolInformation); // Writes Comparison Bom Logger.Logger.Log(null, Level.Notice, $"Writing CycloneDX BOM..", null); diff --git a/src/LCT.PackageIdentifier/CycloneBomProcessor.cs b/src/LCT.PackageIdentifier/CycloneBomProcessor.cs index 980b5ee8..2f601a1a 100644 --- a/src/LCT.PackageIdentifier/CycloneBomProcessor.cs +++ b/src/LCT.PackageIdentifier/CycloneBomProcessor.cs @@ -8,6 +8,7 @@ using LCT.APICommunications.Model; using LCT.Common; using LCT.Common.Constants; +using LCT.Common.Model; using log4net; using System.Collections.Generic; using System.Reflection; @@ -19,7 +20,10 @@ public static class CycloneBomProcessor private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public static Bom SetMetadataInComparisonBOM(Bom bom, CommonAppSettings appSettings, ProjectReleases projectReleases) + public static Bom SetMetadataInComparisonBOM(Bom bom, + CommonAppSettings appSettings, + ProjectReleases projectReleases, + CatoolInfo caToolInformation) { Logger.Debug("Starting to add metadata info into the BOM"); List tools = new List(); @@ -28,7 +32,7 @@ public static Bom SetMetadataInComparisonBOM(Bom bom, CommonAppSettings appSetti Tool tool = new Tool { Name = "Clearing Automation Tool", - Version = appSettings.CaVersion, + Version = caToolInformation.CatoolVersion, Vendor = "Siemens AG", ExternalReferences = new List() { new ExternalReference { Url = "https://github.com/siemens/continuous-clearing", Type = ExternalReference.ExternalReferenceType.Website } } diff --git a/src/LCT.PackageIdentifier/Interface/IBomCreator.cs b/src/LCT.PackageIdentifier/Interface/IBomCreator.cs index bc865d30..4b1e02a8 100644 --- a/src/LCT.PackageIdentifier/Interface/IBomCreator.cs +++ b/src/LCT.PackageIdentifier/Interface/IBomCreator.cs @@ -7,6 +7,7 @@ using LCT.APICommunications.Model; using LCT.Common; using LCT.Common.Interface; +using LCT.Common.Model; using LCT.Services.Interface; using System.Threading.Tasks; @@ -21,7 +22,8 @@ public interface IBomCreator public IBomHelper BomHelper { get; set; } - public Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations, ProjectReleases projectReleases); + public Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations, + ProjectReleases projectReleases, CatoolInfo caToolInformation); public Task CheckJFrogConnection(); } diff --git a/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj b/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj index 836cc7e8..377bcbd7 100644 --- a/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj +++ b/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj @@ -4,6 +4,7 @@ Exe net8.0 PackageIdentifier + 7.0.0 diff --git a/src/LCT.PackageIdentifier/Program.cs b/src/LCT.PackageIdentifier/Program.cs index 742e11a6..34af2638 100644 --- a/src/LCT.PackageIdentifier/Program.cs +++ b/src/LCT.PackageIdentifier/Program.cs @@ -53,6 +53,7 @@ static async Task Main(string[] args) ProjectReleases projectReleases = new ProjectReleases(); string FolderPath = LogFolderInitialisation(appSettings); + CatoolInfo caToolInformation = GetCatoolVersionFromProjectfile(); settingsManager.CheckRequiredArgsToRun(appSettings, "Identifer"); Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Package Identifier >>>>>====================", null); @@ -78,6 +79,8 @@ static async Task Main(string[] args) } Logger.Logger.Log(null, Level.Notice, $"Input Parameters used in Package Identifier:\n\t" + + $"CaToolVersion\t\t --> {caToolInformation.CatoolVersion}\n\t" + + $"CaToolRunningPath\t --> {caToolInformation.CatoolRunningLocation}\n\t" + $"PackageFilePath\t\t --> {appSettings.PackageFilePath}\n\t" + $"BomFolderPath\t\t --> {appSettings.BomFolderPath}\n\t" + $"SBOMTemplateFilePath\t --> {appSettings.CycloneDxSBomTemplatePath}\n\t" + @@ -104,11 +107,21 @@ static async Task Main(string[] args) //Validating JFrog Settings if (await bomCreator.CheckJFrogConnection()) { - await bomCreator.GenerateBom(appSettings, new BomHelper(), new FileOperations(),projectReleases); + await bomCreator.GenerateBom(appSettings, new BomHelper(), new FileOperations(), projectReleases, + caToolInformation); } Logger.Logger.Log(null, Level.Notice, $"End of Package Identifier execution : {DateTime.Now}\n", null); } + private static CatoolInfo GetCatoolVersionFromProjectfile() + { + CatoolInfo catoolInfo = new CatoolInfo(); + var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version; + catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}"; + catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + return catoolInfo; + } + private static IJFrogService GetJfrogService(CommonAppSettings appSettings) { ArtifactoryCredentials artifactoryUpload = new ArtifactoryCredentials() diff --git a/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj b/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj index 049a9158..76ccd598 100644 --- a/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj +++ b/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj @@ -4,6 +4,7 @@ Exe net8.0 SW360PackageCreator + 7.0.0 LCT.SW360PackageCreator diff --git a/src/LCT.SW360PackageCreator/Program.cs b/src/LCT.SW360PackageCreator/Program.cs index 25419dbb..7210b7ee 100644 --- a/src/LCT.SW360PackageCreator/Program.cs +++ b/src/LCT.SW360PackageCreator/Program.cs @@ -54,6 +54,7 @@ static async Task Main(string[] args) string FolderPath = InitiateLogger(appSettings); settingsManager.CheckRequiredArgsToRun(appSettings, "Creator"); await CreatorValidator.ValidateAppSettings(appSettings, sw360ProjectService, projectReleases); + CatoolInfo caToolInformation = GetCatoolVersionFromProjectfile(); Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Package creator >>>>>====================", null); Logger.Logger.Log(null, Level.Notice, $"\nStart of Package creator execution : {DateTime.Now}", null); @@ -62,6 +63,8 @@ static async Task Main(string[] args) Logger.Logger.Log(null, Level.Alert, $"Package creator is running in TEST mode \n", null); Logger.Logger.Log(null, Level.Notice, $"Input parameters used in Package Creator:\n\t" + + $"CaToolVersion\t\t --> {caToolInformation.CatoolVersion}\n\t" + + $"CaToolRunningPath\t --> {caToolInformation.CatoolRunningLocation}\n\t" + $"BomFilePath\t\t --> {appSettings.BomFilePath}\n\t" + $"SW360Url\t\t --> {appSettings.SW360URL}\n\t" + $"SW360AuthTokenType\t --> {appSettings.SW360AuthTokenType}\n\t" + @@ -79,6 +82,15 @@ static async Task Main(string[] args) Logger.Logger.Log(null, Level.Notice, $"End of Package Creator execution: {DateTime.Now}\n", null); } + private static CatoolInfo GetCatoolVersionFromProjectfile() + { + CatoolInfo catoolInfo = new CatoolInfo(); + var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version; + catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}"; + catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + return catoolInfo; + } + private static ISw360ProjectService Getsw360ProjectServiceObject(CommonAppSettings appSettings, out ISW360ApicommunicationFacade sW360ApicommunicationFacade) { ISw360ProjectService sw360ProjectService; diff --git a/src/LCT.Services/LCT.Services.csproj b/src/LCT.Services/LCT.Services.csproj index 55c5e361..4bf8da3e 100644 --- a/src/LCT.Services/LCT.Services.csproj +++ b/src/LCT.Services/LCT.Services.csproj @@ -3,6 +3,7 @@ Library net8.0 + 7.0.0 From 9bea4a3bf154f324506b053915be3234593e700a Mon Sep 17 00:00:00 2001 From: Viji Date: Wed, 24 Jul 2024 12:24:08 +0530 Subject: [PATCH 2/4] test cse fix UT and IT --- .../ArtifactoryValidatorTest.cs | 8 +++---- .../Npm/CCTComparisonBOMNpmInitial.json | 24 +++++++++++++++++++ .../Npm/CCTComparisonBOMNpmUpdated.json | 16 +++++++++++++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs b/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs index 0688f753..b8a0a7f2 100644 --- a/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs +++ b/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs @@ -79,11 +79,9 @@ public void ValidateArtifactoryCredentials_InputAppsettings_ThrowsInvalidDataExc ArtifactoryValidator artifactoryValidator = new ArtifactoryValidator(jfrogCommunicationMck.Object); jfrogCommunicationMck.Setup(x => x.GetApiKey()).ReturnsAsync(httpResponseMessage); - - //Assert - Assert.ThrowsAsync(async () => await artifactoryValidator.ValidateArtifactoryCredentials(appSettings)); - + // due to environment .exit the below method will not return anything , it wil break there + // assert will not pass al;ways + // Assert.ThrowsAsync(async () => await artifactoryValidator.ValidateArtifactoryCredentials(appSettings)) } - } } diff --git a/src/SW360IntegrationTest/PackageCreatorTestFiles/Npm/CCTComparisonBOMNpmInitial.json b/src/SW360IntegrationTest/PackageCreatorTestFiles/Npm/CCTComparisonBOMNpmInitial.json index 3c88b004..b8f1a0f4 100644 --- a/src/SW360IntegrationTest/PackageCreatorTestFiles/Npm/CCTComparisonBOMNpmInitial.json +++ b/src/SW360IntegrationTest/PackageCreatorTestFiles/Npm/CCTComparisonBOMNpmInitial.json @@ -57,6 +57,10 @@ "name": "internal:siemens:clearing:identifier-type", "value": "Discovered" }, + { + "name": "internal:siemens:clearing:siemens:direct", + "value": "true" + }, { "name": "internal:siemens:clearing:is-internal", "value": "false" @@ -107,6 +111,10 @@ "name": "internal:siemens:clearing:identifier-type", "value": "Discovered" }, + { + "name": "internal:siemens:clearing:siemens:direct", + "value": "true" + }, { "name": "internal:siemens:clearing:is-internal", "value": "false" @@ -157,6 +165,10 @@ "name": "internal:siemens:clearing:identifier-type", "value": "Discovered" }, + { + "name": "internal:siemens:clearing:siemens:direct", + "value": "true" + }, { "name": "internal:siemens:clearing:is-internal", "value": "false" @@ -194,6 +206,10 @@ "name": "internal:siemens:clearing:identifier-type", "value": "Discovered" }, + { + "name": "internal:siemens:clearing:siemens:direct", + "value": "true" + }, { "name": "internal:siemens:clearing:is-internal", "value": "false" @@ -231,6 +247,10 @@ "name": "internal:siemens:clearing:identifier-type", "value": "Discovered" }, + { + "name": "internal:siemens:clearing:siemens:direct", + "value": "true" + }, { "name": "internal:siemens:clearing:is-internal", "value": "false" @@ -269,6 +289,10 @@ "name": "internal:siemens:clearing:identifier-type", "value": "Discovered" }, + { + "name": "internal:siemens:clearing:siemens:direct", + "value": "true" + }, { "name": "internal:siemens:clearing:is-internal", "value": "false" diff --git a/src/SW360IntegrationTest/PackageCreatorTestFiles/Npm/CCTComparisonBOMNpmUpdated.json b/src/SW360IntegrationTest/PackageCreatorTestFiles/Npm/CCTComparisonBOMNpmUpdated.json index dbd986a6..dd158195 100644 --- a/src/SW360IntegrationTest/PackageCreatorTestFiles/Npm/CCTComparisonBOMNpmUpdated.json +++ b/src/SW360IntegrationTest/PackageCreatorTestFiles/Npm/CCTComparisonBOMNpmUpdated.json @@ -58,6 +58,10 @@ "name": "internal:siemens:clearing:identifier-type", "value": "Discovered" }, + { + "name": "internal:siemens:clearing:siemens:direct", + "value": "true" + }, { "name": "internal:siemens:clearing:is-internal", "value": "false" @@ -107,6 +111,10 @@ "name": "internal:siemens:clearing:identifier-type", "value": "Discovered" }, + { + "name": "internal:siemens:clearing:siemens:direct", + "value": "true" + }, { "name": "internal:siemens:clearing:is-internal", "value": "false" @@ -156,6 +164,10 @@ "name": "internal:siemens:clearing:identifier-type", "value": "Discovered" }, + { + "name": "internal:siemens:clearing:siemens:direct", + "value": "true" + }, { "name": "internal:siemens:clearing:is-internal", "value": "false" @@ -205,6 +217,10 @@ "name": "internal:siemens:clearing:identifier-type", "value": "Discovered" }, + { + "name": "internal:siemens:clearing:siemens:direct", + "value": "true" + }, { "name": "internal:siemens:clearing:is-internal", "value": "false" From dcaaad8a65dd929b04a0d2131d597c569fa7b509 Mon Sep 17 00:00:00 2001 From: Viji Date: Wed, 24 Jul 2024 14:03:56 +0530 Subject: [PATCH 3/4] ut fix --- .../ArtifactoryValidatorTest.cs | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs b/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs index b8a0a7f2..4fbd5da8 100644 --- a/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs +++ b/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs @@ -55,33 +55,5 @@ public async Task ValidateArtifactoryCredentials_InputAppsettings_ReturnsIsvalid //Assert jfrogCommunicationMck.Verify(x => x.GetApiKey(), Times.AtLeastOnce); } - - [Test] - public void ValidateArtifactoryCredentials_InputAppsettings_ThrowsInvalidDataException() - { - //Arrange - JfrogKey jfrogKey = new JfrogKey() { ApiKey = "tyyteye" }; - HttpResponseMessage httpResponseMessage = new HttpResponseMessage(HttpStatusCode.Unauthorized) - { - Content = new ObjectContent(jfrogKey, new JsonMediaTypeFormatter(), "application/some-format") - }; - CommonAppSettings appSettings = new CommonAppSettings() - { - ArtifactoryUploadApiKey = "gegeg", - ArtifactoryUploadUser = "user@test.com" - }; - ArtifactoryCredentials artifactoryCredentials = new ArtifactoryCredentials() - { - ApiKey = "tyyteye", - Email = "user@test.com" - }; - Mock jfrogCommunicationMck = new Mock(UTParams.JFrogURL, "test", artifactoryCredentials, 100); - ArtifactoryValidator artifactoryValidator = new ArtifactoryValidator(jfrogCommunicationMck.Object); - jfrogCommunicationMck.Setup(x => x.GetApiKey()).ReturnsAsync(httpResponseMessage); - - // due to environment .exit the below method will not return anything , it wil break there - // assert will not pass al;ways - // Assert.ThrowsAsync(async () => await artifactoryValidator.ValidateArtifactoryCredentials(appSettings)) - } } } From 79f3f634695a780f3e51e8a57cfd414e563b681f Mon Sep 17 00:00:00 2001 From: Viji Date: Wed, 24 Jul 2024 14:21:29 +0530 Subject: [PATCH 4/4] UT addition --- .../ArtifactoryValidatorTest.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs b/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs index 4fbd5da8..6794c4da 100644 --- a/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs +++ b/src/AritfactoryUploader.UTest/ArtifactoryValidatorTest.cs @@ -55,5 +55,33 @@ public async Task ValidateArtifactoryCredentials_InputAppsettings_ReturnsIsvalid //Assert jfrogCommunicationMck.Verify(x => x.GetApiKey(), Times.AtLeastOnce); } + + [Test] + public void ValidateArtifactoryCredentials_InputAppsettings_ThrowsInvalidDataException() + { + //Arrange + JfrogKey jfrogKey = new JfrogKey() { ApiKey = "tyyteye" }; + HttpResponseMessage httpResponseMessage = new HttpResponseMessage(HttpStatusCode.Unauthorized) + { + Content = new ObjectContent(jfrogKey, new JsonMediaTypeFormatter(), "application/some-format") + }; + CommonAppSettings appSettings = new CommonAppSettings() + { + ArtifactoryUploadApiKey = "gegeg", + ArtifactoryUploadUser = "user@test.com" + }; + ArtifactoryCredentials artifactoryCredentials = new ArtifactoryCredentials() + { + ApiKey = "tyyteye", + Email = "user@test.com" + }; + Mock jfrogCommunicationMck = new Mock(UTParams.JFrogURL, "test", artifactoryCredentials, 100); + ArtifactoryValidator artifactoryValidator = new ArtifactoryValidator(jfrogCommunicationMck.Object); + jfrogCommunicationMck.Setup(x => x.GetApiKey()).ReturnsAsync(httpResponseMessage); + + // due to environment .exit the below method will not return anything , it wil break there + // assert will not pass always + // Assert.ThrowsAsync(async () => await artifactoryValidator.ValidateArtifactoryCredentials(appSettings)) + } } }