def test_create_repo_node_and_get_cve_error_status_code(_mock_post):
    """Test the method RepoDependencyCreator.create_repo_node_and_get_cve."""
    github_repo = "test_repository"
    deps_list = {"direct": [], "transitive": []}
    with pytest.raises(Exception) as e:
        RepoDependencyCreator.create_repo_node_and_get_cve(
            github_repo, deps_list)
        assert e is not None
def test_create_repo_node_and_get_cve_transitive_dependency_epv_only(
        _mock_post):
    """Test the method RepoDependencyCreator.create_repo_node_and_get_cve."""
    github_repo = "test_repository"

    # use EPV only on transitive dependency
    deps_list = {"direct": [], "transitive": ["xxx:yyy:zzz"]}
    x = RepoDependencyCreator.create_repo_node_and_get_cve(
        github_repo, deps_list)
    assert x is not None
def test_create_repo_node_and_get_cve_direct_dependency(_mock_post):
    """Test the method RepoDependencyCreator.create_repo_node_and_get_cve."""
    github_repo = "test_repository"

    # only direct dependency list is filled in
    # transitive dependencies list is empty
    deps_list = {"direct": ["xxx:yyy:zzz:www"], "transitive": []}

    x = RepoDependencyCreator.create_repo_node_and_get_cve(
        github_repo, deps_list)
    assert x is not None
def test_create_repo_node_and_get_cve(_mock_post):
    """Test the method RepoDependencyCreator.create_repo_node_and_get_cve."""
    github_repo = "test_repository"

    # direct dependencies list is empty
    # transitive dependencies list is empty as well
    deps_list = {"direct": [], "transitive": []}

    x = RepoDependencyCreator.create_repo_node_and_get_cve(
        github_repo, deps_list)
    assert x is not None
def test_create_repo_node_and_get_cve_transitive_dependencies(_mock_post):
    """Test the method RepoDependencyCreator.create_repo_node_and_get_cve."""
    github_repo = "test_repository"

    deps_list = {
        "direct": [],
        "transitive": ["xxx:yyy:zzz:www", "x2:y2:z2:w2"]
    }

    x = RepoDependencyCreator.create_repo_node_and_get_cve(
        github_repo, deps_list)
    assert x is not None
def test_generate_report():
    """Test the method RepoDependencyCreator.generate_report."""
    with (Path(__file__).parent /
          "files/report.json").open(encoding='utf-8') as f:
        content = json.load(f)
        response = RepoDependencyCreator.generate_report(content, deps_list={})
        assert response is not []
        assert len(response) == 1

        assert "repo_url" in response[0]
        assert "vulnerable_deps" in response[0]

        assert response[0][
            "repo_url"] == 'https://github.com/abs51295/maven-simple.git'
        assert response[0]["vulnerable_deps"] == []
def test_generate_report():
    """Test the function RepoDependencyCreator.generate_report."""
    with (Path(__file__).parent / "files/report.json").open(encoding='utf-8') as f:
        content = json.load(f)
        response = RepoDependencyCreator.generate_report(content, deps_list={})
        assert response is not []