Package org.owasp.dependencycheck.data.nvdcve

Source Code of org.owasp.dependencycheck.data.nvdcve.CveDBIntegrationTest

/*
* This file is part of dependency-check-core.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright (c) 2013 Jeremy Long. All Rights Reserved.
*/
package org.owasp.dependencycheck.data.nvdcve;

import java.util.List;
import java.util.Set;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.owasp.dependencycheck.dependency.VulnerableSoftware;
import org.owasp.dependencycheck.utils.DependencyVersion;

/**
*
* @author Jeremy Long <jeremy.long@owasp.org>
*/
public class CveDBIntegrationTest extends BaseDBTestCase {

    /**
     * Pretty useless tests of open, commit, and close methods, of class CveDB.
     */
    @Test
    public void testOpen() throws Exception {
        CveDB instance = new CveDB();
        instance.open();
        instance.commit();
        instance.close();
    }

    /**
     * Test of getCPEs method, of class CveDB.
     */
    @Test
    public void testGetCPEs() throws Exception {
        CveDB instance = new CveDB();
        try {
            String vendor = "apache";
            String product = "struts";
            instance.open();
            Set<VulnerableSoftware> result = instance.getCPEs(vendor, product);
            assertTrue(result.size() > 5);
        } finally {
            instance.close();
        }
    }

    /**
     * Test of getVulnerabilities method, of class CveDB.
     */
    @Test
    public void testGetVulnerabilities() throws Exception {
        String cpeStr = "cpe:/a:apache:struts:2.1.2";
        CveDB instance = new CveDB();
        try {
            instance.open();
            List result = instance.getVulnerabilities(cpeStr);
            assertTrue(result.size() > 5);
        } finally {
            instance.close();
        }
    }

    /**
     * Test of isAffected method, of class CveDB.
     */
    @Test
    public void testIsAffected() throws Exception {
        String vendor = "openssl";
        String product = "openssl";
        DependencyVersion identifiedVersion = new DependencyVersion("1.0.1o");
        String cpeId = "cpe:/a:openssl:openssl:1.0.1e";
        String previous = "y";

        CveDB instance = new CveDB();
        assertFalse(instance.isAffected(vendor, product, identifiedVersion, cpeId, previous));

    }

}
TOP

Related Classes of org.owasp.dependencycheck.data.nvdcve.CveDBIntegrationTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.