-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cyclonedx schema version selection (#2123)
--------- Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
- Loading branch information
Showing
11 changed files
with
274 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cyclonedxjson | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/CycloneDX/cyclonedx-go" | ||
) | ||
|
||
func TestFormatVersions(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
expectedVersion string | ||
}{ | ||
{ | ||
|
||
"cyclonedx-json should default to v1.4", | ||
cyclonedx.SpecVersion1_4.String(), | ||
}, | ||
} | ||
|
||
for _, c := range tests { | ||
c := c | ||
t.Run(c.name, func(t *testing.T) { | ||
sbomFormat := Format() | ||
if sbomFormat.ID() != ID { | ||
t.Errorf("expected ID %q, got %q", ID, sbomFormat.ID()) | ||
} | ||
|
||
if sbomFormat.Version() != c.expectedVersion { | ||
t.Errorf("expected version %q, got %q", c.expectedVersion, sbomFormat.Version()) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package syftjson | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/anchore/syft/internal" | ||
) | ||
|
||
func TestFormat(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
version string | ||
}{ | ||
{ | ||
name: "default version should use latest internal version", | ||
version: "", | ||
}, | ||
} | ||
|
||
for _, c := range tests { | ||
c := c | ||
t.Run(c.name, func(t *testing.T) { | ||
sbomFormat := Format() | ||
if sbomFormat.ID() != ID { | ||
t.Errorf("expected ID %q, got %q", ID, sbomFormat.ID()) | ||
} | ||
|
||
if sbomFormat.Version() != internal.JSONSchemaVersion { | ||
t.Errorf("expected version %q, got %q", c.version, sbomFormat.Version()) | ||
} | ||
}) | ||
} | ||
} |