mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-23 09:31:32 +01:00
added tests for MySQL External DB
Former-commit-id: 25a9773428d52aa95df940ab1c21cd363a361f99
This commit is contained in:
@@ -18,11 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.owasp.dependencycheck.data.nvdcve;
|
package org.owasp.dependencycheck.data.nvdcve;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.owasp.dependencycheck.dependency.VulnerableSoftware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -50,21 +54,15 @@ public class CveDBMySQLTest {
|
|||||||
* Pretty useless tests of open, commit, and close methods, of class CveDB.
|
* Pretty useless tests of open, commit, and close methods, of class CveDB.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testOpen() throws Exception {
|
public void testOpen() throws DatabaseException {
|
||||||
// String con = Settings.getString(Settings.KEYS.DB_CONNECTION_STRING);
|
try {
|
||||||
// String driver = Settings.getString(Settings.KEYS.DB_DRIVER_NAME);
|
|
||||||
// String path = Settings.getString(Settings.KEYS.DB_DRIVER_PATH);
|
|
||||||
//
|
|
||||||
// System.out.println("con: " + con);
|
|
||||||
// System.out.println("driver: " + driver);
|
|
||||||
// System.out.println("path: " + path);
|
|
||||||
// Settings.setString(Settings.KEYS.DB_CONNECTION_STRING, "jdbc:mysql://localhost:3306/dependencycheck");
|
|
||||||
// Settings.setString(Settings.KEYS.DB_DRIVER_NAME, "com.mysql.jdbc.Driver");
|
|
||||||
// Settings.setString(Settings.KEYS.DB_DRIVER_PATH, "c:\\Users\\jeremy\\Documents\\NetBeansProjects\\DependencyCheck\\dependency-check-core/src/test/resources/mysql-connector-java-5.1.27-bin.jar");
|
|
||||||
|
|
||||||
CveDB instance = new CveDB();
|
CveDB instance = new CveDB();
|
||||||
instance.open();
|
instance.open();
|
||||||
instance.close();
|
instance.close();
|
||||||
|
} catch (DatabaseException ex) {
|
||||||
|
System.out.println("Unable to connect to the My SQL database; verify that the db server is running and that the schema has been generated");
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,18 +70,19 @@ public class CveDBMySQLTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetCPEs() throws Exception {
|
public void testGetCPEs() throws Exception {
|
||||||
/*
|
|
||||||
CveDB instance = new CveDB();
|
CveDB instance = new CveDB();
|
||||||
try {
|
try {
|
||||||
String vendor = "apache";
|
String vendor = "apache";
|
||||||
String product = "struts";
|
String product = "struts";
|
||||||
instance.open();
|
instance.open();
|
||||||
Set<VulnerableSoftware> result = instance.getCPEs(vendor, product);
|
Set<VulnerableSoftware> result = instance.getCPEs(vendor, product);
|
||||||
assertTrue(result.size() > 5);
|
assertTrue("Has data been loaded into the MySQL DB? if not consider using the CLI to populate it", result.size() > 5);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
System.out.println("Unable to access the My SQL database; verify that the db server is running and that the schema has been generated");
|
||||||
|
throw ex;
|
||||||
} finally {
|
} finally {
|
||||||
instance.close();
|
instance.close();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,16 +90,17 @@ public class CveDBMySQLTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetVulnerabilities() throws Exception {
|
public void testGetVulnerabilities() throws Exception {
|
||||||
/*
|
|
||||||
String cpeStr = "cpe:/a:apache:struts:2.1.2";
|
String cpeStr = "cpe:/a:apache:struts:2.1.2";
|
||||||
CveDB instance = new CveDB();
|
CveDB instance = new CveDB();
|
||||||
try {
|
try {
|
||||||
instance.open();
|
instance.open();
|
||||||
List result = instance.getVulnerabilities(cpeStr);
|
List result = instance.getVulnerabilities(cpeStr);
|
||||||
assertTrue(result.size() > 5);
|
assertTrue(result.size() > 5);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
System.out.println("Unable to access the My SQL database; verify that the db server is running and that the schema has been generated");
|
||||||
|
throw ex;
|
||||||
} finally {
|
} finally {
|
||||||
instance.close();
|
instance.close();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user