-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from accordproject/disableJavaScriptEvaluation
feat: disableJavaScriptEvaluation
- Loading branch information
Showing
8 changed files
with
484 additions
and
828 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,4 @@ rules: | |
- error | ||
- requireReturn: false | ||
yoda: error | ||
'@typescript-eslint/no-explicit-any': 0 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ModelManager } from '@accordproject/concerto-core'; | ||
import { readFileSync } from 'fs'; | ||
import { TemplateMarkInterpreter } from '../src'; | ||
import { TemplateMarkTransformer } from '@accordproject/markdown-template'; | ||
|
||
describe('template generation options', () => { | ||
test('should fail to evaluate a formula with disableJavaScriptEvaluation set to true', async () => { | ||
const f = async () => { | ||
const model = readFileSync('./test/templates/good/helloformula/model.cto', 'utf-8'); | ||
const template = readFileSync('./test/templates/good/helloformula/template.md', 'utf-8'); | ||
const data = JSON.parse(readFileSync('./test/templates/good/helloformula/data.json', 'utf-8')); | ||
const modelManager = new ModelManager({ strict: true }); | ||
modelManager.addCTOModel(model); | ||
const engine = new TemplateMarkInterpreter(modelManager, {}); | ||
const templateMarkTransformer = new TemplateMarkTransformer(); | ||
const templateMarkDom = templateMarkTransformer.fromMarkdownTemplate({ content: template }, modelManager, 'contract', { verbose: false }); | ||
const now = '2023-03-17T00:00:00.000Z'; | ||
return engine.generate(templateMarkDom, data, {now, disableJavaScriptEvaluation: true}); | ||
}; | ||
await expect(f()).rejects.toThrow('JavaScript evaluation is disabled.'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters