Skip to content

Commit 9cf5468

Browse files
committed
Add more @protected tests.
- Simplify text in older tests. - Support 'protectedMode' option of 'error' or 'warn'. - Test both 'protectedMode' types where needed. - Using 'e' or 'w' suffix for test id but same input file. - Add more tests of various situations.
1 parent 51736a0 commit 9cf5468

34 files changed

+557
-97
lines changed

tests/expand-manifest.jsonld

Lines changed: 173 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,13 +1874,21 @@
18741874
"input": "expand/li10-in.jsonld",
18751875
"expect": "expand/li10-out.jsonld"
18761876
}, {
1877-
"@id": "#tpr01",
1877+
"@id": "#tpr01e",
18781878
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1879-
"name": "Protect a term",
1880-
"purpose": "Protected Contexts",
1879+
"name": "Protected a term (error mode)",
1880+
"purpose": "Check 'error' mode when overriding a protected term. (error mode)",
18811881
"option": {"specVersion": "json-ld-1.1"},
18821882
"input": "expand/pr01-in.jsonld",
18831883
"expect": "protected term redefinition"
1884+
}, {
1885+
"@id": "#tpr01w",
1886+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1887+
"name": "Protected a term (warn mode)",
1888+
"purpose": "Check 'warn' mode when overriding a protected term. (warn mode)",
1889+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
1890+
"input": "expand/pr01-in.jsonld",
1891+
"expect": "expand/pr01-out.jsonld"
18841892
}, {
18851893
"@id": "#tpr02",
18861894
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
@@ -1890,29 +1898,53 @@
18901898
"input": "expand/pr02-in.jsonld",
18911899
"expect": "expand/pr02-out.jsonld"
18921900
}, {
1893-
"@id": "#tpr03",
1901+
"@id": "#tpr03e",
18941902
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1895-
"name": "Protect all terms in context",
1896-
"purpose": "A protected context protects all term definitions.",
1903+
"name": "Protect all terms in context (error mode)",
1904+
"purpose": "A protected context protects all term definitions. (error mode)",
18971905
"option": {"specVersion": "json-ld-1.1"},
18981906
"input": "expand/pr03-in.jsonld",
18991907
"expect": "protected term redefinition"
19001908
}, {
1901-
"@id": "#tpr04",
1909+
"@id": "#tpr03w",
1910+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1911+
"name": "Protect all terms in context (warn mode)",
1912+
"purpose": "A protected context protects all term definitions. (warn mode)",
1913+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
1914+
"input": "expand/pr03-in.jsonld",
1915+
"expect": "expand/pr03-out.jsonld"
1916+
}, {
1917+
"@id": "#tpr04e",
19021918
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1903-
"name": "Do not protect term with @protected: false",
1904-
"purpose": "A protected context does not protect terms with @protected: false.",
1919+
"name": "Do not protect term with @protected: false (error mode)",
1920+
"purpose": "A protected context does not protect terms with @protected: false. (error mode)",
19051921
"option": {"specVersion": "json-ld-1.1"},
19061922
"input": "expand/pr04-in.jsonld",
19071923
"expect": "protected term redefinition"
19081924
}, {
1909-
"@id": "#tpr05",
1925+
"@id": "#tpr04w",
1926+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1927+
"name": "Do not protect term with @protected: false (warn mode)",
1928+
"purpose": "A protected context does not protect terms with @protected: false. (warn mode)",
1929+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
1930+
"input": "expand/pr04-in.jsonld",
1931+
"expect": "expand/pr04-out.jsonld"
1932+
}, {
1933+
"@id": "#tpr05e",
19101934
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1911-
"name": "Clear active context with protected terms from an embedded context",
1912-
"purpose": "The Active context be set to null from an embedded context.",
1935+
"name": "Clear active context with protected terms from an embedded context (error mode)",
1936+
"purpose": "The Active context be set to null from an embedded context. (error mode)",
19131937
"option": {"specVersion": "json-ld-1.1"},
19141938
"input": "expand/pr05-in.jsonld",
19151939
"expect": "invalid context nullification"
1940+
}, {
1941+
"@id": "#tpr05w",
1942+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1943+
"name": "Clear active context with protected terms from an embedded context (warn mode)",
1944+
"purpose": "The Active context be set to null from an embedded context. (warn mode)",
1945+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
1946+
"input": "expand/pr05-in.jsonld",
1947+
"expect": "expand/pr05-out.jsonld"
19161948
}, {
19171949
"@id": "#tpr06",
19181950
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
@@ -1922,77 +1954,181 @@
19221954
"input": "expand/pr06-in.jsonld",
19231955
"expect": "expand/pr06-out.jsonld"
19241956
}, {
1925-
"@id": "#tpr08",
1957+
"@id": "#tpr08e",
19261958
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1927-
"name": "Term with protected scoped context.",
1928-
"purpose": "A scoped context can protect terms.",
1959+
"name": "Term with protected scoped context. (error mode)",
1960+
"purpose": "A scoped context can protect terms. (error mode)",
19291961
"option": {"specVersion": "json-ld-1.1"},
19301962
"input": "expand/pr08-in.jsonld",
19311963
"expect": "protected term redefinition"
19321964
}, {
1933-
"@id": "#tpr09",
1965+
"@id": "#tpr08w",
1966+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1967+
"name": "Term with protected scoped context. (warn mode)",
1968+
"purpose": "A scoped context can protect terms. (warn mode)",
1969+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
1970+
"input": "expand/pr08-in.jsonld",
1971+
"expect": "expand/pr08-out.jsonld"
1972+
}, {
1973+
"@id": "#tpr09e",
19341974
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1935-
"name": "Attempt to redefine term in other protected context.",
1936-
"purpose": "A protected term cannot redefine another protected term.",
1975+
"name": "Attempt to redefine term in other protected context. (error mode)",
1976+
"purpose": "A protected term cannot redefine another protected term. (error mode)",
19371977
"option": {"specVersion": "json-ld-1.1"},
19381978
"input": "expand/pr09-in.jsonld",
19391979
"expect": "protected term redefinition"
1980+
}, {
1981+
"@id": "#tpr09w",
1982+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1983+
"name": "Attempt to redefine term in other protected context. (warn mode)",
1984+
"purpose": "A protected term cannot redefine another protected term. (warn mode)",
1985+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
1986+
"input": "expand/pr09-in.jsonld",
1987+
"expect": "expand/pr09-out.jsonld"
19401988
}, {
19411989
"@id": "#tpr10",
19421990
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1943-
"name": "",
1944-
"purpose": "",
1991+
"name": "Simple protected and unprotected terms.",
1992+
"purpose": "Simple protected and unprotected terms.",
19451993
"option": {"specVersion": "json-ld-1.1"},
19461994
"input": "expand/pr10-in.jsonld",
19471995
"expect": "expand/pr10-out.jsonld"
19481996
}, {
1949-
"@id": "#tpr11",
1997+
"@id": "#tpr11e",
19501998
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1951-
"name": "",
1952-
"purpose": "",
1999+
"name": "Fail to override protected term. (error mode)",
2000+
"purpose": "Fail to override protected term. (error mode)",
19532001
"option": {"specVersion": "json-ld-1.1"},
19542002
"input": "expand/pr11-in.jsonld",
19552003
"expect": "protected term redefinition"
19562004
}, {
1957-
"@id": "#tpr12",
2005+
"@id": "#tpr11w",
2006+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2007+
"name": "Fail to override protected term. (warn mode)",
2008+
"purpose": "Fail to override protected term. (warn mode)",
2009+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
2010+
"input": "expand/pr11-in.jsonld",
2011+
"expect": "expand/pr11-out.jsonld"
2012+
}, {
2013+
"@id": "#tpr12e",
19582014
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1959-
"name": "",
1960-
"purpose": "",
2015+
"name": "Scoped context fail to override protected term. (error mode)",
2016+
"purpose": "Scoped context fail to override protected term. (error mode)",
19612017
"option": {"specVersion": "json-ld-1.1"},
19622018
"input": "expand/pr12-in.jsonld",
19632019
"expect": "protected term redefinition"
2020+
}, {
2021+
"@id": "#tpr12w",
2022+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2023+
"name": "Scoped context fail to override protected term. (warn mode)",
2024+
"purpose": "Scoped context fail to override protected term. (warn mode)",
2025+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
2026+
"input": "expand/pr12-in.jsonld",
2027+
"expect": "expand/pr12-out.jsonld"
19642028
}, {
19652029
"@id": "#tpr13",
19662030
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1967-
"name": "",
1968-
"purpose": "",
2031+
"name": "Override unprotected term.",
2032+
"purpose": "Override unprotected term.",
19692033
"option": {"specVersion": "json-ld-1.1"},
19702034
"input": "expand/pr13-in.jsonld",
19712035
"expect": "expand/pr13-out.jsonld"
19722036
}, {
19732037
"@id": "#tpr14",
19742038
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1975-
"name": "",
1976-
"purpose": "",
2039+
"name": "Clear protection with null context.",
2040+
"purpose": "Clear protection with null context.",
19772041
"option": {"specVersion": "json-ld-1.1"},
19782042
"input": "expand/pr14-in.jsonld",
19792043
"expect": "expand/pr14-out.jsonld"
19802044
}, {
19812045
"@id": "#tpr15",
1982-
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1983-
"name": "",
1984-
"purpose": "",
2046+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2047+
"name": "Clear protection with array with null context",
2048+
"purpose": "Clear protection with array with null context",
19852049
"option": {"specVersion": "json-ld-1.1"},
19862050
"input": "expand/pr15-in.jsonld",
1987-
"expect": "invalid context nullification"
2051+
"expect": "expand/pr15-out.jsonld"
19882052
}, {
19892053
"@id": "#tpr16",
1990-
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1991-
"name": "",
1992-
"purpose": "",
2054+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2055+
"name": "Override protected terms after null.",
2056+
"purpose": "Override protected terms after null.",
19932057
"option": {"specVersion": "json-ld-1.1"},
19942058
"input": "expand/pr16-in.jsonld",
2059+
"expect": "expand/pr16-out.jsonld"
2060+
}, {
2061+
"@id": "#tpr17e",
2062+
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
2063+
"name": "Fail to override protected terms with type. (error mode)",
2064+
"purpose": "Fail to override protected terms with type. (error mode)",
2065+
"option": {"specVersion": "json-ld-1.1"},
2066+
"input": "expand/pr17-in.jsonld",
2067+
"expect": "invalid context nullification"
2068+
}, {
2069+
"@id": "#tpr17w",
2070+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2071+
"name": "Fail to override protected terms with type. (warn mode)",
2072+
"purpose": "Fail to override protected terms with type. (warn mode)",
2073+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
2074+
"input": "expand/pr17-in.jsonld",
2075+
"expect": "expand/pr17-out.jsonld"
2076+
}, {
2077+
"@id": "#tpr18e",
2078+
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
2079+
"name": "Fail to override protected terms with type+null+ctx. (error mode)",
2080+
"purpose": "Fail to override protected terms with type+null+ctx. (error mode)",
2081+
"option": {"specVersion": "json-ld-1.1"},
2082+
"input": "expand/pr18-in.jsonld",
19952083
"expect": "invalid context nullification"
2084+
}, {
2085+
"@id": "#tpr18w",
2086+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2087+
"name": "Fail to override protected terms with type+null+ctx. (warn mode)",
2088+
"purpose": "Fail to override protected terms with type+null+ctx. (warn mode)",
2089+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
2090+
"input": "expand/pr18-in.jsonld",
2091+
"expect": "expand/pr18-out.jsonld"
2092+
}, {
2093+
"@id": "#tpr19",
2094+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2095+
"name": "Mix of protected and unprotected terms.",
2096+
"purpose": "Mix of protected and unprotected terms.",
2097+
"option": {"specVersion": "json-ld-1.1"},
2098+
"input": "expand/pr19-in.jsonld",
2099+
"expect": "expand/pr19-out.jsonld"
2100+
}, {
2101+
"@id": "#tpr20e",
2102+
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
2103+
"name": "Fail with mix of protected and unprotected terms with type+null+ctx. (error mode)",
2104+
"purpose": "Fail with mix of protected and unprotected terms with type+null+ctx. (error mode)",
2105+
"option": {"specVersion": "json-ld-1.1"},
2106+
"input": "expand/pr20-in.jsonld",
2107+
"expect": "invalid context nullification"
2108+
}, {
2109+
"@id": "#tpr20w",
2110+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2111+
"name": "Fail with mix of protected and unprotected terms with type+null+ctx. (warn mode)",
2112+
"purpose": "Fail with mix of protected and unprotected terms with type+null+ctx. (warn mode)",
2113+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
2114+
"input": "expand/pr20-in.jsonld",
2115+
"expect": "expand/pr20-out.jsonld"
2116+
}, {
2117+
"@id": "#tpr21e",
2118+
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
2119+
"name": "Fail with mix of protected and unprotected terms with type+null. (error mode)",
2120+
"purpose": "Fail with mix of protected and unprotected terms with type+null. (error mode)",
2121+
"option": {"specVersion": "json-ld-1.1"},
2122+
"input": "expand/pr21-in.jsonld",
2123+
"expect": "invalid context nullification"
2124+
}, {
2125+
"@id": "#tpr21w",
2126+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2127+
"name": "Fail with mix of protected and unprotected terms with type+null. (warn mode)",
2128+
"purpose": "Fail with mix of protected and unprotected terms with type+null. (warn mode)",
2129+
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
2130+
"input": "expand/pr21-in.jsonld",
2131+
"expect": "expand/pr21-out.jsonld"
19962132
}, {
19972133
"@id": "#ttn01",
19982134
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],

tests/expand/pr01-in.jsonld

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
"@context": {
33
"@vocab": "http://example.com/",
44
"@version": 1.1,
5-
"protected": {"@protected": true}
5+
"protected": {
6+
"@protected": true
7+
}
68
},
79
"protected": {
8-
"@context": {"protected": "http://example.com/something-else"},
9-
"protected": "this should have the property http://example.com/protected"
10+
"@context": {
11+
"protected": "http://example.com/something-else"
12+
},
13+
"protected": "error / property http://example.com/protected"
1014
}
1115
}

tests/expand/pr01-out.jsonld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"http://example.com/protected": [{
4-
"http://example.com/protected": [{"@value": "this should have the property http://example.com/protected"}]
4+
"http://example.com/protected": [{"@value": "error / property http://example.com/protected"}]
55
}]
66
}
77
]

tests/expand/pr02-in.jsonld

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
"@context": {
33
"@vocab": "http://example.com/",
44
"@version": 1.1,
5-
"protected": {"@protected": true},
6-
"unprotected": {"@protected": false}
5+
"protected": {
6+
"@protected": true
7+
},
8+
"unprotected": {
9+
"@protected": false
10+
}
711
},
812
"protected": true,
913
"unprotected": true,
1014
"scope": {
11-
"@context": {"unprotected": "http://example.com/something-else"},
12-
"unprotected": "this should have the property http://example.com/something-else"
15+
"@context": {
16+
"unprotected": "http://example.com/something-else"
17+
},
18+
"unprotected": "property http://example.com/something-else"
1319
}
1420
}

tests/expand/pr02-out.jsonld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"http://example.com/protected": [{"@value": true}],
44
"http://example.com/unprotected": [{"@value": true}],
55
"http://example.com/scope": [{
6-
"http://example.com/something-else": [{"@value": "this should have the property http://example.com/something-else"}]
6+
"http://example.com/something-else": [{"@value": "property http://example.com/something-else"}]
77
}]
88
}
99
]

tests/expand/pr03-in.jsonld

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
"@vocab": "http://example.com/",
44
"@version": 1.1,
55
"@protected": true,
6-
"protected1": {"@id": "http://example.com/protected1"},
7-
"protected2": {"@id": "http://example.com/protected2"}
6+
"protected1": {
7+
"@id": "http://example.com/protected1"
8+
},
9+
"protected2": {
10+
"@id": "http://example.com/protected2"
11+
}
812
},
913
"protected1": {
1014
"@context": {
1115
"protected1": "http://example.com/something-else",
1216
"protected2": "http://example.com/something-else"
1317
},
14-
"protected1": "this should have the property http://example.com/protected1",
15-
"protected2": "this should have the property http://example.com/protected2"
18+
"protected1": "error / property http://example.com/protected1",
19+
"protected2": "error / property http://example.com/protected2"
1620
}
1721
}

tests/expand/pr03-out.jsonld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[
22
{
33
"http://example.com/protected1": [{
4-
"http://example.com/protected1": [{"@value": "this should have the property http://example.com/protected1"}],
5-
"http://example.com/protected2": [{"@value": "this should have the property http://example.com/protected2"}]
4+
"http://example.com/protected1": [{"@value": "error / property http://example.com/protected1"}],
5+
"http://example.com/protected2": [{"@value": "error / property http://example.com/protected2"}]
66
}]
77
}
88
]

0 commit comments

Comments
 (0)