Skip to content
Merged
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
4 changes: 3 additions & 1 deletion src/fosslight_util/write_cyclonedx.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
from fosslight_util.oss_item import CHECKSUM_NULL, get_checksum_sha1
from packageurl import PackageURL
import traceback

logger = logging.getLogger(LOGGER_NAME)

try:
from cyclonedx.builder.this import this_component as cdx_lib_component
from cyclonedx.exception import MissingOptionalDependencyException
Expand All @@ -35,7 +38,6 @@
from cyclonedx.validation.xml import XmlValidator
except Exception:
logger.info('No import cyclonedx-python-lib')
logger = logging.getLogger(LOGGER_NAME)


def write_cyclonedx(output_file_without_ext, output_extension, scan_item):
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def scan_item():
scan_item.set_cover_comment('This is a test comment')

file_item = FileItem('test_result/excel_and_csv')
file_item.checksum = 'af969fc2085b1bb6d31e517d5c456def5cdd7093'

oss_item = OssItem("test_name1", "1.0.0", "Apache-2.0", "https://abc.com")
oss_item.comment = "test_name comment"
Expand Down
20 changes: 20 additions & 0 deletions tests/test_cyclonedx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2021 LG Electronics Inc.
# SPDX-License-Identifier: Apache-2.0

import os

from fosslight_util.write_cyclonedx import write_cyclonedx
from tests import constants


def test_cyclonedx(scan_item):
# given
output_dir = os.path.join(constants.TEST_RESULT_DIR, "cyclonedx")
filename_with_dir = os.path.join(output_dir, "FL-TEST_cyclonedx.json")

# when
success, err_msg, _ = write_cyclonedx(filename_with_dir.split('.')[0], '.json', scan_item)

# then
assert success is True
assert len(os.listdir(output_dir)) > 0
Loading