Skip to content

Add @protected tests and a protectedMode flag. #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 216 additions & 24 deletions tests/expand-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -1874,12 +1874,20 @@
"input": "expand/li10-in.jsonld",
"expect": "expand/li10-out.jsonld"
}, {
"@id": "#tpr01",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Protect a term",
"purpose": "Protected Contexts",
"@id": "#tpr01e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Protected a term (error mode)",
"purpose": "Check 'error' mode when overriding a protected term. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr01-in.jsonld",
"expect": "protected term redefinition"
}, {
"@id": "#tpr01w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Protected a term (warn mode)",
"purpose": "Check 'warn' mode when overriding a protected term. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr01-in.jsonld",
"expect": "expand/pr01-out.jsonld"
}, {
"@id": "#tpr02",
Expand All @@ -1890,28 +1898,52 @@
"input": "expand/pr02-in.jsonld",
"expect": "expand/pr02-out.jsonld"
}, {
"@id": "#tpr03",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Protect all terms in context",
"purpose": "A protected context protects all term definitions.",
"@id": "#tpr03e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Protect all terms in context (error mode)",
"purpose": "A protected context protects all term definitions. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr03-in.jsonld",
"expect": "expand/pr03-out.jsonld"
"expect": "protected term redefinition"
}, {
"@id": "#tpr04",
"@id": "#tpr03w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Do not protect term with @protected: false",
"purpose": "A protected context does not protect terms with @protected: false.",
"name": "Protect all terms in context (warn mode)",
"purpose": "A protected context protects all term definitions. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr03-in.jsonld",
"expect": "expand/pr03-out.jsonld"
}, {
"@id": "#tpr04e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Do not protect term with @protected: false (error mode)",
"purpose": "A protected context does not protect terms with @protected: false. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr04-in.jsonld",
"expect": "expand/pr04-out.jsonld"
"expect": "protected term redefinition"
}, {
"@id": "#tpr05",
"@id": "#tpr04w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Clear active context with protected terms from an embedded context",
"purpose": "The Active context be set to null from an embedded context.",
"name": "Do not protect term with @protected: false (warn mode)",
"purpose": "A protected context does not protect terms with @protected: false. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr04-in.jsonld",
"expect": "expand/pr04-out.jsonld"
}, {
"@id": "#tpr05e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Clear active context with protected terms from an embedded context (error mode)",
"purpose": "The Active context be set to null from an embedded context. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr05-in.jsonld",
"expect": "invalid context nullification"
}, {
"@id": "#tpr05w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Clear active context with protected terms from an embedded context (warn mode)",
"purpose": "The Active context be set to null from an embedded context. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr05-in.jsonld",
"expect": "expand/pr05-out.jsonld"
}, {
"@id": "#tpr06",
Expand All @@ -1922,21 +1954,181 @@
"input": "expand/pr06-in.jsonld",
"expect": "expand/pr06-out.jsonld"
}, {
"@id": "#tpr08",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Term with protected scoped context.",
"purpose": "A scoped context can protect terms.",
"@id": "#tpr08e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Term with protected scoped context. (error mode)",
"purpose": "A scoped context can protect terms. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr08-in.jsonld",
"expect": "expand/pr08-out.jsonld"
"expect": "protected term redefinition"
}, {
"@id": "#tpr09",
"@id": "#tpr08w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Attempt to redefine term in other protected context.",
"purpose": "A protected term cannot redefine another protected term.",
"name": "Term with protected scoped context. (warn mode)",
"purpose": "A scoped context can protect terms. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr08-in.jsonld",
"expect": "expand/pr08-out.jsonld"
}, {
"@id": "#tpr09e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Attempt to redefine term in other protected context. (error mode)",
"purpose": "A protected term cannot redefine another protected term. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr09-in.jsonld",
"expect": "protected term redefinition"
}, {
"@id": "#tpr09w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Attempt to redefine term in other protected context. (warn mode)",
"purpose": "A protected term cannot redefine another protected term. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr09-in.jsonld",
"expect": "expand/pr09-out.jsonld"
}, {
"@id": "#tpr10",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Simple protected and unprotected terms.",
"purpose": "Simple protected and unprotected terms.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr10-in.jsonld",
"expect": "expand/pr10-out.jsonld"
}, {
"@id": "#tpr11e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Fail to override protected term. (error mode)",
"purpose": "Fail to override protected term. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr11-in.jsonld",
"expect": "protected term redefinition"
}, {
"@id": "#tpr11w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Fail to override protected term. (warn mode)",
"purpose": "Fail to override protected term. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr11-in.jsonld",
"expect": "expand/pr11-out.jsonld"
}, {
"@id": "#tpr12e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Scoped context fail to override protected term. (error mode)",
"purpose": "Scoped context fail to override protected term. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr12-in.jsonld",
"expect": "protected term redefinition"
}, {
"@id": "#tpr12w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Scoped context fail to override protected term. (warn mode)",
"purpose": "Scoped context fail to override protected term. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr12-in.jsonld",
"expect": "expand/pr12-out.jsonld"
}, {
"@id": "#tpr13",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Override unprotected term.",
"purpose": "Override unprotected term.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr13-in.jsonld",
"expect": "expand/pr13-out.jsonld"
}, {
"@id": "#tpr14",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Clear protection with null context.",
"purpose": "Clear protection with null context.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr14-in.jsonld",
"expect": "expand/pr14-out.jsonld"
}, {
"@id": "#tpr15",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Clear protection with array with null context",
"purpose": "Clear protection with array with null context",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr15-in.jsonld",
"expect": "expand/pr15-out.jsonld"
}, {
"@id": "#tpr16",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Override protected terms after null.",
"purpose": "Override protected terms after null.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr16-in.jsonld",
"expect": "expand/pr16-out.jsonld"
}, {
"@id": "#tpr17e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Fail to override protected terms with type. (error mode)",
"purpose": "Fail to override protected terms with type. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr17-in.jsonld",
"expect": "invalid context nullification"
}, {
"@id": "#tpr17w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Fail to override protected terms with type. (warn mode)",
"purpose": "Fail to override protected terms with type. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr17-in.jsonld",
"expect": "expand/pr17-out.jsonld"
}, {
"@id": "#tpr18e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Fail to override protected terms with type+null+ctx. (error mode)",
"purpose": "Fail to override protected terms with type+null+ctx. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr18-in.jsonld",
"expect": "invalid context nullification"
}, {
"@id": "#tpr18w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Fail to override protected terms with type+null+ctx. (warn mode)",
"purpose": "Fail to override protected terms with type+null+ctx. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr18-in.jsonld",
"expect": "expand/pr18-out.jsonld"
}, {
"@id": "#tpr19",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Mix of protected and unprotected terms.",
"purpose": "Mix of protected and unprotected terms.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr19-in.jsonld",
"expect": "expand/pr19-out.jsonld"
}, {
"@id": "#tpr20e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Fail with mix of protected and unprotected terms with type+null+ctx. (error mode)",
"purpose": "Fail with mix of protected and unprotected terms with type+null+ctx. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr20-in.jsonld",
"expect": "invalid context nullification"
}, {
"@id": "#tpr20w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Fail with mix of protected and unprotected terms with type+null+ctx. (warn mode)",
"purpose": "Fail with mix of protected and unprotected terms with type+null+ctx. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr20-in.jsonld",
"expect": "expand/pr20-out.jsonld"
}, {
"@id": "#tpr21e",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Fail with mix of protected and unprotected terms with type+null. (error mode)",
"purpose": "Fail with mix of protected and unprotected terms with type+null. (error mode)",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr21-in.jsonld",
"expect": "invalid context nullification"
}, {
"@id": "#tpr21w",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Fail with mix of protected and unprotected terms with type+null. (warn mode)",
"purpose": "Fail with mix of protected and unprotected terms with type+null. (warn mode)",
"option": {"specVersion": "json-ld-1.1", "protectedMode": "warn"},
"input": "expand/pr21-in.jsonld",
"expect": "expand/pr21-out.jsonld"
}, {
"@id": "#ttn01",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
Expand Down
10 changes: 7 additions & 3 deletions tests/expand/pr01-in.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
"@context": {
"@vocab": "http://example.com/",
"@version": 1.1,
"protected": {"@protected": true}
"protected": {
"@protected": true
}
},
"protected": {
"@context": {"protected": "http://example.com/something-else"},
"protected": "this should have the property http://example.com/protected"
"@context": {
"protected": "http://example.com/something-else"
},
"protected": "error / property http://example.com/protected"
}
}
2 changes: 1 addition & 1 deletion tests/expand/pr01-out.jsonld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"http://example.com/protected": [{
"http://example.com/protected": [{"@value": "this should have the property http://example.com/protected"}]
"http://example.com/protected": [{"@value": "error / property http://example.com/protected"}]
}]
}
]
14 changes: 10 additions & 4 deletions tests/expand/pr02-in.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
"@context": {
"@vocab": "http://example.com/",
"@version": 1.1,
"protected": {"@protected": true},
"unprotected": {"@protected": false}
"protected": {
"@protected": true
},
"unprotected": {
"@protected": false
}
},
"protected": true,
"unprotected": true,
"scope": {
"@context": {"unprotected": "http://example.com/something-else"},
"unprotected": "this should have the property http://example.com/something-else"
"@context": {
"unprotected": "http://example.com/something-else"
},
"unprotected": "property http://example.com/something-else"
}
}
2 changes: 1 addition & 1 deletion tests/expand/pr02-out.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"http://example.com/protected": [{"@value": true}],
"http://example.com/unprotected": [{"@value": true}],
"http://example.com/scope": [{
"http://example.com/something-else": [{"@value": "this should have the property http://example.com/something-else"}]
"http://example.com/something-else": [{"@value": "property http://example.com/something-else"}]
}]
}
]
12 changes: 8 additions & 4 deletions tests/expand/pr03-in.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
"@vocab": "http://example.com/",
"@version": 1.1,
"@protected": true,
"protected1": {"@id": "http://example.com/protected1"},
"protected2": {"@id": "http://example.com/protected2"}
"protected1": {
"@id": "http://example.com/protected1"
},
"protected2": {
"@id": "http://example.com/protected2"
}
},
"protected1": {
"@context": {
"protected1": "http://example.com/something-else",
"protected2": "http://example.com/something-else"
},
"protected1": "this should have the property http://example.com/protected1",
"protected2": "this should have the property http://example.com/protected2"
"protected1": "error / property http://example.com/protected1",
"protected2": "error / property http://example.com/protected2"
}
}
4 changes: 2 additions & 2 deletions tests/expand/pr03-out.jsonld
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{
"http://example.com/protected1": [{
"http://example.com/protected1": [{"@value": "this should have the property http://example.com/protected1"}],
"http://example.com/protected2": [{"@value": "this should have the property http://example.com/protected2"}]
"http://example.com/protected1": [{"@value": "error / property http://example.com/protected1"}],
"http://example.com/protected2": [{"@value": "error / property http://example.com/protected2"}]
}]
}
]
12 changes: 8 additions & 4 deletions tests/expand/pr04-in.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
"@vocab": "http://example.com/",
"@version": 1.1,
"@protected": true,
"protected": {"@id": "http://example.com/protected"},
"unprotected": {"@id": "http://example.com/unprotected", "@protected": false}
"protected": {
"@id": "http://example.com/protected"
},
"unprotected": {
"@id": "http://example.com/unprotected", "@protected": false
}
},
"protected": {
"@context": {
"protected": "http://example.com/something-else1",
"unprotected": "http://example.com/something-else2"
},
"protected": "this should have the property http://example.com/protected",
"unprotected": "this should have the property http://example.com/something-else2"
"protected": "error / property http://example.com/protected",
"unprotected": "property http://example.com/something-else2"
}
}
Loading