Skip to content

Commit

Permalink
remove oscal-js
Browse files Browse the repository at this point in the history
  • Loading branch information
wandmagic committed Dec 5, 2024
1 parent 1d3a72c commit 25a4833
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
6 changes: 4 additions & 2 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ test:
configure:
npm install
wget https://repo1.maven.org/maven2/dev/metaschema/oscal/oscal-cli-enhanced/2.4.0/oscal-cli-enhanced-2.4.0-oscal-cli.zip
unzip -j oscal-cli-enhanced-2.4.0-oscal-cli.zip -d node_modules/.bin/oscal-cli-enhanced
unzip -o oscal-cli-enhanced-2.4.0-oscal-cli.zip -d node_modules/.bin/oscal-cli-enhanced
rm oscal-cli-enhanced-2.4.0-oscal-cli.zip
ln -sf $(pwd)/node_modules/.bin/oscal-cli-enhanced/bin/oscal-cli node_modules/.bin/oscal-cli
ln -sf oscal-cli-enhanced/bin/oscal-cli node_modules/.bin/oscal-cli
chmod +x node_modules/.bin/oscal-cli-enhanced/bin/oscal-cli

.PHONY: clean
clean: clean-schemas clean-linkcheck clean-converters clean-archives clean-resolved-metaschemas ## Remove all generated content

Expand Down
26 changes: 21 additions & 5 deletions build/features/step_defenitions/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Given('the following directories by type:', function(dataTable:any) {
});

Given('the OSCAL CLI tool is installed', async function() {
const success = await execSync("which oscal-cli");
const success=execSync(`npx oscal-cli --version`)

if (!success) throw new Error('OSCAL CLI not installed');
});

Expand All @@ -19,13 +20,28 @@ Given('the metaschema directory is {string}', function(dir) {
});

When('I validate {string} content in {string}',{timeout:90000}, async function(type, path) {

const metaschema = 'oscal_'+type+'_metaschema.xml' ;
const metaschema = 'oscal_'+type+'_metaschema.xml';
const metaschemaPath = `${this.metaschemaDir}/${metaschema}`;
await execSync('oscal-cli metaschema validate-content '+path+"-m "+metaschemaPath);

try {
const output = execSync(`npx oscal-cli metaschema validate-content ${path} -m ${metaschemaPath}`, {
stdio: 'pipe',
encoding: 'utf-8'
});
this.result = { isValid: true, output };
} catch (error:any) {
this.result = {
isValid: false,
error: error.message,
stderr: error.stderr?.toString(),
stdout: error.stdout?.toString()
};
}
});

Then('all validations should pass without errors', function() {
if (!this.result.isValid) {
throw new Error(`Validation failed:`);
throw new Error(`Validation failed:\n`+this.result.stderr);
}
});

0 comments on commit 25a4833

Please sign in to comment.