|
| 1 | +{ |
| 2 | + "valid": [ |
| 3 | + { |
| 4 | + "args": { |
| 5 | + "a": [1, 2, { "b": 3 }], |
| 6 | + "b": 1 |
| 7 | + }, |
| 8 | + "policies": [ |
| 9 | + [ |
| 10 | + ["==", ".a", [1, 2, { "b": 3 }]], |
| 11 | + ["==", ".b", 1], |
| 12 | + ["==", ".b", 1.0], |
| 13 | + ["==", ".b", 1.0] |
| 14 | + ], |
| 15 | + [ |
| 16 | + ["!=", ".b", "ddd"], |
| 17 | + ["!=", ".b", null], |
| 18 | + ["!=", ".b", 2], |
| 19 | + ["!=", ".b", { "b": 3 }], |
| 20 | + ["!=", ".b", true], |
| 21 | + ["!=", ".b", false], |
| 22 | + ["not", ["==", ".b", 2]] |
| 23 | + ], |
| 24 | + [["<", ".b", 2], ["<", ".b", 2.0]], |
| 25 | + [[">", ".b", 0], [">", ".b", 0.0]], |
| 26 | + [["<=", ".b", 2], ["<=", ".b", 2.0]], |
| 27 | + [[">=", ".b", 0], [">=", ".b", 0.0]] |
| 28 | + ] |
| 29 | + }, |
| 30 | + { |
| 31 | + "args": { |
| 32 | + "a": "Alice*, Bob, Carol.", |
| 33 | + "b": "Alice*, Bob, Dan, Erin, Carol.", |
| 34 | + "c": "Alice*, Bob , Carol.", |
| 35 | + "d": "Alice*, Bob*, Carol." |
| 36 | + }, |
| 37 | + "policies": [ |
| 38 | + [ |
| 39 | + ["like", ".a", "Alice\\*, Bob*, Carol."], |
| 40 | + ["like", ".b", "Alice\\*, Bob*, Carol."], |
| 41 | + ["like", ".c", "Alice\\*, Bob*, Carol."], |
| 42 | + ["like", ".d", "Alice\\*, Bob*, Carol."] |
| 43 | + ] |
| 44 | + ] |
| 45 | + }, |
| 46 | + { |
| 47 | + "args": { |
| 48 | + "name": "Katie", |
| 49 | + "age": 35, |
| 50 | + "nationalities": ["Canadian", "South African"] |
| 51 | + }, |
| 52 | + "policies": [ |
| 53 | + [["and", []]], |
| 54 | + [["and", [["==", ".name", "Katie"]]]], |
| 55 | + [[["and", [["==", ".name", "Katie"], ["==", ".age", 35]]]]], |
| 56 | + [ |
| 57 | + "and", |
| 58 | + [ |
| 59 | + ["==", ".name", "Katie"], |
| 60 | + ["==", ".age", 35], |
| 61 | + ["==", ".nationalities", ["Canadian", "South African"]] |
| 62 | + ] |
| 63 | + ], |
| 64 | + [["or", []]], |
| 65 | + [["or", [["==", ".name", "Katie"], [">", ".age", 45]]]], |
| 66 | + [ |
| 67 | + [ |
| 68 | + "not", |
| 69 | + [ |
| 70 | + "and", |
| 71 | + [["==", ".name", "Katie"], ["==", ".nationalities", ["American"]]] |
| 72 | + ] |
| 73 | + ] |
| 74 | + ] |
| 75 | + ] |
| 76 | + }, |
| 77 | + { |
| 78 | + "args": { "a": [{ "b": 1 }, { "b": 2 }, { "z": [7, 8, 9] }] }, |
| 79 | + "policies": [[["any", ".a", ["==", ".b", 2]]]] |
| 80 | + }, |
| 81 | + { |
| 82 | + "args": { |
| 83 | + "newsletters": { |
| 84 | + "recipients": [ |
| 85 | + { "email": "bob@example.com" }, |
| 86 | + { "email": "alice@example.com" } |
| 87 | + ] |
| 88 | + } |
| 89 | + }, |
| 90 | + "policies": [ |
| 91 | + [ |
| 92 | + [ |
| 93 | + "all", |
| 94 | + ".newsletters", |
| 95 | + ["any", ".recipients", ["==", ".email", "bob@example.com"]] |
| 96 | + ] |
| 97 | + ] |
| 98 | + ] |
| 99 | + }, |
| 100 | + { |
| 101 | + "args": { |
| 102 | + "from": "alice@example.com", |
| 103 | + "to": ["bob@example.com", "carol@not.example.com"], |
| 104 | + "title": "Coffee", |
| 105 | + "body": "Still on for coffee" |
| 106 | + }, |
| 107 | + "policies": [ |
| 108 | + [ |
| 109 | + ["==", ".from", "alice@example.com"], |
| 110 | + ["any", ".to", ["like", ".", "*@example.com"]] |
| 111 | + ] |
| 112 | + ] |
| 113 | + } |
| 114 | + ], |
| 115 | + "invalid": [ |
| 116 | + { |
| 117 | + "args": { |
| 118 | + "fail1": "Alice*, Bob, Carol", |
| 119 | + "fail2": "Alice*, Bob*, Carol!", |
| 120 | + "fail3": "Alice, Bob, Carol.", |
| 121 | + "fail4": "Alice Cooper, Bob, Carol.", |
| 122 | + "fail5": " Alice*, Bob, Carol. " |
| 123 | + }, |
| 124 | + "policies": [ |
| 125 | + [["like", ".fail1", "Alice\\*, Bob*, Carol."]], |
| 126 | + [["like", ".fail2", "Alice\\*, Bob*, Carol."]], |
| 127 | + [["like", ".fail3", "Alice\\*, Bob*, Carol."]], |
| 128 | + [["like", ".fail4", "Alice\\*, Bob*, Carol."]], |
| 129 | + [["like", ".fail5", "Alice\\*, Bob*, Carol."]] |
| 130 | + ] |
| 131 | + }, |
| 132 | + { |
| 133 | + "args": { |
| 134 | + "name": "Katie", |
| 135 | + "age": 35, |
| 136 | + "nationalities": ["Canadian", "South African"] |
| 137 | + }, |
| 138 | + "policies": [ |
| 139 | + [ |
| 140 | + [ |
| 141 | + "and", |
| 142 | + [ |
| 143 | + ["==", ".name", "Katie"], |
| 144 | + ["==", ".age", 35], |
| 145 | + ["==", ".nationalities", "american"] |
| 146 | + ] |
| 147 | + ] |
| 148 | + ] |
| 149 | + ] |
| 150 | + }, |
| 151 | + { |
| 152 | + "args": { "a": [{ "b": 1 }, { "b": 2 }, { "z": [7, 8, 9] }] }, |
| 153 | + "policies": [[["all", ".a", [">", ".b", 0]]]] |
| 154 | + }, |
| 155 | + { |
| 156 | + "args": { |
| 157 | + "from": "alice@example.com", |
| 158 | + "to": ["carol@elsewhere.example.com"], |
| 159 | + "title": "Coffee", |
| 160 | + "body": "Still on for coffee" |
| 161 | + }, |
| 162 | + "policies": [ |
| 163 | + [ |
| 164 | + ["==", ".from", "alice@example.com"], |
| 165 | + ["any", ".to", ["like", ".", "*@example.com"]] |
| 166 | + ] |
| 167 | + ] |
| 168 | + } |
| 169 | + ] |
| 170 | +} |
0 commit comments