Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

843 scope property is always being set to required #844

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions CycloneDX.Tests/CycloneDX.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
</ItemGroup>

<ItemGroup>
<None Update="FunctionalTests\ExcludeTransitiveDevDependency\AssetsFile.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue826alt-ProjectFileDoesntExistWithAssetsFile\project2assets.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -60,13 +63,13 @@
<None Update="FunctionalTests\Issue830-rsMultipleFrameworks\project2csproj.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\TestcaseFiles\DevDependencies.json">
<None Update="FunctionalTests\ExcludeDevDependencies\DevDependencies.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\TestcaseFiles\DevDependencies_WithPackageConfig_CsProj.xml">
<None Update="FunctionalTests\ExcludeDevDependenciesPackagesConfig\DevDependencies_WithPackageConfig_CsProj.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\TestcaseFiles\DevDependencies_WithPackageConfig_PackageConfig.xml">
<None Update="FunctionalTests\ExcludeDevDependenciesPackagesConfig\DevDependencies_WithPackageConfig_PackageConfig.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\TestcaseFiles\FloatingVersions.json">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,30 @@

namespace CycloneDX.Tests.FunctionalTests
{
public class ExcludeDevDepenceny
public class ExcludeDevDependency
{
[Fact]
public async Task DevDependenciesNormalyGoIntoTheBom()
{
var assetsJson = File.ReadAllText(Path.Combine("FunctionalTests", "TestcaseFiles", "DevDependencies.json"));
var assetsJson = File.ReadAllText(Path.Combine("FunctionalTests", "ExcludeDevDependencies", "DevDependencies.json"));
var options = new RunOptions
{
};



var bom = await FunctionalTestHelper.Test(assetsJson, options);

Assert.True(bom.Components.Count == 1);
Assert.Contains(bom.Components, c => string.Compare(c.Name, "SonarAnalyzer.CSharp", true) == 0 && c.Version == "9.16.0.82469");
Assert.True(bom.Components.First(c => c.Name == "SonarAnalyzer.CSharp").Scope == Component.ComponentScope.Excluded, "Scope of development dependency is not excluded.");

}

[Fact]
public async Task DevDependenciesAreExcludedWithExcludeDevDependencies()
{
var assetsJson = File.ReadAllText(Path.Combine("FunctionalTests", "TestcaseFiles", "DevDependencies.json"));
var assetsJson = File.ReadAllText(Path.Combine("FunctionalTests", "ExcludeDevDependencies", "DevDependencies.json"));
var options = new RunOptions
{
excludeDev = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using CycloneDX.Models;
using Xunit;

namespace CycloneDX.Tests.FunctionalTests
namespace CycloneDX.Tests.FunctionalTests.ExcludeDevDependenciesPackagesConfig
{
public class ExcludeDevDependnciesWithPackageConfig
{
Expand All @@ -20,10 +20,10 @@ private MockFileSystem getMockFS()
{
{ MockUnixSupport.Path("c:/ProjectPath/Project.csproj"),
new MockFileData(
File.ReadAllText(Path.Combine("FunctionalTests", "TestcaseFiles", "DevDependencies_WithPackageConfig_CsProj.xml"))) },
File.ReadAllText(Path.Combine("FunctionalTests", "ExcludeDevDependenciesPackagesConfig", "DevDependencies_WithPackageConfig_CsProj.xml"))) },
{ MockUnixSupport.Path("c:/ProjectPath/packages.config"),
new MockFileData(
File.ReadAllText(Path.Combine("FunctionalTests", "TestcaseFiles", "DevDependencies_WithPackageConfig_PackageConfig.xml"))) }
File.ReadAllText(Path.Combine("FunctionalTests", "ExcludeDevDependenciesPackagesConfig", "DevDependencies_WithPackageConfig_PackageConfig.xml"))) }
});
}

Expand All @@ -38,12 +38,13 @@ public async Task DevDependenciesNormalyGoIntoTheBom()

Assert.True(bom.Components.Count == 1, $"Unexpected number of components. Expected 1, got {bom.Components.Count}");
Assert.Contains(bom.Components, c => string.Compare(c.Name, "SonarAnalyzer.CSharp", true) == 0 && c.Version == "9.16.0.82469");
Assert.True(bom.Components.First(c => c.Name == "SonarAnalyzer.CSharp").Scope == Component.ComponentScope.Excluded, "Scope of development dependency is not excluded.");

}

[Fact]
public async Task DevDependenciesAreExcludedWithExcludeDevDependencies()
{
{
var options = new RunOptions
{
excludeDev = true
Expand All @@ -53,7 +54,7 @@ public async Task DevDependenciesAreExcludedWithExcludeDevDependencies()
var bom = await FunctionalTestHelper.Test(options, getMockFS());

Assert.True(bom.Components.Count == 0);


}

Expand Down
Loading
Loading