Skip to content

tests: run test against actual schema files, not snapshots #256

Closed
1 of 1 issue completed
Closed
@jkowalleck

Description

@jkowalleck

Current implementation of java tests run against a snapshot of the schema files, shipped with org.cyclinedx java package.
This is undesired and error-prone, as changes to the schema files in this repo are not checked against the schema example files.
Therefore, most java checks in pull requests are just bogus results without any meaning.
This must change ASAP.

Use cases:

  • a PullRequest is opened, that modifies a schema file. tests must run based on these changes, not some snapshots.
  • a PullRequest is opened, that modify some test-resources. tests must run based on these changes.

acceptance criteria

  • all test run against the actual schema files in this repo, not against any other snapshots
  • optional, but preferred: tests run offline, do not load any data from external sources
  • all currently running tests still pass

scope

targets

out of scope (since already fixed/done)

  • PHP tests -- done, uses local versions
  • JS tests -- done, uses local versions
  • ProtoBuf tests -- done, uses local versions
    • see
      function validate() {
      FILE="$1"
      SCHEMA_VERS="$2"
      SCHEMA_FILE="bom-${SCHEMA_VERS}.proto"
      MESSAGE="cyclonedx.v${SCHEMA_VERS/./_}.Bom"
      echo ">> validate $(realpath --relative-to="$PWD" "$FILE") as ${MESSAGE} of ${SCHEMA_FILE}" >&2
      # this test method is a bare minimum, and it might not detect all kinds of malformed input.
      # could be improved by utilizing protoc -- see https://github.com/CycloneDX/specification/pull/385/commits/8db0967c11cb913ac3c7a9a037159338df3f3bd9
      docker run --rm \
      --volume "${ROOT_PATH}/${SCHEMA_DIR}:/workspace/${SCHEMA_DIR}:ro" \
      --volume "${FILE}:/workspace/test_res:ro" \
      --workdir '/workspace' \
      bufbuild/buf:"$BUF_IMAGE_VERSION" \
      convert "${SCHEMA_DIR}/${SCHEMA_FILE}" \
      --type "$MESSAGE" \
      --from 'test_res#format=txtpb' \
      --to /dev/null
      }
      shopt -s globstar
      for test_res in "$ROOT_PATH"/"$TEST_RES_DIR"/*/valid-*.textproto
      do
      SCHEMA_VERS="$(basename "$(dirname "$test_res")")"
      validate "$test_res" "$SCHEMA_VERS"
      done

caused by #255
related: https://cyclonedx.slack.com/archives/G01PMU9ERJA/p1687363757137109

Sub-issues

Metadata

Metadata

Assignees

Labels

chore: QAA chore related to Quality Assurancetest-datarelated to test-resources and -data

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions