3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-23 17:45:03 +00:00

Disallow anchors/aliases to objects when loading config YAML

This commit is contained in:
Dragory 2021-08-14 18:22:29 +03:00
parent 72a90ce66a
commit 1e50e459f3
5 changed files with 96 additions and 3 deletions

View file

@ -0,0 +1,43 @@
import test from "ava";
import { ObjectAliasError, validateNoObjectAliases } from "./validateNoObjectAliases";
test("validateNoObjectAliases() disallows object aliases at top level", t => {
const obj: any = {
objectRef: {
foo: "bar",
},
};
obj.otherProp = obj.objectRef;
t.throws(() => validateNoObjectAliases(obj), { instanceOf: ObjectAliasError });
});
test("validateNoObjectAliases() disallows aliases to nested objects", t => {
const obj: any = {
nested: {
objectRef: {
foo: "bar",
},
},
};
obj.otherProp = obj.nested.objectRef;
t.throws(() => validateNoObjectAliases(obj), { instanceOf: ObjectAliasError });
});
test("validateNoObjectAliases() disallows nested object aliases", t => {
const obj: any = {
nested: {
objectRef: {
foo: "bar",
},
},
};
obj.otherProp = {
alsoNested: {
ref: obj.nested.objectRef,
},
};
t.throws(() => validateNoObjectAliases(obj), { instanceOf: ObjectAliasError });
});