docker-archive / oscalkit

NIST OSCAL SDK and CLI
https://docker.github.io/oscalkit/
Other
36 stars 23 forks source link

Fix failing XML validation tests #65

Closed anweiss closed 5 years ago

anweiss commented 5 years ago

The following tests are failing:

--- FAIL: TestXMLValidate (0.00s)
    --- FAIL: TestXMLValidate/successful-validation (0.00s)
        validator_test.go:159: xmlValidator.Validate() error = open ../testdata/fedramp-simple-profile.xml: no such file or directory, wantErr false
    --- PASS: TestXMLValidate/failed-validation (0.00s)

Looks like we need to include some test data for validation against the upstream XSDs

Supports #10

farhankamalkhan-10p commented 5 years ago

@anweiss I have included some profiles and schema in test_util/artifacts and changed the validator test to use those. This fixed the issue mentioned above but now the test gives a new error on TestXMLValidate/successful-validation in the PR https://github.com/docker/oscalkit/pull/72. The error is as following:

time="2019-01-28T17:35:26+05:00" level=error msg="../test_util/artifacts/oscal-profile-schema.xsd:323: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element': A global element declaration '{http://csrc.nist.gov/ns/oscal/1.0}group' does already exist.\n../test_util/artifacts/oscal-profile-schema.xsd:336: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'ref': The QName value '{http://csrc.nist.gov/ns/oscal/1.0}control' does not resolve to a(n) element declaration.\n../test_util/artifacts/oscal-profile-schema.xsd:394: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'ref': The QName value '{http://csrc.nist.gov/ns/oscal/1.0}guideline' does not resolve to a(n) element declaration.\n../test_util/artifacts/oscal-profile-schema.xsd:475: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'ref': The QName value '{http://csrc.nist.gov/ns/oscal/1.0}choice' does not resolve to a(n) element declaration.\n../test_util/artifacts/oscal-profile-schema.xsd:545: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'ref': The QName value '{http://csrc.nist.gov/ns/oscal/1.0}ref' does not resolve to a(n) element declaration.\nWXS schema ../test_util/artifacts/oscal-profile-schema.xsd failed to compile\n"

Can this be because of the discrepancies in the profile schema? I am not sure how to go forward and solve this issue. Can you please look into this.

anweiss commented 5 years ago

@farhan-khan30 I'm not seeing this error. The test looked to pass in your PR.

farhankamalkhan-10p commented 5 years ago

Yep logs look clean on the PR. I was probably missing an artifact on my local machine.

anweiss commented 5 years ago

No worries. Closing.