blob: 13ba66db99a76dd58c1e3b85f8c342fecce5663e [file] [log] [blame]
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001// Copyright 2022 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package main
16
17import (
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +000018 "bytes"
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +000019 "encoding/json"
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +000020 "fmt"
21 "os"
22 "reflect"
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +000023 "strings"
24 "testing"
25 "time"
26
27 "android/soong/tools/compliance"
Jingwen Chen376b6b62023-06-07 05:58:11 +000028
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +000029 "github.com/spdx/tools-golang/builder/builder2v2"
30 "github.com/spdx/tools-golang/spdx/common"
31 spdx "github.com/spdx/tools-golang/spdx/v2_2"
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +000032)
33
34func TestMain(m *testing.M) {
35 // Change into the parent directory before running the tests
36 // so they can find the testdata directory.
37 if err := os.Chdir(".."); err != nil {
38 fmt.Printf("failed to change to testdata directory: %s\n", err)
39 os.Exit(1)
40 }
41 os.Exit(m.Run())
42}
43
44func Test(t *testing.T) {
45 tests := []struct {
46 condition string
47 name string
48 outDir string
49 roots []string
50 stripPrefix string
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +000051 expectedOut *spdx.Document
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +000052 expectedDeps []string
53 }{
54 {
55 condition: "firstparty",
56 name: "apex",
57 roots: []string{"highest.apex.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +000058 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +000059 SPDXVersion: "SPDX-2.2",
60 DataLicense: "CC0-1.0",
61 SPDXIdentifier: "DOCUMENT",
62 DocumentName: "testdata-firstparty-highest.apex",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +000063 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/firstparty/highest.apex.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +000064 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +000065 Packages: []*spdx.Package{
66 {
67 PackageName: "testdata-firstparty-highest.apex.meta_lic",
68 PackageVersion: "NOASSERTION",
69 PackageDownloadLocation: "NOASSERTION",
70 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-highest.apex.meta_lic"),
71 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
72 },
73 {
74 PackageName: "testdata-firstparty-bin-bin1.meta_lic",
75 PackageVersion: "NOASSERTION",
76 PackageDownloadLocation: "NOASSERTION",
77 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin1.meta_lic"),
78 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
79 },
80 {
81 PackageName: "testdata-firstparty-bin-bin2.meta_lic",
82 PackageVersion: "NOASSERTION",
83 PackageDownloadLocation: "NOASSERTION",
84 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin2.meta_lic"),
85 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
86 },
87 {
88 PackageName: "testdata-firstparty-lib-liba.so.meta_lic",
89 PackageVersion: "NOASSERTION",
90 PackageDownloadLocation: "NOASSERTION",
91 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
92 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
93 },
94 {
95 PackageName: "testdata-firstparty-lib-libb.so.meta_lic",
96 PackageVersion: "NOASSERTION",
97 PackageDownloadLocation: "NOASSERTION",
98 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libb.so.meta_lic"),
99 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
100 },
101 {
102 PackageName: "testdata-firstparty-lib-libc.a.meta_lic",
103 PackageVersion: "NOASSERTION",
104 PackageDownloadLocation: "NOASSERTION",
105 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libc.a.meta_lic"),
106 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
107 },
108 {
109 PackageName: "testdata-firstparty-lib-libd.so.meta_lic",
110 PackageVersion: "NOASSERTION",
111 PackageDownloadLocation: "NOASSERTION",
112 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libd.so.meta_lic"),
113 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
114 },
115 },
116 Relationships: []*spdx.Relationship{
117 {
118 RefA: common.MakeDocElementID("", "DOCUMENT"),
119 RefB: common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
120 Relationship: "DESCRIBES",
121 },
122 {
123 RefA: common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
124 RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
125 Relationship: "CONTAINS",
126 },
127 {
128 RefA: common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
129 RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
130 Relationship: "CONTAINS",
131 },
132 {
133 RefA: common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
134 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
135 Relationship: "CONTAINS",
136 },
137 {
138 RefA: common.MakeDocElementID("", "testdata-firstparty-highest.apex.meta_lic"),
139 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
140 Relationship: "CONTAINS",
141 },
142 {
143 RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
144 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
145 Relationship: "CONTAINS",
146 },
147 {
148 RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
149 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libc.a.meta_lic"),
150 Relationship: "CONTAINS",
151 },
152 {
153 RefA: common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
154 RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
155 Relationship: "RUNTIME_DEPENDENCY_OF",
156 },
157 {
158 RefA: common.MakeDocElementID("", "testdata-firstparty-lib-libd.so.meta_lic"),
159 RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
160 Relationship: "RUNTIME_DEPENDENCY_OF",
161 },
162 },
163 OtherLicenses: []*spdx.OtherLicense{
164 {
165 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
166 ExtractedText: "&&&First Party License&&&\n",
167 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
168 },
169 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000170 },
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +0000171 expectedDeps: []string{
172 "testdata/firstparty/FIRST_PARTY_LICENSE",
173 "testdata/firstparty/bin/bin1.meta_lic",
174 "testdata/firstparty/bin/bin2.meta_lic",
175 "testdata/firstparty/highest.apex.meta_lic",
176 "testdata/firstparty/lib/liba.so.meta_lic",
177 "testdata/firstparty/lib/libb.so.meta_lic",
178 "testdata/firstparty/lib/libc.a.meta_lic",
179 "testdata/firstparty/lib/libd.so.meta_lic",
180 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000181 },
182 {
183 condition: "firstparty",
184 name: "application",
185 roots: []string{"application.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000186 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000187 SPDXVersion: "SPDX-2.2",
188 DataLicense: "CC0-1.0",
189 SPDXIdentifier: "DOCUMENT",
190 DocumentName: "testdata-firstparty-application",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +0000191 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/firstparty/application.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000192 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000193 Packages: []*spdx.Package{
194 {
195 PackageName: "testdata-firstparty-application.meta_lic",
196 PackageVersion: "NOASSERTION",
197 PackageDownloadLocation: "NOASSERTION",
198 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-application.meta_lic"),
199 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
200 },
201 {
202 PackageName: "testdata-firstparty-bin-bin3.meta_lic",
203 PackageVersion: "NOASSERTION",
204 PackageDownloadLocation: "NOASSERTION",
205 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin3.meta_lic"),
206 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
207 },
208 {
209 PackageName: "testdata-firstparty-lib-liba.so.meta_lic",
210 PackageVersion: "NOASSERTION",
211 PackageDownloadLocation: "NOASSERTION",
212 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
213 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
214 },
215 {
216 PackageName: "testdata-firstparty-lib-libb.so.meta_lic",
217 PackageVersion: "NOASSERTION",
218 PackageDownloadLocation: "NOASSERTION",
219 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libb.so.meta_lic"),
220 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
221 },
222 },
223 Relationships: []*spdx.Relationship{
224 {
225 RefA: common.MakeDocElementID("", "DOCUMENT"),
226 RefB: common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
227 Relationship: "DESCRIBES",
228 },
229 {
230 RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin3.meta_lic"),
231 RefB: common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
232 Relationship: "BUILD_TOOL_OF",
233 },
234 {
235 RefA: common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
236 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
237 Relationship: "CONTAINS",
238 },
239 {
240 RefA: common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
241 RefB: common.MakeDocElementID("", "testdata-firstparty-application.meta_lic"),
242 Relationship: "RUNTIME_DEPENDENCY_OF",
243 },
244 },
245 OtherLicenses: []*spdx.OtherLicense{
246 {
247 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
248 ExtractedText: "&&&First Party License&&&\n",
249 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
250 },
251 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000252 },
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +0000253 expectedDeps: []string{
254 "testdata/firstparty/FIRST_PARTY_LICENSE",
255 "testdata/firstparty/application.meta_lic",
256 "testdata/firstparty/bin/bin3.meta_lic",
257 "testdata/firstparty/lib/liba.so.meta_lic",
258 "testdata/firstparty/lib/libb.so.meta_lic",
259 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000260 },
261 {
262 condition: "firstparty",
263 name: "container",
264 roots: []string{"container.zip.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000265 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000266 SPDXVersion: "SPDX-2.2",
267 DataLicense: "CC0-1.0",
268 SPDXIdentifier: "DOCUMENT",
269 DocumentName: "testdata-firstparty-container.zip",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +0000270 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/firstparty/container.zip.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000271 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000272 Packages: []*spdx.Package{
273 {
274 PackageName: "testdata-firstparty-container.zip.meta_lic",
275 PackageVersion: "NOASSERTION",
276 PackageDownloadLocation: "NOASSERTION",
277 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-container.zip.meta_lic"),
278 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
279 },
280 {
281 PackageName: "testdata-firstparty-bin-bin1.meta_lic",
282 PackageVersion: "NOASSERTION",
283 PackageDownloadLocation: "NOASSERTION",
284 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin1.meta_lic"),
285 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
286 },
287 {
288 PackageName: "testdata-firstparty-bin-bin2.meta_lic",
289 PackageVersion: "NOASSERTION",
290 PackageDownloadLocation: "NOASSERTION",
291 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin2.meta_lic"),
292 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
293 },
294 {
295 PackageName: "testdata-firstparty-lib-liba.so.meta_lic",
296 PackageVersion: "NOASSERTION",
297 PackageDownloadLocation: "NOASSERTION",
298 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
299 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
300 },
301 {
302 PackageName: "testdata-firstparty-lib-libb.so.meta_lic",
303 PackageVersion: "NOASSERTION",
304 PackageDownloadLocation: "NOASSERTION",
305 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libb.so.meta_lic"),
306 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
307 },
308 {
309 PackageName: "testdata-firstparty-lib-libc.a.meta_lic",
310 PackageVersion: "NOASSERTION",
311 PackageDownloadLocation: "NOASSERTION",
312 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libc.a.meta_lic"),
313 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
314 },
315 {
316 PackageName: "testdata-firstparty-lib-libd.so.meta_lic",
317 PackageVersion: "NOASSERTION",
318 PackageDownloadLocation: "NOASSERTION",
319 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libd.so.meta_lic"),
320 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
321 },
322 },
323 Relationships: []*spdx.Relationship{
324 {
325 RefA: common.MakeDocElementID("", "DOCUMENT"),
326 RefB: common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
327 Relationship: "DESCRIBES",
328 },
329 {
330 RefA: common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
331 RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
332 Relationship: "CONTAINS",
333 },
334 {
335 RefA: common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
336 RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
337 Relationship: "CONTAINS",
338 },
339 {
340 RefA: common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
341 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
342 Relationship: "CONTAINS",
343 },
344 {
345 RefA: common.MakeDocElementID("", "testdata-firstparty-container.zip.meta_lic"),
346 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
347 Relationship: "CONTAINS",
348 },
349 {
350 RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
351 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
352 Relationship: "CONTAINS",
353 },
354 {
355 RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
356 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libc.a.meta_lic"),
357 Relationship: "CONTAINS",
358 },
359 {
360 RefA: common.MakeDocElementID("", "testdata-firstparty-lib-libb.so.meta_lic"),
361 RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
362 Relationship: "RUNTIME_DEPENDENCY_OF",
363 },
364 {
365 RefA: common.MakeDocElementID("", "testdata-firstparty-lib-libd.so.meta_lic"),
366 RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin2.meta_lic"),
367 Relationship: "RUNTIME_DEPENDENCY_OF",
368 },
369 },
370 OtherLicenses: []*spdx.OtherLicense{
371 {
372 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
373 ExtractedText: "&&&First Party License&&&\n",
374 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
375 },
376 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000377 },
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +0000378 expectedDeps: []string{
379 "testdata/firstparty/FIRST_PARTY_LICENSE",
380 "testdata/firstparty/bin/bin1.meta_lic",
381 "testdata/firstparty/bin/bin2.meta_lic",
382 "testdata/firstparty/container.zip.meta_lic",
383 "testdata/firstparty/lib/liba.so.meta_lic",
384 "testdata/firstparty/lib/libb.so.meta_lic",
385 "testdata/firstparty/lib/libc.a.meta_lic",
386 "testdata/firstparty/lib/libd.so.meta_lic",
387 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000388 },
389 {
390 condition: "firstparty",
391 name: "binary",
392 roots: []string{"bin/bin1.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000393 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000394 SPDXVersion: "SPDX-2.2",
395 DataLicense: "CC0-1.0",
396 SPDXIdentifier: "DOCUMENT",
397 DocumentName: "testdata-firstparty-bin-bin1",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +0000398 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/firstparty/bin/bin1.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000399 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000400 Packages: []*spdx.Package{
401 {
402 PackageName: "testdata-firstparty-bin-bin1.meta_lic",
403 PackageVersion: "NOASSERTION",
404 PackageDownloadLocation: "NOASSERTION",
405 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-bin-bin1.meta_lic"),
406 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
407 },
408 {
409 PackageName: "testdata-firstparty-lib-liba.so.meta_lic",
410 PackageVersion: "NOASSERTION",
411 PackageDownloadLocation: "NOASSERTION",
412 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-liba.so.meta_lic"),
413 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
414 },
415 {
416 PackageName: "testdata-firstparty-lib-libc.a.meta_lic",
417 PackageVersion: "NOASSERTION",
418 PackageDownloadLocation: "NOASSERTION",
419 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libc.a.meta_lic"),
420 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
421 },
422 },
423 Relationships: []*spdx.Relationship{
424 {
425 RefA: common.MakeDocElementID("", "DOCUMENT"),
426 RefB: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
427 Relationship: "DESCRIBES",
428 },
429 {
430 RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
431 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-liba.so.meta_lic"),
432 Relationship: "CONTAINS",
433 },
434 {
435 RefA: common.MakeDocElementID("", "testdata-firstparty-bin-bin1.meta_lic"),
436 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libc.a.meta_lic"),
437 Relationship: "CONTAINS",
438 },
439 },
440 OtherLicenses: []*spdx.OtherLicense{
441 {
442 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
443 ExtractedText: "&&&First Party License&&&\n",
444 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
445 },
446 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000447 },
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +0000448 expectedDeps: []string{
449 "testdata/firstparty/FIRST_PARTY_LICENSE",
450 "testdata/firstparty/bin/bin1.meta_lic",
451 "testdata/firstparty/lib/liba.so.meta_lic",
452 "testdata/firstparty/lib/libc.a.meta_lic",
453 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000454 },
455 {
456 condition: "firstparty",
457 name: "library",
458 roots: []string{"lib/libd.so.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000459 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000460 SPDXVersion: "SPDX-2.2",
461 DataLicense: "CC0-1.0",
462 SPDXIdentifier: "DOCUMENT",
463 DocumentName: "testdata-firstparty-lib-libd.so",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +0000464 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/firstparty/lib/libd.so.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000465 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000466 Packages: []*spdx.Package{
467 {
468 PackageName: "testdata-firstparty-lib-libd.so.meta_lic",
469 PackageVersion: "NOASSERTION",
470 PackageDownloadLocation: "NOASSERTION",
471 PackageSPDXIdentifier: common.ElementID("testdata-firstparty-lib-libd.so.meta_lic"),
472 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
473 },
474 },
475 Relationships: []*spdx.Relationship{
476 {
477 RefA: common.MakeDocElementID("", "DOCUMENT"),
478 RefB: common.MakeDocElementID("", "testdata-firstparty-lib-libd.so.meta_lic"),
479 Relationship: "DESCRIBES",
480 },
481 },
482 OtherLicenses: []*spdx.OtherLicense{
483 {
484 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
485 ExtractedText: "&&&First Party License&&&\n",
486 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
487 },
488 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000489 },
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +0000490 expectedDeps: []string{
491 "testdata/firstparty/FIRST_PARTY_LICENSE",
492 "testdata/firstparty/lib/libd.so.meta_lic",
493 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000494 },
495 {
496 condition: "notice",
497 name: "apex",
498 roots: []string{"highest.apex.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000499 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000500 SPDXVersion: "SPDX-2.2",
501 DataLicense: "CC0-1.0",
502 SPDXIdentifier: "DOCUMENT",
503 DocumentName: "testdata-notice-highest.apex",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +0000504 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/notice/highest.apex.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000505 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000506 Packages: []*spdx.Package{
507 {
508 PackageName: "testdata-notice-highest.apex.meta_lic",
509 PackageVersion: "NOASSERTION",
510 PackageDownloadLocation: "NOASSERTION",
511 PackageSPDXIdentifier: common.ElementID("testdata-notice-highest.apex.meta_lic"),
512 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
513 },
514 {
515 PackageName: "testdata-notice-bin-bin1.meta_lic",
516 PackageVersion: "NOASSERTION",
517 PackageDownloadLocation: "NOASSERTION",
518 PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin1.meta_lic"),
519 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
520 },
521 {
522 PackageName: "testdata-notice-bin-bin2.meta_lic",
523 PackageVersion: "NOASSERTION",
524 PackageDownloadLocation: "NOASSERTION",
525 PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin2.meta_lic"),
526 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
527 },
528 {
529 PackageName: "testdata-notice-lib-liba.so.meta_lic",
530 PackageVersion: "NOASSERTION",
531 PackageDownloadLocation: "NOASSERTION",
532 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
533 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
534 },
535 {
536 PackageName: "testdata-notice-lib-libb.so.meta_lic",
537 PackageVersion: "NOASSERTION",
538 PackageDownloadLocation: "NOASSERTION",
539 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libb.so.meta_lic"),
540 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
541 },
542 {
543 PackageName: "testdata-notice-lib-libc.a.meta_lic",
544 PackageVersion: "NOASSERTION",
545 PackageDownloadLocation: "NOASSERTION",
546 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libc.a.meta_lic"),
547 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
548 },
549 {
550 PackageName: "testdata-notice-lib-libd.so.meta_lic",
551 PackageVersion: "NOASSERTION",
552 PackageDownloadLocation: "NOASSERTION",
553 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libd.so.meta_lic"),
554 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
555 },
556 },
557 Relationships: []*spdx.Relationship{
558 {
559 RefA: common.MakeDocElementID("", "DOCUMENT"),
560 RefB: common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
561 Relationship: "DESCRIBES",
562 },
563 {
564 RefA: common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
565 RefB: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
566 Relationship: "CONTAINS",
567 },
568 {
569 RefA: common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
570 RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
571 Relationship: "CONTAINS",
572 },
573 {
574 RefA: common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
575 RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
576 Relationship: "CONTAINS",
577 },
578 {
579 RefA: common.MakeDocElementID("", "testdata-notice-highest.apex.meta_lic"),
580 RefB: common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
581 Relationship: "CONTAINS",
582 },
583 {
584 RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
585 RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
586 Relationship: "CONTAINS",
587 },
588 {
589 RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
590 RefB: common.MakeDocElementID("", "testdata-notice-lib-libc.a.meta_lic"),
591 Relationship: "CONTAINS",
592 },
593 {
594 RefA: common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
595 RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
596 Relationship: "RUNTIME_DEPENDENCY_OF",
597 },
598 {
599 RefA: common.MakeDocElementID("", "testdata-notice-lib-libd.so.meta_lic"),
600 RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
601 Relationship: "RUNTIME_DEPENDENCY_OF",
602 },
603 },
604 OtherLicenses: []*spdx.OtherLicense{
605 {
606 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
607 ExtractedText: "&&&First Party License&&&\n",
608 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
609 },
610 {
611 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
612 ExtractedText: "%%%Notice License%%%\n",
613 LicenseName: "testdata-notice-NOTICE_LICENSE",
614 },
615 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000616 },
617 expectedDeps: []string{
618 "testdata/firstparty/FIRST_PARTY_LICENSE",
619 "testdata/notice/NOTICE_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +0000620 "testdata/notice/bin/bin1.meta_lic",
621 "testdata/notice/bin/bin2.meta_lic",
622 "testdata/notice/highest.apex.meta_lic",
623 "testdata/notice/lib/liba.so.meta_lic",
624 "testdata/notice/lib/libb.so.meta_lic",
625 "testdata/notice/lib/libc.a.meta_lic",
626 "testdata/notice/lib/libd.so.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000627 },
628 },
629 {
630 condition: "notice",
631 name: "container",
632 roots: []string{"container.zip.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000633 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000634 SPDXVersion: "SPDX-2.2",
635 DataLicense: "CC0-1.0",
636 SPDXIdentifier: "DOCUMENT",
637 DocumentName: "testdata-notice-container.zip",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +0000638 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/notice/container.zip.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000639 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000640 Packages: []*spdx.Package{
641 {
642 PackageName: "testdata-notice-container.zip.meta_lic",
643 PackageVersion: "NOASSERTION",
644 PackageDownloadLocation: "NOASSERTION",
645 PackageSPDXIdentifier: common.ElementID("testdata-notice-container.zip.meta_lic"),
646 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
647 },
648 {
649 PackageName: "testdata-notice-bin-bin1.meta_lic",
650 PackageVersion: "NOASSERTION",
651 PackageDownloadLocation: "NOASSERTION",
652 PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin1.meta_lic"),
653 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
654 },
655 {
656 PackageName: "testdata-notice-bin-bin2.meta_lic",
657 PackageVersion: "NOASSERTION",
658 PackageDownloadLocation: "NOASSERTION",
659 PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin2.meta_lic"),
660 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
661 },
662 {
663 PackageName: "testdata-notice-lib-liba.so.meta_lic",
664 PackageVersion: "NOASSERTION",
665 PackageDownloadLocation: "NOASSERTION",
666 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
667 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
668 },
669 {
670 PackageName: "testdata-notice-lib-libb.so.meta_lic",
671 PackageVersion: "NOASSERTION",
672 PackageDownloadLocation: "NOASSERTION",
673 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libb.so.meta_lic"),
674 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
675 },
676 {
677 PackageName: "testdata-notice-lib-libc.a.meta_lic",
678 PackageVersion: "NOASSERTION",
679 PackageDownloadLocation: "NOASSERTION",
680 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libc.a.meta_lic"),
681 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
682 },
683 {
684 PackageName: "testdata-notice-lib-libd.so.meta_lic",
685 PackageVersion: "NOASSERTION",
686 PackageDownloadLocation: "NOASSERTION",
687 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libd.so.meta_lic"),
688 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
689 },
690 },
691 Relationships: []*spdx.Relationship{
692 {
693 RefA: common.MakeDocElementID("", "DOCUMENT"),
694 RefB: common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
695 Relationship: "DESCRIBES",
696 },
697 {
698 RefA: common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
699 RefB: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
700 Relationship: "CONTAINS",
701 },
702 {
703 RefA: common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
704 RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
705 Relationship: "CONTAINS",
706 },
707 {
708 RefA: common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
709 RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
710 Relationship: "CONTAINS",
711 },
712 {
713 RefA: common.MakeDocElementID("", "testdata-notice-container.zip.meta_lic"),
714 RefB: common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
715 Relationship: "CONTAINS",
716 },
717 {
718 RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
719 RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
720 Relationship: "CONTAINS",
721 },
722 {
723 RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
724 RefB: common.MakeDocElementID("", "testdata-notice-lib-libc.a.meta_lic"),
725 Relationship: "CONTAINS",
726 },
727 {
728 RefA: common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
729 RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
730 Relationship: "RUNTIME_DEPENDENCY_OF",
731 },
732 {
733 RefA: common.MakeDocElementID("", "testdata-notice-lib-libd.so.meta_lic"),
734 RefB: common.MakeDocElementID("", "testdata-notice-bin-bin2.meta_lic"),
735 Relationship: "RUNTIME_DEPENDENCY_OF",
736 },
737 },
738 OtherLicenses: []*spdx.OtherLicense{
739 {
740 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
741 ExtractedText: "&&&First Party License&&&\n",
742 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
743 },
744 {
745 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
746 ExtractedText: "%%%Notice License%%%\n",
747 LicenseName: "testdata-notice-NOTICE_LICENSE",
748 },
749 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000750 },
751 expectedDeps: []string{
752 "testdata/firstparty/FIRST_PARTY_LICENSE",
753 "testdata/notice/NOTICE_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +0000754 "testdata/notice/bin/bin1.meta_lic",
755 "testdata/notice/bin/bin2.meta_lic",
756 "testdata/notice/container.zip.meta_lic",
757 "testdata/notice/lib/liba.so.meta_lic",
758 "testdata/notice/lib/libb.so.meta_lic",
759 "testdata/notice/lib/libc.a.meta_lic",
760 "testdata/notice/lib/libd.so.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000761 },
762 },
763 {
764 condition: "notice",
765 name: "application",
766 roots: []string{"application.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000767 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000768 SPDXVersion: "SPDX-2.2",
769 DataLicense: "CC0-1.0",
770 SPDXIdentifier: "DOCUMENT",
771 DocumentName: "testdata-notice-application",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +0000772 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/notice/application.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000773 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000774 Packages: []*spdx.Package{
775 {
776 PackageName: "testdata-notice-application.meta_lic",
777 PackageVersion: "NOASSERTION",
778 PackageDownloadLocation: "NOASSERTION",
779 PackageSPDXIdentifier: common.ElementID("testdata-notice-application.meta_lic"),
780 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
781 },
782 {
783 PackageName: "testdata-notice-bin-bin3.meta_lic",
784 PackageVersion: "NOASSERTION",
785 PackageDownloadLocation: "NOASSERTION",
786 PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin3.meta_lic"),
787 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
788 },
789 {
790 PackageName: "testdata-notice-lib-liba.so.meta_lic",
791 PackageVersion: "NOASSERTION",
792 PackageDownloadLocation: "NOASSERTION",
793 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
794 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
795 },
796 {
797 PackageName: "testdata-notice-lib-libb.so.meta_lic",
798 PackageVersion: "NOASSERTION",
799 PackageDownloadLocation: "NOASSERTION",
800 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libb.so.meta_lic"),
801 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
802 },
803 },
804 Relationships: []*spdx.Relationship{
805 {
806 RefA: common.MakeDocElementID("", "DOCUMENT"),
807 RefB: common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
808 Relationship: "DESCRIBES",
809 },
810 {
811 RefA: common.MakeDocElementID("", "testdata-notice-bin-bin3.meta_lic"),
812 RefB: common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
813 Relationship: "BUILD_TOOL_OF",
814 },
815 {
816 RefA: common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
817 RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
818 Relationship: "CONTAINS",
819 },
820 {
821 RefA: common.MakeDocElementID("", "testdata-notice-lib-libb.so.meta_lic"),
822 RefB: common.MakeDocElementID("", "testdata-notice-application.meta_lic"),
823 Relationship: "RUNTIME_DEPENDENCY_OF",
824 },
825 },
826 OtherLicenses: []*spdx.OtherLicense{
827 {
828 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
829 ExtractedText: "&&&First Party License&&&\n",
830 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
831 },
832 {
833 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
834 ExtractedText: "%%%Notice License%%%\n",
835 LicenseName: "testdata-notice-NOTICE_LICENSE",
836 },
837 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000838 },
839 expectedDeps: []string{
840 "testdata/firstparty/FIRST_PARTY_LICENSE",
841 "testdata/notice/NOTICE_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +0000842 "testdata/notice/application.meta_lic",
843 "testdata/notice/bin/bin3.meta_lic",
844 "testdata/notice/lib/liba.so.meta_lic",
845 "testdata/notice/lib/libb.so.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000846 },
847 },
848 {
849 condition: "notice",
850 name: "binary",
851 roots: []string{"bin/bin1.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000852 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000853 SPDXVersion: "SPDX-2.2",
854 DataLicense: "CC0-1.0",
855 SPDXIdentifier: "DOCUMENT",
856 DocumentName: "testdata-notice-bin-bin1",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +0000857 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/notice/bin/bin1.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000858 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000859 Packages: []*spdx.Package{
860 {
861 PackageName: "testdata-notice-bin-bin1.meta_lic",
862 PackageVersion: "NOASSERTION",
863 PackageDownloadLocation: "NOASSERTION",
864 PackageSPDXIdentifier: common.ElementID("testdata-notice-bin-bin1.meta_lic"),
865 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
866 },
867 {
868 PackageName: "testdata-notice-lib-liba.so.meta_lic",
869 PackageVersion: "NOASSERTION",
870 PackageDownloadLocation: "NOASSERTION",
871 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-liba.so.meta_lic"),
872 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
873 },
874 {
875 PackageName: "testdata-notice-lib-libc.a.meta_lic",
876 PackageVersion: "NOASSERTION",
877 PackageDownloadLocation: "NOASSERTION",
878 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libc.a.meta_lic"),
879 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
880 },
881 },
882 Relationships: []*spdx.Relationship{
883 {
884 RefA: common.MakeDocElementID("", "DOCUMENT"),
885 RefB: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
886 Relationship: "DESCRIBES",
887 },
888 {
889 RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
890 RefB: common.MakeDocElementID("", "testdata-notice-lib-liba.so.meta_lic"),
891 Relationship: "CONTAINS",
892 },
893 {
894 RefA: common.MakeDocElementID("", "testdata-notice-bin-bin1.meta_lic"),
895 RefB: common.MakeDocElementID("", "testdata-notice-lib-libc.a.meta_lic"),
896 Relationship: "CONTAINS",
897 },
898 },
899 OtherLicenses: []*spdx.OtherLicense{
900 {
901 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
902 ExtractedText: "&&&First Party License&&&\n",
903 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
904 },
905 {
906 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
907 ExtractedText: "%%%Notice License%%%\n",
908 LicenseName: "testdata-notice-NOTICE_LICENSE",
909 },
910 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000911 },
912 expectedDeps: []string{
913 "testdata/firstparty/FIRST_PARTY_LICENSE",
914 "testdata/notice/NOTICE_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +0000915 "testdata/notice/bin/bin1.meta_lic",
916 "testdata/notice/lib/liba.so.meta_lic",
917 "testdata/notice/lib/libc.a.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000918 },
919 },
920 {
921 condition: "notice",
922 name: "library",
923 roots: []string{"lib/libd.so.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000924 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000925 SPDXVersion: "SPDX-2.2",
926 DataLicense: "CC0-1.0",
927 SPDXIdentifier: "DOCUMENT",
928 DocumentName: "testdata-notice-lib-libd.so",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +0000929 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/notice/lib/libd.so.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000930 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000931 Packages: []*spdx.Package{
932 {
933 PackageName: "testdata-notice-lib-libd.so.meta_lic",
934 PackageVersion: "NOASSERTION",
935 PackageDownloadLocation: "NOASSERTION",
936 PackageSPDXIdentifier: common.ElementID("testdata-notice-lib-libd.so.meta_lic"),
937 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
938 },
939 },
940 Relationships: []*spdx.Relationship{
941 {
942 RefA: common.MakeDocElementID("", "DOCUMENT"),
943 RefB: common.MakeDocElementID("", "testdata-notice-lib-libd.so.meta_lic"),
944 Relationship: "DESCRIBES",
945 },
946 },
947 OtherLicenses: []*spdx.OtherLicense{
948 {
949 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
950 ExtractedText: "%%%Notice License%%%\n",
951 LicenseName: "testdata-notice-NOTICE_LICENSE",
952 },
953 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000954 },
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +0000955 expectedDeps: []string{
956 "testdata/notice/NOTICE_LICENSE",
957 "testdata/notice/lib/libd.so.meta_lic",
958 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +0000959 },
960 {
961 condition: "reciprocal",
962 name: "apex",
963 roots: []string{"highest.apex.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000964 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000965 SPDXVersion: "SPDX-2.2",
966 DataLicense: "CC0-1.0",
967 SPDXIdentifier: "DOCUMENT",
968 DocumentName: "testdata-reciprocal-highest.apex",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +0000969 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/reciprocal/highest.apex.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +0000970 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +0000971 Packages: []*spdx.Package{
972 {
973 PackageName: "testdata-reciprocal-highest.apex.meta_lic",
974 PackageVersion: "NOASSERTION",
975 PackageDownloadLocation: "NOASSERTION",
976 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-highest.apex.meta_lic"),
977 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
978 },
979 {
980 PackageName: "testdata-reciprocal-bin-bin1.meta_lic",
981 PackageVersion: "NOASSERTION",
982 PackageDownloadLocation: "NOASSERTION",
983 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-bin-bin1.meta_lic"),
984 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
985 },
986 {
987 PackageName: "testdata-reciprocal-bin-bin2.meta_lic",
988 PackageVersion: "NOASSERTION",
989 PackageDownloadLocation: "NOASSERTION",
990 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-bin-bin2.meta_lic"),
991 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
992 },
993 {
994 PackageName: "testdata-reciprocal-lib-liba.so.meta_lic",
995 PackageVersion: "NOASSERTION",
996 PackageDownloadLocation: "NOASSERTION",
997 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-liba.so.meta_lic"),
998 PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
999 },
1000 {
1001 PackageName: "testdata-reciprocal-lib-libb.so.meta_lic",
1002 PackageVersion: "NOASSERTION",
1003 PackageDownloadLocation: "NOASSERTION",
1004 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libb.so.meta_lic"),
1005 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1006 },
1007 {
1008 PackageName: "testdata-reciprocal-lib-libc.a.meta_lic",
1009 PackageVersion: "NOASSERTION",
1010 PackageDownloadLocation: "NOASSERTION",
1011 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libc.a.meta_lic"),
1012 PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1013 },
1014 {
1015 PackageName: "testdata-reciprocal-lib-libd.so.meta_lic",
1016 PackageVersion: "NOASSERTION",
1017 PackageDownloadLocation: "NOASSERTION",
1018 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libd.so.meta_lic"),
1019 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1020 },
1021 },
1022 Relationships: []*spdx.Relationship{
1023 {
1024 RefA: common.MakeDocElementID("", "DOCUMENT"),
1025 RefB: common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
1026 Relationship: "DESCRIBES",
1027 },
1028 {
1029 RefA: common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
1030 RefB: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1031 Relationship: "CONTAINS",
1032 },
1033 {
1034 RefA: common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
1035 RefB: common.MakeDocElementID("", "testdata-reciprocal-bin-bin2.meta_lic"),
1036 Relationship: "CONTAINS",
1037 },
1038 {
1039 RefA: common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
1040 RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
1041 Relationship: "CONTAINS",
1042 },
1043 {
1044 RefA: common.MakeDocElementID("", "testdata-reciprocal-highest.apex.meta_lic"),
1045 RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-libb.so.meta_lic"),
1046 Relationship: "CONTAINS",
1047 },
1048 {
1049 RefA: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1050 RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
1051 Relationship: "CONTAINS",
1052 },
1053 {
1054 RefA: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1055 RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-libc.a.meta_lic"),
1056 Relationship: "CONTAINS",
1057 },
1058 {
1059 RefA: common.MakeDocElementID("", "testdata-reciprocal-lib-libb.so.meta_lic"),
1060 RefB: common.MakeDocElementID("", "testdata-reciprocal-bin-bin2.meta_lic"),
1061 Relationship: "RUNTIME_DEPENDENCY_OF",
1062 },
1063 {
1064 RefA: common.MakeDocElementID("", "testdata-reciprocal-lib-libd.so.meta_lic"),
1065 RefB: common.MakeDocElementID("", "testdata-reciprocal-bin-bin2.meta_lic"),
1066 Relationship: "RUNTIME_DEPENDENCY_OF",
1067 },
1068 },
1069 OtherLicenses: []*spdx.OtherLicense{
1070 {
1071 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1072 ExtractedText: "&&&First Party License&&&\n",
1073 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
1074 },
1075 {
1076 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1077 ExtractedText: "%%%Notice License%%%\n",
1078 LicenseName: "testdata-notice-NOTICE_LICENSE",
1079 },
1080 {
1081 LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1082 ExtractedText: "$$$Reciprocal License$$$\n",
1083 LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
1084 },
1085 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001086 },
1087 expectedDeps: []string{
1088 "testdata/firstparty/FIRST_PARTY_LICENSE",
1089 "testdata/notice/NOTICE_LICENSE",
1090 "testdata/reciprocal/RECIPROCAL_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00001091 "testdata/reciprocal/bin/bin1.meta_lic",
1092 "testdata/reciprocal/bin/bin2.meta_lic",
1093 "testdata/reciprocal/highest.apex.meta_lic",
1094 "testdata/reciprocal/lib/liba.so.meta_lic",
1095 "testdata/reciprocal/lib/libb.so.meta_lic",
1096 "testdata/reciprocal/lib/libc.a.meta_lic",
1097 "testdata/reciprocal/lib/libd.so.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001098 },
1099 },
1100 {
1101 condition: "reciprocal",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001102 name: "application",
1103 roots: []string{"application.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001104 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001105 SPDXVersion: "SPDX-2.2",
1106 DataLicense: "CC0-1.0",
1107 SPDXIdentifier: "DOCUMENT",
1108 DocumentName: "testdata-reciprocal-application",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00001109 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/reciprocal/application.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001110 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001111 Packages: []*spdx.Package{
1112 {
1113 PackageName: "testdata-reciprocal-application.meta_lic",
1114 PackageVersion: "NOASSERTION",
1115 PackageDownloadLocation: "NOASSERTION",
1116 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-application.meta_lic"),
1117 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1118 },
1119 {
1120 PackageName: "testdata-reciprocal-bin-bin3.meta_lic",
1121 PackageVersion: "NOASSERTION",
1122 PackageDownloadLocation: "NOASSERTION",
1123 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-bin-bin3.meta_lic"),
1124 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1125 },
1126 {
1127 PackageName: "testdata-reciprocal-lib-liba.so.meta_lic",
1128 PackageVersion: "NOASSERTION",
1129 PackageDownloadLocation: "NOASSERTION",
1130 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-liba.so.meta_lic"),
1131 PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1132 },
1133 {
1134 PackageName: "testdata-reciprocal-lib-libb.so.meta_lic",
1135 PackageVersion: "NOASSERTION",
1136 PackageDownloadLocation: "NOASSERTION",
1137 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libb.so.meta_lic"),
1138 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1139 },
1140 },
1141 Relationships: []*spdx.Relationship{
1142 {
1143 RefA: common.MakeDocElementID("", "DOCUMENT"),
1144 RefB: common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
1145 Relationship: "DESCRIBES",
1146 },
1147 {
1148 RefA: common.MakeDocElementID("", "testdata-reciprocal-bin-bin3.meta_lic"),
1149 RefB: common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
1150 Relationship: "BUILD_TOOL_OF",
1151 },
1152 {
1153 RefA: common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
1154 RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
1155 Relationship: "CONTAINS",
1156 },
1157 {
1158 RefA: common.MakeDocElementID("", "testdata-reciprocal-lib-libb.so.meta_lic"),
1159 RefB: common.MakeDocElementID("", "testdata-reciprocal-application.meta_lic"),
1160 Relationship: "RUNTIME_DEPENDENCY_OF",
1161 },
1162 },
1163 OtherLicenses: []*spdx.OtherLicense{
1164 {
1165 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1166 ExtractedText: "&&&First Party License&&&\n",
1167 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
1168 },
1169 {
1170 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1171 ExtractedText: "%%%Notice License%%%\n",
1172 LicenseName: "testdata-notice-NOTICE_LICENSE",
1173 },
1174 {
1175 LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1176 ExtractedText: "$$$Reciprocal License$$$\n",
1177 LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
1178 },
1179 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001180 },
1181 expectedDeps: []string{
1182 "testdata/firstparty/FIRST_PARTY_LICENSE",
1183 "testdata/notice/NOTICE_LICENSE",
1184 "testdata/reciprocal/RECIPROCAL_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00001185 "testdata/reciprocal/application.meta_lic",
1186 "testdata/reciprocal/bin/bin3.meta_lic",
1187 "testdata/reciprocal/lib/liba.so.meta_lic",
1188 "testdata/reciprocal/lib/libb.so.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001189 },
1190 },
1191 {
1192 condition: "reciprocal",
1193 name: "binary",
1194 roots: []string{"bin/bin1.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001195 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001196 SPDXVersion: "SPDX-2.2",
1197 DataLicense: "CC0-1.0",
1198 SPDXIdentifier: "DOCUMENT",
1199 DocumentName: "testdata-reciprocal-bin-bin1",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00001200 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/reciprocal/bin/bin1.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001201 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001202 Packages: []*spdx.Package{
1203 {
1204 PackageName: "testdata-reciprocal-bin-bin1.meta_lic",
1205 PackageVersion: "NOASSERTION",
1206 PackageDownloadLocation: "NOASSERTION",
1207 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-bin-bin1.meta_lic"),
1208 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1209 },
1210 {
1211 PackageName: "testdata-reciprocal-lib-liba.so.meta_lic",
1212 PackageVersion: "NOASSERTION",
1213 PackageDownloadLocation: "NOASSERTION",
1214 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-liba.so.meta_lic"),
1215 PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1216 },
1217 {
1218 PackageName: "testdata-reciprocal-lib-libc.a.meta_lic",
1219 PackageVersion: "NOASSERTION",
1220 PackageDownloadLocation: "NOASSERTION",
1221 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libc.a.meta_lic"),
1222 PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1223 },
1224 },
1225 Relationships: []*spdx.Relationship{
1226 {
1227 RefA: common.MakeDocElementID("", "DOCUMENT"),
1228 RefB: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1229 Relationship: "DESCRIBES",
1230 },
1231 {
1232 RefA: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1233 RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-liba.so.meta_lic"),
1234 Relationship: "CONTAINS",
1235 },
1236 {
1237 RefA: common.MakeDocElementID("", "testdata-reciprocal-bin-bin1.meta_lic"),
1238 RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-libc.a.meta_lic"),
1239 Relationship: "CONTAINS",
1240 },
1241 },
1242 OtherLicenses: []*spdx.OtherLicense{
1243 {
1244 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1245 ExtractedText: "&&&First Party License&&&\n",
1246 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
1247 },
1248 {
1249 LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1250 ExtractedText: "$$$Reciprocal License$$$\n",
1251 LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
1252 },
1253 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001254 },
1255 expectedDeps: []string{
1256 "testdata/firstparty/FIRST_PARTY_LICENSE",
1257 "testdata/reciprocal/RECIPROCAL_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00001258 "testdata/reciprocal/bin/bin1.meta_lic",
1259 "testdata/reciprocal/lib/liba.so.meta_lic",
1260 "testdata/reciprocal/lib/libc.a.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001261 },
1262 },
1263 {
1264 condition: "reciprocal",
1265 name: "library",
1266 roots: []string{"lib/libd.so.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001267 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001268 SPDXVersion: "SPDX-2.2",
1269 DataLicense: "CC0-1.0",
1270 SPDXIdentifier: "DOCUMENT",
1271 DocumentName: "testdata-reciprocal-lib-libd.so",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00001272 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/reciprocal/lib/libd.so.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001273 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001274 Packages: []*spdx.Package{
1275 {
1276 PackageName: "testdata-reciprocal-lib-libd.so.meta_lic",
1277 PackageVersion: "NOASSERTION",
1278 PackageDownloadLocation: "NOASSERTION",
1279 PackageSPDXIdentifier: common.ElementID("testdata-reciprocal-lib-libd.so.meta_lic"),
1280 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1281 },
1282 },
1283 Relationships: []*spdx.Relationship{
1284 {
1285 RefA: common.MakeDocElementID("", "DOCUMENT"),
1286 RefB: common.MakeDocElementID("", "testdata-reciprocal-lib-libd.so.meta_lic"),
1287 Relationship: "DESCRIBES",
1288 },
1289 },
1290 OtherLicenses: []*spdx.OtherLicense{
1291 {
1292 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1293 ExtractedText: "%%%Notice License%%%\n",
1294 LicenseName: "testdata-notice-NOTICE_LICENSE",
1295 },
1296 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001297 },
1298 expectedDeps: []string{
1299 "testdata/notice/NOTICE_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00001300 "testdata/reciprocal/lib/libd.so.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001301 },
1302 },
1303 {
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001304 condition: "restricted",
1305 name: "apex",
1306 roots: []string{"highest.apex.meta_lic"},
1307 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001308 SPDXVersion: "SPDX-2.2",
1309 DataLicense: "CC0-1.0",
1310 SPDXIdentifier: "DOCUMENT",
1311 DocumentName: "testdata-restricted-highest.apex",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00001312 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/restricted/highest.apex.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001313 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001314 Packages: []*spdx.Package{
1315 {
1316 PackageName: "testdata-restricted-highest.apex.meta_lic",
1317 PackageVersion: "NOASSERTION",
1318 PackageDownloadLocation: "NOASSERTION",
1319 PackageSPDXIdentifier: common.ElementID("testdata-restricted-highest.apex.meta_lic"),
1320 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1321 },
1322 {
1323 PackageName: "testdata-restricted-bin-bin1.meta_lic",
1324 PackageVersion: "NOASSERTION",
1325 PackageDownloadLocation: "NOASSERTION",
1326 PackageSPDXIdentifier: common.ElementID("testdata-restricted-bin-bin1.meta_lic"),
1327 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1328 },
1329 {
1330 PackageName: "testdata-restricted-bin-bin2.meta_lic",
1331 PackageVersion: "NOASSERTION",
1332 PackageDownloadLocation: "NOASSERTION",
1333 PackageSPDXIdentifier: common.ElementID("testdata-restricted-bin-bin2.meta_lic"),
1334 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1335 },
1336 {
1337 PackageName: "testdata-restricted-lib-liba.so.meta_lic",
1338 PackageVersion: "NOASSERTION",
1339 PackageDownloadLocation: "NOASSERTION",
1340 PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-liba.so.meta_lic"),
1341 PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1342 },
1343 {
1344 PackageName: "testdata-restricted-lib-libb.so.meta_lic",
1345 PackageVersion: "NOASSERTION",
1346 PackageDownloadLocation: "NOASSERTION",
1347 PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libb.so.meta_lic"),
1348 PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1349 },
1350 {
1351 PackageName: "testdata-restricted-lib-libc.a.meta_lic",
1352 PackageVersion: "NOASSERTION",
1353 PackageDownloadLocation: "NOASSERTION",
1354 PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libc.a.meta_lic"),
1355 PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1356 },
1357 {
1358 PackageName: "testdata-restricted-lib-libd.so.meta_lic",
1359 PackageVersion: "NOASSERTION",
1360 PackageDownloadLocation: "NOASSERTION",
1361 PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libd.so.meta_lic"),
1362 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1363 },
1364 },
1365 Relationships: []*spdx.Relationship{
1366 {
1367 RefA: common.MakeDocElementID("", "DOCUMENT"),
1368 RefB: common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
1369 Relationship: "DESCRIBES",
1370 },
1371 {
1372 RefA: common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
1373 RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1374 Relationship: "CONTAINS",
1375 },
1376 {
1377 RefA: common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
1378 RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1379 Relationship: "CONTAINS",
1380 },
1381 {
1382 RefA: common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
1383 RefB: common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
1384 Relationship: "CONTAINS",
1385 },
1386 {
1387 RefA: common.MakeDocElementID("", "testdata-restricted-highest.apex.meta_lic"),
1388 RefB: common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
1389 Relationship: "CONTAINS",
1390 },
1391 {
1392 RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1393 RefB: common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
1394 Relationship: "CONTAINS",
1395 },
1396 {
1397 RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1398 RefB: common.MakeDocElementID("", "testdata-restricted-lib-libc.a.meta_lic"),
1399 Relationship: "CONTAINS",
1400 },
1401 {
1402 RefA: common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
1403 RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1404 Relationship: "RUNTIME_DEPENDENCY_OF",
1405 },
1406 {
1407 RefA: common.MakeDocElementID("", "testdata-restricted-lib-libd.so.meta_lic"),
1408 RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1409 Relationship: "RUNTIME_DEPENDENCY_OF",
1410 },
1411 },
1412 OtherLicenses: []*spdx.OtherLicense{
1413 {
1414 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1415 ExtractedText: "&&&First Party License&&&\n",
1416 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
1417 },
1418 {
1419 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1420 ExtractedText: "%%%Notice License%%%\n",
1421 LicenseName: "testdata-notice-NOTICE_LICENSE",
1422 },
1423 {
1424 LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1425 ExtractedText: "$$$Reciprocal License$$$\n",
1426 LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
1427 },
1428 {
1429 LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1430 ExtractedText: "###Restricted License###\n",
1431 LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
1432 },
1433 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001434 },
1435 expectedDeps: []string{
1436 "testdata/firstparty/FIRST_PARTY_LICENSE",
1437 "testdata/notice/NOTICE_LICENSE",
1438 "testdata/reciprocal/RECIPROCAL_LICENSE",
1439 "testdata/restricted/RESTRICTED_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00001440 "testdata/restricted/bin/bin1.meta_lic",
1441 "testdata/restricted/bin/bin2.meta_lic",
1442 "testdata/restricted/highest.apex.meta_lic",
1443 "testdata/restricted/lib/liba.so.meta_lic",
1444 "testdata/restricted/lib/libb.so.meta_lic",
1445 "testdata/restricted/lib/libc.a.meta_lic",
1446 "testdata/restricted/lib/libd.so.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001447 },
1448 },
1449 {
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001450 condition: "restricted",
1451 name: "container",
1452 roots: []string{"container.zip.meta_lic"},
1453 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001454 SPDXVersion: "SPDX-2.2",
1455 DataLicense: "CC0-1.0",
1456 SPDXIdentifier: "DOCUMENT",
1457 DocumentName: "testdata-restricted-container.zip",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00001458 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/restricted/container.zip.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001459 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001460 Packages: []*spdx.Package{
1461 {
1462 PackageName: "testdata-restricted-container.zip.meta_lic",
1463 PackageVersion: "NOASSERTION",
1464 PackageDownloadLocation: "NOASSERTION",
1465 PackageSPDXIdentifier: common.ElementID("testdata-restricted-container.zip.meta_lic"),
1466 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1467 },
1468 {
1469 PackageName: "testdata-restricted-bin-bin1.meta_lic",
1470 PackageVersion: "NOASSERTION",
1471 PackageDownloadLocation: "NOASSERTION",
1472 PackageSPDXIdentifier: common.ElementID("testdata-restricted-bin-bin1.meta_lic"),
1473 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1474 },
1475 {
1476 PackageName: "testdata-restricted-bin-bin2.meta_lic",
1477 PackageVersion: "NOASSERTION",
1478 PackageDownloadLocation: "NOASSERTION",
1479 PackageSPDXIdentifier: common.ElementID("testdata-restricted-bin-bin2.meta_lic"),
1480 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1481 },
1482 {
1483 PackageName: "testdata-restricted-lib-liba.so.meta_lic",
1484 PackageVersion: "NOASSERTION",
1485 PackageDownloadLocation: "NOASSERTION",
1486 PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-liba.so.meta_lic"),
1487 PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1488 },
1489 {
1490 PackageName: "testdata-restricted-lib-libb.so.meta_lic",
1491 PackageVersion: "NOASSERTION",
1492 PackageDownloadLocation: "NOASSERTION",
1493 PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libb.so.meta_lic"),
1494 PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1495 },
1496 {
1497 PackageName: "testdata-restricted-lib-libc.a.meta_lic",
1498 PackageVersion: "NOASSERTION",
1499 PackageDownloadLocation: "NOASSERTION",
1500 PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libc.a.meta_lic"),
1501 PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1502 },
1503 {
1504 PackageName: "testdata-restricted-lib-libd.so.meta_lic",
1505 PackageVersion: "NOASSERTION",
1506 PackageDownloadLocation: "NOASSERTION",
1507 PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libd.so.meta_lic"),
1508 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1509 },
1510 },
1511 Relationships: []*spdx.Relationship{
1512 {
1513 RefA: common.MakeDocElementID("", "DOCUMENT"),
1514 RefB: common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
1515 Relationship: "DESCRIBES",
1516 },
1517 {
1518 RefA: common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
1519 RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1520 Relationship: "CONTAINS",
1521 },
1522 {
1523 RefA: common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
1524 RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1525 Relationship: "CONTAINS",
1526 },
1527 {
1528 RefA: common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
1529 RefB: common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
1530 Relationship: "CONTAINS",
1531 },
1532 {
1533 RefA: common.MakeDocElementID("", "testdata-restricted-container.zip.meta_lic"),
1534 RefB: common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
1535 Relationship: "CONTAINS",
1536 },
1537 {
1538 RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1539 RefB: common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
1540 Relationship: "CONTAINS",
1541 },
1542 {
1543 RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1544 RefB: common.MakeDocElementID("", "testdata-restricted-lib-libc.a.meta_lic"),
1545 Relationship: "CONTAINS",
1546 },
1547 {
1548 RefA: common.MakeDocElementID("", "testdata-restricted-lib-libb.so.meta_lic"),
1549 RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1550 Relationship: "RUNTIME_DEPENDENCY_OF",
1551 },
1552 {
1553 RefA: common.MakeDocElementID("", "testdata-restricted-lib-libd.so.meta_lic"),
1554 RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin2.meta_lic"),
1555 Relationship: "RUNTIME_DEPENDENCY_OF",
1556 },
1557 },
1558 OtherLicenses: []*spdx.OtherLicense{
1559 {
1560 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1561 ExtractedText: "&&&First Party License&&&\n",
1562 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
1563 },
1564 {
1565 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1566 ExtractedText: "%%%Notice License%%%\n",
1567 LicenseName: "testdata-notice-NOTICE_LICENSE",
1568 },
1569 {
1570 LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1571 ExtractedText: "$$$Reciprocal License$$$\n",
1572 LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
1573 },
1574 {
1575 LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1576 ExtractedText: "###Restricted License###\n",
1577 LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
1578 },
1579 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001580 },
1581 expectedDeps: []string{
1582 "testdata/firstparty/FIRST_PARTY_LICENSE",
1583 "testdata/notice/NOTICE_LICENSE",
1584 "testdata/reciprocal/RECIPROCAL_LICENSE",
1585 "testdata/restricted/RESTRICTED_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00001586 "testdata/restricted/bin/bin1.meta_lic",
1587 "testdata/restricted/bin/bin2.meta_lic",
1588 "testdata/restricted/container.zip.meta_lic",
1589 "testdata/restricted/lib/liba.so.meta_lic",
1590 "testdata/restricted/lib/libb.so.meta_lic",
1591 "testdata/restricted/lib/libc.a.meta_lic",
1592 "testdata/restricted/lib/libd.so.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001593 },
1594 },
1595 {
1596 condition: "restricted",
1597 name: "binary",
1598 roots: []string{"bin/bin1.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001599 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001600 SPDXVersion: "SPDX-2.2",
1601 DataLicense: "CC0-1.0",
1602 SPDXIdentifier: "DOCUMENT",
1603 DocumentName: "testdata-restricted-bin-bin1",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00001604 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/restricted/bin/bin1.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001605 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001606 Packages: []*spdx.Package{
1607 {
1608 PackageName: "testdata-restricted-bin-bin1.meta_lic",
1609 PackageVersion: "NOASSERTION",
1610 PackageDownloadLocation: "NOASSERTION",
1611 PackageSPDXIdentifier: common.ElementID("testdata-restricted-bin-bin1.meta_lic"),
1612 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1613 },
1614 {
1615 PackageName: "testdata-restricted-lib-liba.so.meta_lic",
1616 PackageVersion: "NOASSERTION",
1617 PackageDownloadLocation: "NOASSERTION",
1618 PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-liba.so.meta_lic"),
1619 PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1620 },
1621 {
1622 PackageName: "testdata-restricted-lib-libc.a.meta_lic",
1623 PackageVersion: "NOASSERTION",
1624 PackageDownloadLocation: "NOASSERTION",
1625 PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libc.a.meta_lic"),
1626 PackageLicenseConcluded: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1627 },
1628 },
1629 Relationships: []*spdx.Relationship{
1630 {
1631 RefA: common.MakeDocElementID("", "DOCUMENT"),
1632 RefB: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1633 Relationship: "DESCRIBES",
1634 },
1635 {
1636 RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1637 RefB: common.MakeDocElementID("", "testdata-restricted-lib-liba.so.meta_lic"),
1638 Relationship: "CONTAINS",
1639 },
1640 {
1641 RefA: common.MakeDocElementID("", "testdata-restricted-bin-bin1.meta_lic"),
1642 RefB: common.MakeDocElementID("", "testdata-restricted-lib-libc.a.meta_lic"),
1643 Relationship: "CONTAINS",
1644 },
1645 },
1646 OtherLicenses: []*spdx.OtherLicense{
1647 {
1648 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1649 ExtractedText: "&&&First Party License&&&\n",
1650 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
1651 },
1652 {
1653 LicenseIdentifier: "LicenseRef-testdata-reciprocal-RECIPROCAL_LICENSE",
1654 ExtractedText: "$$$Reciprocal License$$$\n",
1655 LicenseName: "testdata-reciprocal-RECIPROCAL_LICENSE",
1656 },
1657 {
1658 LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1659 ExtractedText: "###Restricted License###\n",
1660 LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
1661 },
1662 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001663 },
1664 expectedDeps: []string{
1665 "testdata/firstparty/FIRST_PARTY_LICENSE",
1666 "testdata/reciprocal/RECIPROCAL_LICENSE",
1667 "testdata/restricted/RESTRICTED_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00001668 "testdata/restricted/bin/bin1.meta_lic",
1669 "testdata/restricted/lib/liba.so.meta_lic",
1670 "testdata/restricted/lib/libc.a.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001671 },
1672 },
1673 {
1674 condition: "restricted",
1675 name: "library",
1676 roots: []string{"lib/libd.so.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001677 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001678 SPDXVersion: "SPDX-2.2",
1679 DataLicense: "CC0-1.0",
1680 SPDXIdentifier: "DOCUMENT",
1681 DocumentName: "testdata-restricted-lib-libd.so",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00001682 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/restricted/lib/libd.so.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001683 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001684 Packages: []*spdx.Package{
1685 {
1686 PackageName: "testdata-restricted-lib-libd.so.meta_lic",
1687 PackageVersion: "NOASSERTION",
1688 PackageDownloadLocation: "NOASSERTION",
1689 PackageSPDXIdentifier: common.ElementID("testdata-restricted-lib-libd.so.meta_lic"),
1690 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1691 },
1692 },
1693 Relationships: []*spdx.Relationship{
1694 {
1695 RefA: common.MakeDocElementID("", "DOCUMENT"),
1696 RefB: common.MakeDocElementID("", "testdata-restricted-lib-libd.so.meta_lic"),
1697 Relationship: "DESCRIBES",
1698 },
1699 },
1700 OtherLicenses: []*spdx.OtherLicense{
1701 {
1702 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1703 ExtractedText: "%%%Notice License%%%\n",
1704 LicenseName: "testdata-notice-NOTICE_LICENSE",
1705 },
1706 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001707 },
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00001708 expectedDeps: []string{
1709 "testdata/notice/NOTICE_LICENSE",
1710 "testdata/restricted/lib/libd.so.meta_lic",
1711 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001712 },
1713 {
1714 condition: "proprietary",
1715 name: "apex",
1716 roots: []string{"highest.apex.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001717 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001718 SPDXVersion: "SPDX-2.2",
1719 DataLicense: "CC0-1.0",
1720 SPDXIdentifier: "DOCUMENT",
1721 DocumentName: "testdata-proprietary-highest.apex",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00001722 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/proprietary/highest.apex.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001723 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001724 Packages: []*spdx.Package{
1725 {
1726 PackageName: "testdata-proprietary-highest.apex.meta_lic",
1727 PackageVersion: "NOASSERTION",
1728 PackageDownloadLocation: "NOASSERTION",
1729 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-highest.apex.meta_lic"),
1730 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1731 },
1732 {
1733 PackageName: "testdata-proprietary-bin-bin1.meta_lic",
1734 PackageVersion: "NOASSERTION",
1735 PackageDownloadLocation: "NOASSERTION",
1736 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin1.meta_lic"),
1737 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1738 },
1739 {
1740 PackageName: "testdata-proprietary-bin-bin2.meta_lic",
1741 PackageVersion: "NOASSERTION",
1742 PackageDownloadLocation: "NOASSERTION",
1743 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin2.meta_lic"),
1744 PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1745 },
1746 {
1747 PackageName: "testdata-proprietary-lib-liba.so.meta_lic",
1748 PackageVersion: "NOASSERTION",
1749 PackageDownloadLocation: "NOASSERTION",
1750 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
1751 PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1752 },
1753 {
1754 PackageName: "testdata-proprietary-lib-libb.so.meta_lic",
1755 PackageVersion: "NOASSERTION",
1756 PackageDownloadLocation: "NOASSERTION",
1757 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libb.so.meta_lic"),
1758 PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1759 },
1760 {
1761 PackageName: "testdata-proprietary-lib-libc.a.meta_lic",
1762 PackageVersion: "NOASSERTION",
1763 PackageDownloadLocation: "NOASSERTION",
1764 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libc.a.meta_lic"),
1765 PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1766 },
1767 {
1768 PackageName: "testdata-proprietary-lib-libd.so.meta_lic",
1769 PackageVersion: "NOASSERTION",
1770 PackageDownloadLocation: "NOASSERTION",
1771 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libd.so.meta_lic"),
1772 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1773 },
1774 },
1775 Relationships: []*spdx.Relationship{
1776 {
1777 RefA: common.MakeDocElementID("", "DOCUMENT"),
1778 RefB: common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
1779 Relationship: "DESCRIBES",
1780 },
1781 {
1782 RefA: common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
1783 RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1784 Relationship: "CONTAINS",
1785 },
1786 {
1787 RefA: common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
1788 RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1789 Relationship: "CONTAINS",
1790 },
1791 {
1792 RefA: common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
1793 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
1794 Relationship: "CONTAINS",
1795 },
1796 {
1797 RefA: common.MakeDocElementID("", "testdata-proprietary-highest.apex.meta_lic"),
1798 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
1799 Relationship: "CONTAINS",
1800 },
1801 {
1802 RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1803 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
1804 Relationship: "CONTAINS",
1805 },
1806 {
1807 RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1808 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libc.a.meta_lic"),
1809 Relationship: "CONTAINS",
1810 },
1811 {
1812 RefA: common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
1813 RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1814 Relationship: "RUNTIME_DEPENDENCY_OF",
1815 },
1816 {
1817 RefA: common.MakeDocElementID("", "testdata-proprietary-lib-libd.so.meta_lic"),
1818 RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1819 Relationship: "RUNTIME_DEPENDENCY_OF",
1820 },
1821 },
1822 OtherLicenses: []*spdx.OtherLicense{
1823 {
1824 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1825 ExtractedText: "&&&First Party License&&&\n",
1826 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
1827 },
1828 {
1829 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1830 ExtractedText: "%%%Notice License%%%\n",
1831 LicenseName: "testdata-notice-NOTICE_LICENSE",
1832 },
1833 {
1834 LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1835 ExtractedText: "@@@Proprietary License@@@\n",
1836 LicenseName: "testdata-proprietary-PROPRIETARY_LICENSE",
1837 },
1838 {
1839 LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1840 ExtractedText: "###Restricted License###\n",
1841 LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
1842 },
1843 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001844 },
1845 expectedDeps: []string{
1846 "testdata/firstparty/FIRST_PARTY_LICENSE",
1847 "testdata/notice/NOTICE_LICENSE",
1848 "testdata/proprietary/PROPRIETARY_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00001849 "testdata/proprietary/bin/bin1.meta_lic",
1850 "testdata/proprietary/bin/bin2.meta_lic",
1851 "testdata/proprietary/highest.apex.meta_lic",
1852 "testdata/proprietary/lib/liba.so.meta_lic",
1853 "testdata/proprietary/lib/libb.so.meta_lic",
1854 "testdata/proprietary/lib/libc.a.meta_lic",
1855 "testdata/proprietary/lib/libd.so.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001856 "testdata/restricted/RESTRICTED_LICENSE",
1857 },
1858 },
1859 {
1860 condition: "proprietary",
1861 name: "container",
1862 roots: []string{"container.zip.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001863 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001864 SPDXVersion: "SPDX-2.2",
1865 DataLicense: "CC0-1.0",
1866 SPDXIdentifier: "DOCUMENT",
1867 DocumentName: "testdata-proprietary-container.zip",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00001868 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/proprietary/container.zip.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00001869 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00001870 Packages: []*spdx.Package{
1871 {
1872 PackageName: "testdata-proprietary-container.zip.meta_lic",
1873 PackageVersion: "NOASSERTION",
1874 PackageDownloadLocation: "NOASSERTION",
1875 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-container.zip.meta_lic"),
1876 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1877 },
1878 {
1879 PackageName: "testdata-proprietary-bin-bin1.meta_lic",
1880 PackageVersion: "NOASSERTION",
1881 PackageDownloadLocation: "NOASSERTION",
1882 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin1.meta_lic"),
1883 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1884 },
1885 {
1886 PackageName: "testdata-proprietary-bin-bin2.meta_lic",
1887 PackageVersion: "NOASSERTION",
1888 PackageDownloadLocation: "NOASSERTION",
1889 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin2.meta_lic"),
1890 PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1891 },
1892 {
1893 PackageName: "testdata-proprietary-lib-liba.so.meta_lic",
1894 PackageVersion: "NOASSERTION",
1895 PackageDownloadLocation: "NOASSERTION",
1896 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
1897 PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1898 },
1899 {
1900 PackageName: "testdata-proprietary-lib-libb.so.meta_lic",
1901 PackageVersion: "NOASSERTION",
1902 PackageDownloadLocation: "NOASSERTION",
1903 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libb.so.meta_lic"),
1904 PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1905 },
1906 {
1907 PackageName: "testdata-proprietary-lib-libc.a.meta_lic",
1908 PackageVersion: "NOASSERTION",
1909 PackageDownloadLocation: "NOASSERTION",
1910 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libc.a.meta_lic"),
1911 PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1912 },
1913 {
1914 PackageName: "testdata-proprietary-lib-libd.so.meta_lic",
1915 PackageVersion: "NOASSERTION",
1916 PackageDownloadLocation: "NOASSERTION",
1917 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libd.so.meta_lic"),
1918 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1919 },
1920 },
1921 Relationships: []*spdx.Relationship{
1922 {
1923 RefA: common.MakeDocElementID("", "DOCUMENT"),
1924 RefB: common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
1925 Relationship: "DESCRIBES",
1926 },
1927 {
1928 RefA: common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
1929 RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1930 Relationship: "CONTAINS",
1931 },
1932 {
1933 RefA: common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
1934 RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1935 Relationship: "CONTAINS",
1936 },
1937 {
1938 RefA: common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
1939 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
1940 Relationship: "CONTAINS",
1941 },
1942 {
1943 RefA: common.MakeDocElementID("", "testdata-proprietary-container.zip.meta_lic"),
1944 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
1945 Relationship: "CONTAINS",
1946 },
1947 {
1948 RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1949 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
1950 Relationship: "CONTAINS",
1951 },
1952 {
1953 RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
1954 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libc.a.meta_lic"),
1955 Relationship: "CONTAINS",
1956 },
1957 {
1958 RefA: common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
1959 RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1960 Relationship: "RUNTIME_DEPENDENCY_OF",
1961 },
1962 {
1963 RefA: common.MakeDocElementID("", "testdata-proprietary-lib-libd.so.meta_lic"),
1964 RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin2.meta_lic"),
1965 Relationship: "RUNTIME_DEPENDENCY_OF",
1966 },
1967 },
1968 OtherLicenses: []*spdx.OtherLicense{
1969 {
1970 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
1971 ExtractedText: "&&&First Party License&&&\n",
1972 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
1973 },
1974 {
1975 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
1976 ExtractedText: "%%%Notice License%%%\n",
1977 LicenseName: "testdata-notice-NOTICE_LICENSE",
1978 },
1979 {
1980 LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
1981 ExtractedText: "@@@Proprietary License@@@\n",
1982 LicenseName: "testdata-proprietary-PROPRIETARY_LICENSE",
1983 },
1984 {
1985 LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
1986 ExtractedText: "###Restricted License###\n",
1987 LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
1988 },
1989 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00001990 },
1991 expectedDeps: []string{
1992 "testdata/firstparty/FIRST_PARTY_LICENSE",
1993 "testdata/notice/NOTICE_LICENSE",
1994 "testdata/proprietary/PROPRIETARY_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00001995 "testdata/proprietary/bin/bin1.meta_lic",
1996 "testdata/proprietary/bin/bin2.meta_lic",
1997 "testdata/proprietary/container.zip.meta_lic",
1998 "testdata/proprietary/lib/liba.so.meta_lic",
1999 "testdata/proprietary/lib/libb.so.meta_lic",
2000 "testdata/proprietary/lib/libc.a.meta_lic",
2001 "testdata/proprietary/lib/libd.so.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002002 "testdata/restricted/RESTRICTED_LICENSE",
2003 },
2004 },
2005 {
2006 condition: "proprietary",
2007 name: "application",
2008 roots: []string{"application.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002009 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00002010 SPDXVersion: "SPDX-2.2",
2011 DataLicense: "CC0-1.0",
2012 SPDXIdentifier: "DOCUMENT",
2013 DocumentName: "testdata-proprietary-application",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00002014 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/proprietary/application.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00002015 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002016 Packages: []*spdx.Package{
2017 {
2018 PackageName: "testdata-proprietary-application.meta_lic",
2019 PackageVersion: "NOASSERTION",
2020 PackageDownloadLocation: "NOASSERTION",
2021 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-application.meta_lic"),
2022 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
2023 },
2024 {
2025 PackageName: "testdata-proprietary-bin-bin3.meta_lic",
2026 PackageVersion: "NOASSERTION",
2027 PackageDownloadLocation: "NOASSERTION",
2028 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin3.meta_lic"),
2029 PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
2030 },
2031 {
2032 PackageName: "testdata-proprietary-lib-liba.so.meta_lic",
2033 PackageVersion: "NOASSERTION",
2034 PackageDownloadLocation: "NOASSERTION",
2035 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
2036 PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
2037 },
2038 {
2039 PackageName: "testdata-proprietary-lib-libb.so.meta_lic",
2040 PackageVersion: "NOASSERTION",
2041 PackageDownloadLocation: "NOASSERTION",
2042 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libb.so.meta_lic"),
2043 PackageLicenseConcluded: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
2044 },
2045 },
2046 Relationships: []*spdx.Relationship{
2047 {
2048 RefA: common.MakeDocElementID("", "DOCUMENT"),
2049 RefB: common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
2050 Relationship: "DESCRIBES",
2051 },
2052 {
2053 RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin3.meta_lic"),
2054 RefB: common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
2055 Relationship: "BUILD_TOOL_OF",
2056 },
2057 {
2058 RefA: common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
2059 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
2060 Relationship: "CONTAINS",
2061 },
2062 {
2063 RefA: common.MakeDocElementID("", "testdata-proprietary-lib-libb.so.meta_lic"),
2064 RefB: common.MakeDocElementID("", "testdata-proprietary-application.meta_lic"),
2065 Relationship: "RUNTIME_DEPENDENCY_OF",
2066 },
2067 },
2068 OtherLicenses: []*spdx.OtherLicense{
2069 {
2070 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
2071 ExtractedText: "&&&First Party License&&&\n",
2072 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
2073 },
2074 {
2075 LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
2076 ExtractedText: "@@@Proprietary License@@@\n",
2077 LicenseName: "testdata-proprietary-PROPRIETARY_LICENSE",
2078 },
2079 {
2080 LicenseIdentifier: "LicenseRef-testdata-restricted-RESTRICTED_LICENSE",
2081 ExtractedText: "###Restricted License###\n",
2082 LicenseName: "testdata-restricted-RESTRICTED_LICENSE",
2083 },
2084 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002085 },
2086 expectedDeps: []string{
2087 "testdata/firstparty/FIRST_PARTY_LICENSE",
2088 "testdata/proprietary/PROPRIETARY_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00002089 "testdata/proprietary/application.meta_lic",
2090 "testdata/proprietary/bin/bin3.meta_lic",
2091 "testdata/proprietary/lib/liba.so.meta_lic",
2092 "testdata/proprietary/lib/libb.so.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002093 "testdata/restricted/RESTRICTED_LICENSE",
2094 },
2095 },
2096 {
2097 condition: "proprietary",
2098 name: "binary",
2099 roots: []string{"bin/bin1.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002100 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00002101 SPDXVersion: "SPDX-2.2",
2102 DataLicense: "CC0-1.0",
2103 SPDXIdentifier: "DOCUMENT",
2104 DocumentName: "testdata-proprietary-bin-bin1",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00002105 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/proprietary/bin/bin1.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00002106 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002107 Packages: []*spdx.Package{
2108 {
2109 PackageName: "testdata-proprietary-bin-bin1.meta_lic",
2110 PackageVersion: "NOASSERTION",
2111 PackageDownloadLocation: "NOASSERTION",
2112 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-bin-bin1.meta_lic"),
2113 PackageLicenseConcluded: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
2114 },
2115 {
2116 PackageName: "testdata-proprietary-lib-liba.so.meta_lic",
2117 PackageVersion: "NOASSERTION",
2118 PackageDownloadLocation: "NOASSERTION",
2119 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-liba.so.meta_lic"),
2120 PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
2121 },
2122 {
2123 PackageName: "testdata-proprietary-lib-libc.a.meta_lic",
2124 PackageVersion: "NOASSERTION",
2125 PackageDownloadLocation: "NOASSERTION",
2126 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libc.a.meta_lic"),
2127 PackageLicenseConcluded: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
2128 },
2129 },
2130 Relationships: []*spdx.Relationship{
2131 {
2132 RefA: common.MakeDocElementID("", "DOCUMENT"),
2133 RefB: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
2134 Relationship: "DESCRIBES",
2135 },
2136 {
2137 RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
2138 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-liba.so.meta_lic"),
2139 Relationship: "CONTAINS",
2140 },
2141 {
2142 RefA: common.MakeDocElementID("", "testdata-proprietary-bin-bin1.meta_lic"),
2143 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libc.a.meta_lic"),
2144 Relationship: "CONTAINS",
2145 },
2146 },
2147 OtherLicenses: []*spdx.OtherLicense{
2148 {
2149 LicenseIdentifier: "LicenseRef-testdata-firstparty-FIRST_PARTY_LICENSE",
2150 ExtractedText: "&&&First Party License&&&\n",
2151 LicenseName: "testdata-firstparty-FIRST_PARTY_LICENSE",
2152 },
2153 {
2154 LicenseIdentifier: "LicenseRef-testdata-proprietary-PROPRIETARY_LICENSE",
2155 ExtractedText: "@@@Proprietary License@@@\n",
2156 LicenseName: "testdata-proprietary-PROPRIETARY_LICENSE",
2157 },
2158 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002159 },
2160 expectedDeps: []string{
2161 "testdata/firstparty/FIRST_PARTY_LICENSE",
2162 "testdata/proprietary/PROPRIETARY_LICENSE",
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00002163 "testdata/proprietary/bin/bin1.meta_lic",
2164 "testdata/proprietary/lib/liba.so.meta_lic",
2165 "testdata/proprietary/lib/libc.a.meta_lic",
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002166 },
2167 },
2168 {
2169 condition: "proprietary",
2170 name: "library",
2171 roots: []string{"lib/libd.so.meta_lic"},
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002172 expectedOut: &spdx.Document{
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00002173 SPDXVersion: "SPDX-2.2",
2174 DataLicense: "CC0-1.0",
2175 SPDXIdentifier: "DOCUMENT",
2176 DocumentName: "testdata-proprietary-lib-libd.so",
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00002177 DocumentNamespace: generateSPDXNamespace("", "1970-01-01T00:00:00Z", "testdata/proprietary/lib/libd.so.meta_lic"),
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00002178 CreationInfo: getCreationInfo(t),
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002179 Packages: []*spdx.Package{
2180 {
2181 PackageName: "testdata-proprietary-lib-libd.so.meta_lic",
2182 PackageVersion: "NOASSERTION",
2183 PackageDownloadLocation: "NOASSERTION",
2184 PackageSPDXIdentifier: common.ElementID("testdata-proprietary-lib-libd.so.meta_lic"),
2185 PackageLicenseConcluded: "LicenseRef-testdata-notice-NOTICE_LICENSE",
2186 },
2187 },
2188 Relationships: []*spdx.Relationship{
2189 {
2190 RefA: common.MakeDocElementID("", "DOCUMENT"),
2191 RefB: common.MakeDocElementID("", "testdata-proprietary-lib-libd.so.meta_lic"),
2192 Relationship: "DESCRIBES",
2193 },
2194 },
2195 OtherLicenses: []*spdx.OtherLicense{
2196 {
2197 LicenseIdentifier: "LicenseRef-testdata-notice-NOTICE_LICENSE",
2198 ExtractedText: "%%%Notice License%%%\n",
2199 LicenseName: "testdata-notice-NOTICE_LICENSE",
2200 },
2201 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002202 },
Ibrahim Kanouche649b4d72022-11-12 05:46:12 +00002203 expectedDeps: []string{
2204 "testdata/notice/NOTICE_LICENSE",
2205 "testdata/proprietary/lib/libd.so.meta_lic",
2206 },
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002207 },
2208 }
2209 for _, tt := range tests {
2210 t.Run(tt.condition+" "+tt.name, func(t *testing.T) {
2211 stdout := &bytes.Buffer{}
2212 stderr := &bytes.Buffer{}
2213
2214 rootFiles := make([]string, 0, len(tt.roots))
2215 for _, r := range tt.roots {
2216 rootFiles = append(rootFiles, "testdata/"+tt.condition+"/"+r)
2217 }
2218
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00002219 ctx := context{stdout, stderr, compliance.GetFS(tt.outDir), "", []string{tt.stripPrefix}, fakeTime, ""}
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002220
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002221 spdxDoc, deps, err := sbomGenerator(&ctx, rootFiles...)
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002222 if err != nil {
2223 t.Fatalf("sbom: error = %v, stderr = %v", err, stderr)
2224 return
2225 }
2226 if stderr.Len() > 0 {
2227 t.Errorf("sbom: gotStderr = %v, want none", stderr)
2228 }
2229
Ibrahim Kanouche8c745a42023-04-07 18:29:48 +00002230 if err := validate(spdxDoc); err != nil {
2231 t.Fatalf("sbom: document fails to validate: %v", err)
2232 }
2233
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002234 gotData, err := json.Marshal(spdxDoc)
2235 if err != nil {
2236 t.Fatalf("sbom: failed to marshal spdx doc: %v", err)
2237 return
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002238 }
2239
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002240 t.Logf("Got SPDX Doc: %s", string(gotData))
2241
2242 expectedData, err := json.Marshal(tt.expectedOut)
2243 if err != nil {
2244 t.Fatalf("sbom: failed to marshal spdx doc: %v", err)
2245 return
2246 }
2247
2248 t.Logf("Want SPDX Doc: %s", string(expectedData))
2249
2250 // compare the spdx Docs
2251 compareSpdxDocs(t, spdxDoc, tt.expectedOut)
2252
2253 // compare deps
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002254 t.Logf("got deps: %q", deps)
2255
2256 t.Logf("want deps: %q", tt.expectedDeps)
2257
2258 if g, w := deps, tt.expectedDeps; !reflect.DeepEqual(g, w) {
2259 t.Errorf("unexpected deps, wanted:\n%s\ngot:\n%s\n",
2260 strings.Join(w, "\n"), strings.Join(g, "\n"))
2261 }
2262 })
2263 }
2264}
2265
Ibrahim Kanouche397a9cf2023-04-17 16:25:46 +00002266func TestGenerateSPDXNamespace(t *testing.T) {
2267
2268 buildID1 := "example-1"
2269 buildID2 := "example-2"
2270 files1 := "file1"
2271 timestamp1 := "2022-05-01"
2272 timestamp2 := "2022-05-02"
2273 files2 := "file2"
2274
2275 // Test case 1: different timestamps, same files
2276 nsh1 := generateSPDXNamespace("", timestamp1, files1)
2277 nsh2 := generateSPDXNamespace("", timestamp2, files1)
2278
2279 if nsh1 == "" {
2280 t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", "", timestamp1, files1)
2281 }
2282
2283 if nsh2 == "" {
2284 t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", "", timestamp2, files1)
2285 }
2286
2287 if nsh1 == nsh2 {
2288 t.Errorf("generateSPDXNamespace(%s, %s, %s) and generateSPDXNamespace(%s, %s, %s): expected different namespace hashes, but got the same", "", timestamp1, files1, "", timestamp2, files1)
2289 }
2290
2291 // Test case 2: different build ids, same timestamps and files
2292 nsh1 = generateSPDXNamespace(buildID1, timestamp1, files1)
2293 nsh2 = generateSPDXNamespace(buildID2, timestamp1, files1)
2294
2295 if nsh1 == "" {
2296 t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID1, timestamp1, files1)
2297 }
2298
2299 if nsh2 == "" {
2300 t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID2, timestamp1, files1)
2301 }
2302
2303 if nsh1 == nsh2 {
2304 t.Errorf("generateSPDXNamespace(%s, %s, %s) and generateSPDXNamespace(%s, %s, %s): expected different namespace hashes, but got the same", buildID1, timestamp1, files1, buildID2, timestamp1, files1)
2305 }
2306
2307 // Test case 3: same build ids and files, different timestamps
2308 nsh1 = generateSPDXNamespace(buildID1, timestamp1, files1)
2309 nsh2 = generateSPDXNamespace(buildID1, timestamp2, files1)
2310
2311 if nsh1 == "" {
2312 t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID1, timestamp1, files1)
2313 }
2314
2315 if nsh2 == "" {
2316 t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID1, timestamp2, files1)
2317 }
2318
2319 if nsh1 != nsh2 {
2320 t.Errorf("generateSPDXNamespace(%s, %s, %s) and generateSPDXNamespace(%s, %s, %s): expected same namespace hashes, but got different: %s and %s", buildID1, timestamp1, files1, buildID2, timestamp1, files1, nsh1, nsh2)
2321 }
2322
2323 // Test case 4: same build ids and timestamps, different files
2324 nsh1 = generateSPDXNamespace(buildID1, timestamp1, files1)
2325 nsh2 = generateSPDXNamespace(buildID1, timestamp1, files2)
2326
2327 if nsh1 == "" {
2328 t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID1, timestamp1, files1)
2329 }
2330
2331 if nsh2 == "" {
2332 t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", buildID1, timestamp1, files2)
2333 }
2334
2335 if nsh1 == nsh2 {
2336 t.Errorf("generateSPDXNamespace(%s, %s, %s) and generateSPDXNamespace(%s, %s, %s): expected different namespace hashes, but got the same", buildID1, timestamp1, files1, buildID1, timestamp1, files2)
2337 }
2338
2339 // Test case 5: empty build ids, same timestamps and different files
2340 nsh1 = generateSPDXNamespace("", timestamp1, files1)
2341 nsh2 = generateSPDXNamespace("", timestamp1, files2)
2342
2343 if nsh1 == "" {
2344 t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", "", timestamp1, files1)
2345 }
2346
2347 if nsh2 == "" {
2348 t.Errorf("generateSPDXNamespace(%s, %s, %s): expected non-empty string, but got empty string", "", timestamp1, files2)
2349 }
2350
2351 if nsh1 == nsh2 {
2352 t.Errorf("generateSPDXNamespace(%s, %s, %s) and generateSPDXNamespace(%s, %s, %s): expected different namespace hashes, but got the same", "", timestamp1, files1, "", timestamp1, files2)
2353 }
2354}
2355
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002356func getCreationInfo(t *testing.T) *spdx.CreationInfo {
2357 ci, err := builder2v2.BuildCreationInfoSection2_2("Organization", "Google LLC", nil)
2358 if err != nil {
2359 t.Errorf("Unable to get creation info: %v", err)
2360 return nil
2361 }
2362 return ci
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002363}
2364
Ibrahim Kanouche8c745a42023-04-07 18:29:48 +00002365// validate returns an error if the Document is found to be invalid
2366func validate(doc *spdx.Document) error {
2367 if doc.SPDXVersion == "" {
2368 return fmt.Errorf("SPDXVersion: got nothing, want spdx version")
2369 }
2370 if doc.DataLicense == "" {
2371 return fmt.Errorf("DataLicense: got nothing, want Data License")
2372 }
2373 if doc.SPDXIdentifier == "" {
2374 return fmt.Errorf("SPDXIdentifier: got nothing, want SPDX Identifier")
2375 }
2376 if doc.DocumentName == "" {
2377 return fmt.Errorf("DocumentName: got nothing, want Document Name")
2378 }
Jingwen Chen376b6b62023-06-07 05:58:11 +00002379 if c := fmt.Sprintf("%v", doc.CreationInfo.Creators[1].Creator); c != "Google LLC" {
2380 return fmt.Errorf("Creator: got %v, want 'Google LLC'", c)
Ibrahim Kanouche8c745a42023-04-07 18:29:48 +00002381 }
2382 _, err := time.Parse(time.RFC3339, doc.CreationInfo.Created)
2383 if err != nil {
2384 return fmt.Errorf("Invalid time spec: %q: got error %q, want no error", doc.CreationInfo.Created, err)
2385 }
2386
2387 for _, license := range doc.OtherLicenses {
2388 if license.ExtractedText == "" {
2389 return fmt.Errorf("License file: %q: got nothing, want license text", license.LicenseName)
2390 }
2391 }
2392 return nil
2393}
2394
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002395// compareSpdxDocs deep-compares two spdx docs by going through the info section, packages, relationships and licenses
2396func compareSpdxDocs(t *testing.T, actual, expected *spdx.Document) {
2397
2398 if actual == nil || expected == nil {
2399 t.Errorf("SBOM: SPDX Doc is nil! Got %v: Expected %v", actual, expected)
2400 }
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00002401
2402 if actual.DocumentName != expected.DocumentName {
2403 t.Errorf("sbom: unexpected SPDX Document Name got %q, want %q", actual.DocumentName, expected.DocumentName)
2404 }
2405
2406 if actual.SPDXVersion != expected.SPDXVersion {
2407 t.Errorf("sbom: unexpected SPDX Version got %s, want %s", actual.SPDXVersion, expected.SPDXVersion)
2408 }
2409
2410 if actual.DataLicense != expected.DataLicense {
2411 t.Errorf("sbom: unexpected SPDX DataLicense got %s, want %s", actual.DataLicense, expected.DataLicense)
2412 }
2413
2414 if actual.SPDXIdentifier != expected.SPDXIdentifier {
2415 t.Errorf("sbom: unexpected SPDX Identified got %s, want %s", actual.SPDXIdentifier, expected.SPDXIdentifier)
2416 }
2417
2418 if actual.DocumentNamespace != expected.DocumentNamespace {
2419 t.Errorf("sbom: unexpected SPDX Document Namespace got %s, want %s", actual.DocumentNamespace, expected.DocumentNamespace)
2420 }
2421
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002422 // compare creation info
2423 compareSpdxCreationInfo(t, actual.CreationInfo, expected.CreationInfo)
2424
2425 // compare packages
2426 if len(actual.Packages) != len(expected.Packages) {
2427 t.Errorf("SBOM: Number of Packages is different! Got %d: Expected %d", len(actual.Packages), len(expected.Packages))
2428 }
2429
2430 for i, pkg := range actual.Packages {
2431 if !compareSpdxPackages(t, i, pkg, expected.Packages[i]) {
2432 break
2433 }
2434 }
2435
2436 // compare licenses
2437 if len(actual.OtherLicenses) != len(expected.OtherLicenses) {
2438 t.Errorf("SBOM: Number of Licenses in actual is different! Got %d: Expected %d", len(actual.OtherLicenses), len(expected.OtherLicenses))
2439 }
2440 for i, license := range actual.OtherLicenses {
2441 if !compareLicenses(t, i, license, expected.OtherLicenses[i]) {
2442 break
2443 }
2444 }
2445
2446 //compare Relationships
2447 if len(actual.Relationships) != len(expected.Relationships) {
2448 t.Errorf("SBOM: Number of Licenses in actual is different! Got %d: Expected %d", len(actual.Relationships), len(expected.Relationships))
2449 }
2450 for i, rl := range actual.Relationships {
2451 if !compareRelationShips(t, i, rl, expected.Relationships[i]) {
2452 break
2453 }
2454 }
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002455}
2456
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002457func compareSpdxCreationInfo(t *testing.T, actual, expected *spdx.CreationInfo) {
2458 if actual == nil || expected == nil {
2459 t.Errorf("SBOM: Creation info is nil! Got %q: Expected %q", actual, expected)
2460 }
2461
2462 if actual.LicenseListVersion != expected.LicenseListVersion {
2463 t.Errorf("SBOM: Creation info license version Error! Got %s: Expected %s", actual.LicenseListVersion, expected.LicenseListVersion)
2464 }
2465
2466 if len(actual.Creators) != len(expected.Creators) {
2467 t.Errorf("SBOM: Creation info creators Error! Got %d: Expected %d", len(actual.Creators), len(expected.Creators))
2468 }
2469
2470 for i, info := range actual.Creators {
2471 if info != expected.Creators[i] {
2472 t.Errorf("SBOM: Creation info creators Error! Got %q: Expected %q", info, expected.Creators[i])
2473 }
2474 }
2475}
2476
2477func compareSpdxPackages(t *testing.T, i int, actual, expected *spdx.Package) bool {
2478 if actual == nil || expected == nil {
2479 t.Errorf("SBOM: Packages are nil at index %d! Got %v: Expected %v", i, actual, expected)
Bob Badour928ee9d2023-03-31 14:51:36 +00002480 return false
Ibrahim Kanouchee97adc52023-03-20 16:42:09 +00002481 }
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002482 if actual.PackageName != expected.PackageName {
2483 t.Errorf("SBOM: Package name Error at index %d! Got %s: Expected %s", i, actual.PackageName, expected.PackageName)
Ibrahim Kanouchee97adc52023-03-20 16:42:09 +00002484 return false
2485 }
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002486
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002487 if actual.PackageVersion != expected.PackageVersion {
2488 t.Errorf("SBOM: Package version Error at index %d! Got %s: Expected %s", i, actual.PackageVersion, expected.PackageVersion)
Ibrahim Kanouchee97adc52023-03-20 16:42:09 +00002489 return false
2490 }
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002491
2492 if actual.PackageSPDXIdentifier != expected.PackageSPDXIdentifier {
2493 t.Errorf("SBOM: Package identifier Error at index %d! Got %s: Expected %s", i, actual.PackageSPDXIdentifier, expected.PackageSPDXIdentifier)
2494 return false
2495 }
2496
2497 if actual.PackageDownloadLocation != expected.PackageDownloadLocation {
2498 t.Errorf("SBOM: Package download location Error at index %d! Got %s: Expected %s", i, actual.PackageDownloadLocation, expected.PackageDownloadLocation)
2499 return false
2500 }
2501
2502 if actual.PackageLicenseConcluded != expected.PackageLicenseConcluded {
2503 t.Errorf("SBOM: Package license concluded Error at index %d! Got %s: Expected %s", i, actual.PackageLicenseConcluded, expected.PackageLicenseConcluded)
2504 return false
2505 }
2506 return true
Bob Badour928ee9d2023-03-31 14:51:36 +00002507}
2508
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002509func compareRelationShips(t *testing.T, i int, actual, expected *spdx.Relationship) bool {
2510 if actual == nil || expected == nil {
2511 t.Errorf("SBOM: Relationships is nil at index %d! Got %v: Expected %v", i, actual, expected)
2512 return false
2513 }
2514
2515 if actual.RefA != expected.RefA {
2516 t.Errorf("SBOM: Relationship RefA Error at index %d! Got %s: Expected %s", i, actual.RefA, expected.RefA)
2517 return false
2518 }
2519
2520 if actual.RefB != expected.RefB {
2521 t.Errorf("SBOM: Relationship RefB Error at index %d! Got %s: Expected %s", i, actual.RefB, expected.RefB)
2522 return false
2523 }
2524
2525 if actual.Relationship != expected.Relationship {
2526 t.Errorf("SBOM: Relationship type Error at index %d! Got %s: Expected %s", i, actual.Relationship, expected.Relationship)
2527 return false
2528 }
2529 return true
Bob Badour928ee9d2023-03-31 14:51:36 +00002530}
2531
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002532func compareLicenses(t *testing.T, i int, actual, expected *spdx.OtherLicense) bool {
2533 if actual == nil || expected == nil {
2534 t.Errorf("SBOM: Licenses is nil at index %d! Got %v: Expected %v", i, actual, expected)
2535 return false
2536 }
Bob Badour928ee9d2023-03-31 14:51:36 +00002537
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002538 if actual.LicenseName != expected.LicenseName {
2539 t.Errorf("SBOM: License Name Error at index %d! Got %s: Expected %s", i, actual.LicenseName, expected.LicenseName)
2540 return false
2541 }
Bob Badour928ee9d2023-03-31 14:51:36 +00002542
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002543 if actual.LicenseIdentifier != expected.LicenseIdentifier {
2544 t.Errorf("SBOM: License Identifier Error at index %d! Got %s: Expected %s", i, actual.LicenseIdentifier, expected.LicenseIdentifier)
2545 return false
2546 }
Bob Badour928ee9d2023-03-31 14:51:36 +00002547
Ibrahim Kanouche91f2f9d2023-04-01 05:05:32 +00002548 if actual.ExtractedText != expected.ExtractedText {
2549 t.Errorf("SBOM: License Extracted Text Error at index %d! Got: %q want: %q", i, actual.ExtractedText, expected.ExtractedText)
2550 return false
2551 }
2552 return true
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002553}
2554
Ibrahim Kanouchef89fc4a2023-04-03 20:15:14 +00002555func fakeTime() string {
2556 t := time.UnixMicro(0)
2557 return t.UTC().Format("2006-01-02T15:04:05Z")
Ibrahim Kanouchebedf1a82022-10-22 01:28:05 +00002558}