-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid creating duplicate entries in Sw360 (#166)
* Initial * Duplicate check * Unique entries * UT Added * UT Added * Sonar Issues fixed * Log added * Review comments * Update CreatorHelper.cs * Review comments * Nuspec update * BuG fix * Update CA_UsageDocument.md * Sumanth's changes * Logging while linking to components * Update compile.yml * Update compile.yml --------- Co-authored-by: Sumanth Kb <[email protected]> Co-authored-by: Karthika Geethanand ¯\_(ツ)_/¯ <[email protected]> Co-authored-by: karthika <[email protected]>
- Loading branch information
1 parent
d520630
commit 5367099
Showing
13 changed files
with
165 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,10 @@ | |
using System.Diagnostics; | ||
using LCT.Common; | ||
using Castle.Core.Internal; | ||
using LCT.Facade.Interfaces; | ||
using System.Net.Http; | ||
using System.Net; | ||
using System.Text; | ||
|
||
namespace SW360ComponentCreator.UTest | ||
{ | ||
|
@@ -169,6 +173,53 @@ public async Task SetContentsForComparisonBOM_ProvidedValidBomDetails_ReturnsLis | |
Assert.That(data.Count > 0); | ||
} | ||
|
||
[Test] | ||
public async Task SetContentsForComparisonBOM_ProvidedValidBomDetailsWithSw360InvalidCred_ReturnsEmpty() | ||
{ | ||
//Arrange | ||
var debianPatcher = new Mock<IDebianPatcher>(); | ||
IDictionary<string, IPackageDownloader> _packageDownloderList = new Dictionary<string, IPackageDownloader> | ||
{ | ||
{ "DEBIAN", new DebianPackageDownloader(debianPatcher.Object) } | ||
}; | ||
var creatorHelper = new CreatorHelper(_packageDownloderList); | ||
|
||
ReleasesInfo releasesInfo = new ReleasesInfo(); | ||
releasesInfo.SourceCodeDownloadUrl = "https://snapshot.debian.org/archive/debian/20180915T211528Z/pool/main/a/adduser/adduser_3.118.tar.xz"; | ||
|
||
List<Components> componentsAvailableInSw360 = new List<Components>(); | ||
List<Components> comparisonBomData = new List<Components> | ||
{ | ||
new Components() | ||
{ | ||
Name = "adduser", | ||
Version = "3.118", | ||
ComponentExternalId = "pkg:deb/debian/adduser?arch=source", | ||
ReleaseExternalId = "pkg:deb/debian/[email protected]?arch=source", | ||
SourceUrl = "https://snapshot.debian.org/archive/debian/20180915T211528Z/pool/main/a/adduser/adduser_3.118.tar.xz", | ||
DownloadUrl = "https://snapshot.debian.org/archive/debian/20180915T211528Z/pool/main/a/adduser/adduser_3.118.tar.xz" | ||
} | ||
}; | ||
var iSW360Service = new Mock<ISW360Service>(); | ||
|
||
//Mocking the Sw360 result as Empty with SuccessCode | ||
HttpResponseMessage responseMessage = new HttpResponseMessage | ||
{ | ||
StatusCode = HttpStatusCode.OK, | ||
Content = new StringContent("", Encoding.UTF8) | ||
}; | ||
var iSW360ApicommunicationFacade = new Mock<ISW360ApicommunicationFacade>(); | ||
iSW360ApicommunicationFacade.Setup(x => x.GetReleases()).ReturnsAsync(await responseMessage.Content.ReadAsStringAsync()); | ||
iSW360Service.Setup(x => x.GetAvailableReleasesInSw360(comparisonBomData)).ReturnsAsync(componentsAvailableInSw360); | ||
iSW360Service.Setup(x => x.GetReleaseDataOfComponent(comparisonBomData[0].ReleaseLink)).ReturnsAsync(releasesInfo); | ||
|
||
//Act | ||
var data = await creatorHelper.SetContentsForComparisonBOM(comparisonBomData, iSW360Service.Object); | ||
|
||
//Assert | ||
Assert.That(data.Count.Equals(0)); | ||
} | ||
|
||
[Test] | ||
public async Task GetUpdatedComponentsDetails_ProvidedValidBomDetails_ReturnsUpdatedBom() | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.