diff --git a/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts b/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts index 2b33ec53..5d0b997a 100644 --- a/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts +++ b/test/functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec.ts @@ -13,7 +13,7 @@ describe('ConsoleOutputDisableExpressionNode', () => { } ); - assert.match(obfuscationResult.getObfuscatedCode(), /_\u0003\.log\u0001\.in/); + assert.match(obfuscationResult.getObfuscatedCode(), /for *\(_0x([a-z0-9]){5,6} in _0x([a-z0-9]){5,6} *= *_0x([a-z0-9]){4}\('0xc'\)\)/); }); it('should\'t append `ConsoleOutputDisableExpressionNode` custom node into the obfuscated code if `disableConsoleOutput` option is not set', () => { @@ -24,6 +24,6 @@ describe('ConsoleOutputDisableExpressionNode', () => { } ); - assert.notMatch(obfuscationResult.getObfuscatedCode(), /_\u0003\.log\u0001\.in/); + assert.notMatch(obfuscationResult.getObfuscatedCode(), /for *\(_0x([a-z0-9]){5,6} in _0x([a-z0-9]){5,6} *= *_0x([a-z0-9]){4}\('0xc'\)\)/); }); }); diff --git a/test/functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec.ts b/test/functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec.ts new file mode 100644 index 00000000..9a272eb2 --- /dev/null +++ b/test/functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec.ts @@ -0,0 +1,29 @@ +import { IObfuscationResult } from "../../../../src/interfaces/IObfuscationResult"; + +import { JavaScriptObfuscator } from "../../../../src/JavaScriptObfuscator"; + +const assert: Chai.AssertStatic = require('chai').assert; + +describe('DomainLockNode', () => { + it('should correctly append `DomainLockNode` custom node into the obfuscated code if `domainLock` option is set', () => { + let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( + `var test = 'test';`, + { + domainLock: ['.example.com'] + } + ); + + assert.match(obfuscationResult.getObfuscatedCode(), /var _0x([a-z0-9]){5,6} *= *new RegExp/); + }); + + it('should\'t append `DomainLockNode` custom node into the obfuscated code if `domainLock` option is not set', () => { + let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate( + `var test = 'test';`, + { + domainLock: [] + } + ); + + assert.notMatch(obfuscationResult.getObfuscatedCode(), /var _0x([a-z0-9]){5,6} *= *new RegExp/); + }); +}); diff --git a/test/index.spec.ts b/test/index.spec.ts index f93348ac..4bf2d57a 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -24,6 +24,7 @@ import './functional-tests/JavaScriptObfuscator.spec'; import './functional-tests/JavaScriptObfuscatorCLI.spec'; import './functional-tests/JavaScriptObfuscatorInternal.spec'; import './functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec'; +import './functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec'; import './functional-tests/custom-nodes/unicode-array-nodes/UnicodeArrayCallsWrapper.spec'; import './functional-tests/custom-nodes/unicode-array-nodes/UnicodeArrayDecodeNode.spec'; import './functional-tests/custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode.spec';