@@ -98,3 +98,41 @@ def test_document_with_mixed_values():
9898 "Element Package is not the current element in scope, probably the expected "
9999 "tag to start the element (PackageName) is missing. Line: 4"
100100 ]
101+
102+
103+ def test_faulty_license_expression ():
104+ parser = Parser ()
105+ document_str = "\n " .join (
106+ [
107+ f"SPDXID:{ DOCUMENT_SPDX_ID } " ,
108+ "FileName: File with faulty license expression" ,
109+ "SPDXID: SPDXRef-File" ,
110+ "FileChecksum: SHA1: d6a770ba38583ed4bb4525bd96e50461655d2759" ,
111+ "LicenseConcluded: LicenseRef-foo/bar" ,
112+ "PackageName: Package with faulty license expression" ,
113+ "SPDXID: SPDXRef-Package" ,
114+ "PackageDownloadLocation: www.download.com" ,
115+ "PackageLicenseConcluded: LicenseRef-bar/foo" ,
116+ "SnippetSPDXID: SPDXRef-Snippet" ,
117+ "SnippetName: Snippet with faulty license expression" ,
118+ "SnippetLicenseConcluded: LicenseRef-foo/foo" ,
119+ ]
120+ )
121+
122+ with pytest .raises (SPDXParsingError ) as err :
123+ parser .parse (document_str )
124+
125+ assert err .value .get_messages () == [
126+ 'Error while parsing File: ["Error while parsing license expression: '
127+ "LicenseRef-foo/bar: Invalid license key: the valid characters are: letters "
128+ "and numbers, underscore, dot, colon or hyphen signs and spaces: "
129+ "'LicenseRef-foo/bar'\" ]" ,
130+ 'Error while parsing Package: ["Error while parsing license expression: '
131+ "LicenseRef-bar/foo: Invalid license key: the valid characters are: letters "
132+ "and numbers, underscore, dot, colon or hyphen signs and spaces: "
133+ "'LicenseRef-bar/foo'\" ]" ,
134+ 'Error while parsing Snippet: ["Error while parsing license expression: '
135+ "LicenseRef-foo/foo: Invalid license key: the valid characters are: letters "
136+ "and numbers, underscore, dot, colon or hyphen signs and spaces: "
137+ "'LicenseRef-foo/foo'\" ]" ,
138+ ]
0 commit comments