76 lines
2.1 KiB
JavaScript
76 lines
2.1 KiB
JavaScript
/**
|
|
* Regular Expression tests.
|
|
*
|
|
* @author C85297 [95289555+C85297@users.noreply.github.com]
|
|
* @copyright Crown Copyright 2017
|
|
* @license Apache-2.0
|
|
*/
|
|
import TestRegister from "../../lib/TestRegister.mjs";
|
|
import { EMAIL_REGEX } from "../../../src/core/lib/Extract.mjs";
|
|
|
|
TestRegister.addTests([
|
|
{
|
|
name: "Regular Expression - built in email regex - IP address",
|
|
input: "yaunwfkb\nexample@[127.0.0.1]\n091nvka",
|
|
expectedOutput: "example@[127.0.0.1]",
|
|
recipeConfig: [
|
|
{
|
|
op: "Regular expression",
|
|
args: [
|
|
"Email address",
|
|
EMAIL_REGEX.source,
|
|
true,
|
|
true,
|
|
false,
|
|
false,
|
|
false,
|
|
false,
|
|
"List matches",
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: "Regular Expression - built in email regex - invalid IP address",
|
|
input: "yaunwfkb\nfalse_positive@[1.2.3.]\n091nvka",
|
|
expectedOutput: "",
|
|
recipeConfig: [
|
|
{
|
|
op: "Regular expression",
|
|
args: [
|
|
"Email address",
|
|
EMAIL_REGEX.source,
|
|
true,
|
|
true,
|
|
false,
|
|
false,
|
|
false,
|
|
false,
|
|
"List matches",
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: "Regular Expression - built in email regex - IPv4 from #2318",
|
|
input: "user@[1.2.3.4]\ntest@[192.168.0.1]\nno-match@[1.2.3.]",
|
|
expectedOutput: "user@[1.2.3.4]\ntest@[192.168.0.1]",
|
|
recipeConfig: [
|
|
{
|
|
op: "Regular expression",
|
|
args: [
|
|
"Email address",
|
|
EMAIL_REGEX.source,
|
|
true,
|
|
true,
|
|
false,
|
|
false,
|
|
false,
|
|
false,
|
|
"List matches",
|
|
],
|
|
},
|
|
],
|
|
},
|
|
]);
|