add bom descriptor schema + test against xml schemas in pipeline (#163)

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman
2020-08-27 19:12:45 -04:00
committed by GitHub
parent d85d0ac418
commit eda0f8c774
16 changed files with 4081 additions and 28 deletions
+10 -8
View File
@@ -5,21 +5,23 @@ package integration
import (
"bytes"
"fmt"
"github.com/anchore/go-testutils"
"github.com/anchore/syft/syft"
"github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/presenter"
"github.com/anchore/syft/syft/scope"
"github.com/xeipuuv/gojsonschema"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"testing"
"github.com/anchore/go-testutils"
"github.com/anchore/syft/syft"
"github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/presenter"
"github.com/anchore/syft/syft/scope"
"github.com/xeipuuv/gojsonschema"
)
const jsonSchemaExamplesPath = "json-schema/examples"
const jsonSchemaPath = "schema/json"
const jsonSchemaExamplesPath = jsonSchemaPath + "/examples"
func repoRoot(t *testing.T) string {
t.Helper()
@@ -35,7 +37,7 @@ func repoRoot(t *testing.T) string {
}
func validateAgainstV1Schema(t *testing.T, json string) {
fullSchemaPath := path.Join(repoRoot(t), "json-schema", "schema.json")
fullSchemaPath := path.Join(repoRoot(t), jsonSchemaPath, "schema.json")
schemaLoader := gojsonschema.NewReferenceLoader(fmt.Sprintf("file://%s", fullSchemaPath))
documentLoader := gojsonschema.NewStringLoader(json)