8000 [issue-375] add validation test for SPDX Lite by armintaenzertng · Pull Request #587 · spdx/tools-python · GitHub
[go: up one dir, main page]

Skip to content

[issue-375] add validation test for SPDX Lite #587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2023
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
[issue-375] add validation test for SPDX Lite
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
  • Loading branch information
armintaenzertng committed Apr 17, 2023
commit f917fcca4acaac586d227942b9f336922e2d7263
36 changes: 36 additions & 0 deletions tests/spdx/data/SPDXLite.spdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# from https://github.com/OpenChain-Project/OpenChain-JWG/blob/4675d7a61ad552e8f9780419c54dddbdf87f6018/subgroups/sbom-sg/outcomes/SPDX-Lite/sample/SPDX-tools-spdxlite.txt
## 2 Document Creation Information

SPDXVersion: SPDX-2.2
DataLicense: CC0-1.0
SPDXID: SPDXRef-DOCUMENT
DocumentName: example-v1.0
DocumentNamespace: https://example.com/example-v1.0
Creator: Person: someone
Created: 2021-04-05T01:23:45Z

## 3 Package Information

PackageName: SPDX tools
SPDXID: SPDXRef-spdxtools
PackageVersion: 2.0.3
PackageFileName: spdx-tools-2.0.2-jar-with-dependencies.jar
PackageDownloadLocation: NONE
FilesAnalyzed: false
PackageHomePage: https://spdx.org/tools
PackageLicenseConcluded: Apache-2.0
PackageLicenseDeclared: Apache-2.0
PackageLicenseComments: <text></text>
PackageCopyrightText: <text>software copyright (c) 2000-2003, BEA Systems, <http://www.bea.com/></text>
PackageComment: <text>
ModificationRecord: NO
CompileOptions: --some-option
LinkMethodology: Dynamic
</text>

## 6 Other Licensing Information Detected

LicenseID: LicenseRef-1
ExtractedText: <text>hoge</text>
LicenseName: NOASSERTION
LicenseComment: <text></text>
9 changes: 8 additions & 1 deletion tests/spdx/validation/test_document_validator.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0

import os
from typing import List, Optional

import pytest

from spdx.constants import DOCUMENT_SPDX_ID
from spdx.model.document import CreationInfo, Document
from spdx.model.relationship import Relationship, RelationshipType
from spdx.parser.parse_anything import parse_file
from spdx.validation.document_validator import validate_full_spdx_document
from spdx.validation.validation_message import SpdxElementType, ValidationContext, ValidationMessage
from tests.spdx.fixtures import creation_info_fixture, document_fixture, file_fixture, package_fixture, snippet_fixture
Expand All @@ -21,6 +22,12 @@ def test_valid_document():
assert validation_messages == []


def test_spdx_lite_validation():
document = parse_file(os.path.join(os.path.dirname(__file__), "../data/SPDXLite.spdx"))

assert validate_full_spdx_document(document) == []


@pytest.mark.parametrize(
"creation_info, version_input, expected_message",
[
Expand Down
0