mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-21 08:39:24 +01:00
Merge pull request #475 from biancajiang/master
Fix test to skip the proper test case when bundle-audit is not available
This commit is contained in:
@@ -57,15 +57,9 @@ public class RubyBundleAuditAnalyzerTest extends BaseTest {
|
|||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
try {
|
Settings.initialize();
|
||||||
Settings.initialize();
|
analyzer = new RubyBundleAuditAnalyzer();
|
||||||
analyzer = new RubyBundleAuditAnalyzer();
|
analyzer.setFilesMatched(true);
|
||||||
analyzer.setFilesMatched(true);
|
|
||||||
analyzer.initialize();
|
|
||||||
} catch (Exception e) {
|
|
||||||
//LOGGER.warn("Exception setting up RubyBundleAuditAnalyzer. Tests will be incomplete", e);
|
|
||||||
Assume.assumeNoException("Exception setting up RubyBundleAuditAnalyzer; bundle audit may not be installed. Tests will be incomplete", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,19 +97,26 @@ public class RubyBundleAuditAnalyzerTest extends BaseTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAnalysis() throws AnalysisException, DatabaseException {
|
public void testAnalysis() throws AnalysisException, DatabaseException {
|
||||||
final Dependency result = new Dependency(BaseTest.getResourceAsFile(this,
|
try {
|
||||||
"ruby/vulnerable/gems/rails-4.1.15/Gemfile.lock"));
|
analyzer.initialize();
|
||||||
final Engine engine = new Engine();
|
|
||||||
analyzer.analyze(result, engine);
|
|
||||||
int size = engine.getDependencies().size();
|
|
||||||
assertThat(size, is(1));
|
|
||||||
|
|
||||||
Dependency dependency = engine.getDependencies().get(0);
|
final Dependency result = new Dependency(BaseTest.getResourceAsFile(this,
|
||||||
assertTrue(dependency.getProductEvidence().toString().toLowerCase().contains("redcarpet"));
|
"ruby/vulnerable/gems/rails-4.1.15/Gemfile.lock"));
|
||||||
assertTrue(dependency.getVersionEvidence().toString().toLowerCase().contains("2.2.2"));
|
final Engine engine = new Engine();
|
||||||
|
analyzer.analyze(result, engine);
|
||||||
|
int size = engine.getDependencies().size();
|
||||||
|
assertThat(size, is(1));
|
||||||
|
|
||||||
|
Dependency dependency = engine.getDependencies().get(0);
|
||||||
|
assertTrue(dependency.getProductEvidence().toString().toLowerCase().contains("redcarpet"));
|
||||||
|
assertTrue(dependency.getVersionEvidence().toString().toLowerCase().contains("2.2.2"));
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.warn("Exception setting up RubyBundleAuditAnalyzer. Make sure Ruby gem bundle-audit is installed. You may also need to set property \"analyzer.bundle.audit.path\".", e);
|
||||||
|
Assume.assumeNoException("Exception setting up RubyBundleAuditAnalyzer; bundle audit may not be installed, or property \"analyzer.bundle.audit.path\" may not be set.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test when Ruby bundle-audit is not available on the system.
|
* Test when Ruby bundle-audit is not available on the system.
|
||||||
*
|
*
|
||||||
@@ -133,7 +134,7 @@ public class RubyBundleAuditAnalyzerTest extends BaseTest {
|
|||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
assertThat(analyzer.isEnabled(), is(false));
|
assertThat(analyzer.isEnabled(), is(false));
|
||||||
LOGGER.info("Ruby Bundle Audit Analyzer is disabled as expected.");
|
LOGGER.info("phantom-bundle-audit is not available. Ruby Bundle Audit Analyzer is disabled as expected.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user