From fd95852594c10ccf1d19ca1690ace46cfc72abe2 Mon Sep 17 00:00:00 2001 From: "A.J. Stein" Date: Wed, 31 Jan 2024 17:35:59 -0500 Subject: [PATCH] Regression test for usnistgov/liboscal-java#232 --- .../profile/resolver/ProfileResolutionTests.java | 12 +++++++++++- src/test/resources/content/issue106-catalog.xml | 16 ++++++++++++++++ src/test/resources/content/issue106-profile.xml | 15 +++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/content/issue106-catalog.xml create mode 100644 src/test/resources/content/issue106-profile.xml diff --git a/src/test/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolutionTests.java b/src/test/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolutionTests.java index 38c602be..2c7e18a7 100644 --- a/src/test/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolutionTests.java +++ b/src/test/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolutionTests.java @@ -182,7 +182,8 @@ void performTest(String profileName) throws IOException, SaxonApiException { StringWriter writer = new StringWriter(); serializer.serialize(catalog, writer); - // OscalBindingContext.instance().newSerializer(Format.YAML, Catalog.class).serialize(catalog, + // OscalBindingContext.instance().newSerializer(Format.YAML, + // Catalog.class).serialize(catalog, // System.out); // System.out.println("Pre scrub: " + writer.getBuffer().toString()); @@ -256,4 +257,13 @@ void testArsModerateProfile() throws IOException, ProfileResolutionException, UR assertNotNull(resolvedCatalog); } + + @Test + void testIssue106Profile() throws IOException, ProfileResolutionException, URISyntaxException { + Path profileFile = Paths.get(JUNIT_TEST_PATH, "content/issue106-profile.xml"); + assert profileFile != null; + Catalog catalog = resolveProfile(profileFile); + assertNotNull(catalog); + assertEquals("1.1.1", catalog.getMetadata().getOscalVersion()); + } } diff --git a/src/test/resources/content/issue106-catalog.xml b/src/test/resources/content/issue106-catalog.xml new file mode 100644 index 00000000..d32a2006 --- /dev/null +++ b/src/test/resources/content/issue106-catalog.xml @@ -0,0 +1,16 @@ + + + + + + <last-modified>2023-02-18T13:06:18Z</last-modified> + <version>2023-02-18T13:06:18Z</version> + <oscal-version>1.1.1</oscal-version> + </metadata> + <control id="c1"> + <title /> + <control id="c1.1"> + <title /> + </control> + </control> +</catalog> \ No newline at end of file diff --git a/src/test/resources/content/issue106-profile.xml b/src/test/resources/content/issue106-profile.xml new file mode 100644 index 00000000..1874029d --- /dev/null +++ b/src/test/resources/content/issue106-profile.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="https://github.com/usnistgov/OSCAL/releases/download/v1.1.1/oscal_complete_schema.xsd" schematypens="http://www.w3.org/2001/XMLSchema" title="OSCAL complete schema" ?> +<profile xmlns="http://csrc.nist.gov/ns/oscal/1.0" uuid="3353e8e1-3eef-42ef-8163-1f71616bafca"> + <metadata> + <title /> + <last-modified>2023-02-18T13:06:18Z</last-modified> + <version>2023-02-18T13:06:18Z</version> + <oscal-version>1.1.1</oscal-version> + </metadata> + <import href="issue106-catalog.xml"> + <include-controls> + <with-id>c1.1</with-id> + </include-controls> + </import> +</profile> \ No newline at end of file