Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix profile resolution when children of nested controls selected #233

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,7 @@ public DefaultResult visitControl(
childResult.applyTo(control);
} else {
// remove this control and promote any needed children

if (SelectionStatus.SELECTED.equals(index.getSelectionStatus(parent))) {
retval.removeControl(control);
}
retval.removeControl(control);
retval.appendPromoted(ObjectUtils.notNull(childResult));
index.removeItem(entity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
aj-stein-nist marked this conversation as resolved.
Show resolved Hide resolved
// Catalog.class).serialize(catalog,
// System.out);

// System.out.println("Pre scrub: " + writer.getBuffer().toString());
Expand Down Expand Up @@ -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());
}
}
16 changes: 16 additions & 0 deletions src/test/resources/content/issue106-catalog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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" ?>
<catalog xmlns="http://csrc.nist.gov/ns/oscal/1.0" uuid="37b7acd4-ab3f-4217-99d1-2ab9e490db49">
<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>
<control id="c1">
<title />
<control id="c1.1">
<title />
</control>
</control>
</catalog>
15 changes: 15 additions & 0 deletions src/test/resources/content/issue106-profile.xml
Original file line number Diff line number Diff line change
@@ -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>
Loading