Skip to content

Http profile #56

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
23 changes: 22 additions & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ be used to verify JSON-LD Processor conformance to the set of specifications
that constitute JSON-LD. The goal of the suite is to provide an easy and
comprehensive JSON-LD testing solution for developers creating JSON-LD Processors.

More information and an RDFS definition of the test vocabulary can be found at [vocab](https://w3c.github.io/json-ld-api/tests/vocab).

# Design

Tests are defined into _compact_, _expand_, _flatten_, _remote-doc_, _fromRdf_, and _toRdf_ sections:
Expand All @@ -26,7 +28,9 @@ Tests are defined into _compact_, _expand_, _flatten_, _remote-doc_, _fromRdf_,
* _remote-doc_ tests have _input_ and _expected_ documents.
The _expected_ results can be compared using [JSON-LD object comparison](#json-ld-object-comparison) with the processor output.

For *NegativeEvaluationTests*, the result is a string associated with the expected error code. Options may be present to describe the intended HTTP behavior:
For *NegativeEvaluationTests*, the result is a string associated with the expected error code.

Options may be present to describe the intended HTTP behavior:
* _contentType_: Content-Type of the returned HTTP payload, defaults to the appropriate type for the _input_ suffix.
* _httpStatus_: The HTTP status code to return, defaults to `200`.
* _redirectTo_: The HTTP _Content-Location_ header value.
Expand All @@ -35,6 +39,23 @@ Tests are defined into _compact_, _expand_, _flatten_, _remote-doc_, _fromRdf_,
The _expected_ results can be compared using [JSON-LD object comparison](#json-ld-object-comparison) with the processor output.
* _toRdf_ tests have _input_ and _expected_ documents.
The _expected_ results can be compared using [RDF Dataset Isomorphism](https://www.w3.org/TR/rdf11-concepts/#dfn-dataset-isomorphism).
* _http_ tests have _input_ and _expected_ documents and an optional _context_ document.
These tests describe the behavior of an HTTP server performing content-negotiation using the ACCEPT header, specified using the _accept_ option to generate the _expected_ result document.
The _expected_ results can be compared using [JSON-LD object comparison](#json-ld-object-comparison) with the processor output
after potentially remapping blank node identifiers (see below).
Additionally, if the result is compacted and the `ordered` option is not set, result should be expanded and compared with the expanded _expected_ document also using [JSON-LD object comparison](#json-ld-object-comparison).

If the result is to be compacted, and no explicit context URL is provided, test subjects should use http/default-context.jsonld

If the profile parameter includes http://example.com/do-not-use, test subjects should reject the URL and not accept the media type. Otherwise, for any other URL, applications should apply the specified URL for the context or frame, as appropriate.

For *NegativeEvaluationTests*, the result is the expected HTTP status. Options may be present to describe the intended HTTP behavior:
* _accept_: The HTTP _Accept_ header value.

Options may be present to describe the intended HTTP behavior:
* _contentType_: Content-Type of the returned HTTP payload, defaults to the appropriate type for the _input_ suffix.
* _httpAccept_: The HTTP _Accept_ header value.
* _httpLink_: The HTTP _Link_ header value.

Unless `processingMode` is set explicitly in a test entry, `processingMode` is compatible with both `json-ld-1.0` and `json-ld-1.1`.

Expand Down
9 changes: 5 additions & 4 deletions tests/context.jsonld
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"@context": {
"@vocab": "https://json-ld.org/test-suite/vocab#",
"@vocab": "https://w3c.github.io/json-ld-api/tests/vocab#",
"dc": "http://purl.org/dc/terms/",
"jld": "https://w3c.github.io/json-ld-api/vocab#",
"jld": "https://w3c.github.io/json-ld-api/tests/vocab#",
"mf": "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
Expand All @@ -21,10 +21,11 @@
"base": { "@type": "@id" },
"compactArrays": { "@type": "xsd:boolean" },
"compactToRelative": { "@type": "xsd:boolean" },
"documentLoader": { "@type": "xsd:string" },
"contentType": { "@type": "xsd:boolean" },
"expandContext": { "@type": "xsd:string" },
"httpStatus": { "@type": "xsd:integer" },
"httpAccept": { "@type": "xsd:string" },
"httpLink": { "@type": "xsd:string", "@container": "@set" },
"httpStatus": { "@type": "xsd:integer" },
"processingMode": { "@type": "xsd:string" },
"produceGeneralizedRdf":{ "@type": "xsd:boolean" },
"specVersion": { "@type": "xsd:string" },
Expand Down
228 changes: 228 additions & 0 deletions tests/http-manifest.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
{
"@context": "https://w3c.github.io/json-ld-api/context.jsonld",
"@id": "",
"@type": "mf:Manifest",
"name": "HTTP",
"description": "Tests the appropriate server response to an HTTP Accept header and use of the profile parameter to the application/ld+json media type.",
"baseIri": "https://w3c.github.io/json-ld-api/tests/",
"sequence": [
{
"@id": "#t0001",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return unprocessed input",
"purpose": "Support application/ld+json media type.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json",
"contentType": "application/ld+json"
},
"input": "http/0001-in.jsonld",
"expect": "http/0001-out.jsonld"
}, {
"@id": "#t0002",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return expanded input with profile=http://www.w3.org/ns/json-ld#expanded",
"purpose": "Perform expansion of the input.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=http://www.w3.org/ns/json-ld#expanded",
"contentType": "application/ld+json"
},
"input": "http/0002-in.jsonld",
"expect": "http/0002-out.jsonld"
}, {
"@id": "#t0003",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return compacted input using the default context with profile=http://www.w3.org/ns/json-ld#compacted",
"purpose": "Perform compaction of the input.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=http://www.w3.org/ns/json-ld#compacted",
"contentType": "application/ld+json"
},
"input": "http/0003-in.jsonld",
"context": "http/default-context.jsonld",
"expect": "http/0003-out.jsonld"
}, {
"@id": "#t0004",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return compacted input using the specified context with application/ld+json and link header",
"purpose": "Perform compaction of the input.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json",
"httpLink": "<https://w3c.github.io/json-ld-api/tests/http/0004-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"",
"contentType": "application/ld+json"
},
"input": "http/0004-in.jsonld",
"context": "http/0004-context.jsonld",
"expect": "http/0004-out.jsonld"
}, {
"@id": "#t0005",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return compacted input using the specified context with application/ld+json;profile=\"http://www.w3.org/ns/json-ld#compacted\"",
"purpose": "Perform compaction of the input.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=\"http://www.w3.org/ns/json-ld#compacted\"",
"httpLink": "<https://w3c.github.io/json-ld-api/tests/http/0005-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"",
"contentType": "application/ld+json"
},
"input": "http/0005-in.jsonld",
"context": "http/0005-context.jsonld",
"expect": "http/0005-out.jsonld"
}, {
"@id": "#t0007",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return flattened input as application/ld+json using specified with application/ld+json;profile=http://www.w3.org/ns/json-ld#flattened",
"purpose": "Perform flattening of the input in expanded form.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=http://www.w3.org/ns/json-ld#flattened",
"contentType": "application/ld+json"
},
"input": "http/0007-in.jsonld",
"expect": "http/0007-out.jsonld"
}, {
"@id": "#t0008",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return flattened input using the default context with application/ld+json;profile=\"http://www.w3.org/ns/json-ld#flattened http://www.w3.org/ns/json-ld#compacted\"",
"purpose": "Perform flattening of the input in compact form.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=\"http://www.w3.org/ns/json-ld#flattened http://www.w3.org/ns/json-ld#compacted\"",
"contentType": "application/ld+json"
},
"input": "http/0008-in.jsonld",
"expect": "http/0008-out.jsonld"
}, {
"@id": "#t0009",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return flattened input using the default context with application/ld+json;profile=\"http://www.w3.org/ns/json-ld#compacted http://www.w3.org/ns/json-ld#flattened\"",
"purpose": "Perform flattening of the input in compact form.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=\"http://www.w3.org/ns/json-ld#compacted http://www.w3.org/ns/json-ld#flattened\"",
"contentType": "application/ld+json"
},
"input": "http/0009-in.jsonld",
"expect": "http/0009-out.jsonld"
}, {
"@id": "#t0010",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return flattened input using the specified context with application/ld+json;profile=\"http://www.w3.org/ns/json-ld#flattened\"",
"purpose": "Perform flattening of the input in compact form.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=\"http://www.w3.org/ns/json-ld#flattened https://w3c.github.io/json-ld-api/tests/http/0010-context.jsonld\"",
"httpLink": "<https://w3c.github.io/json-ld-api/tests/http/0010-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"",
"contentType": "application/ld+json"
},
"input": "http/0010-in.jsonld",
"context": "http/0010-context.jsonld",
"expect": "http/0010-out.jsonld"
}, {
"@id": "#t0011",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return flattened input using the specified context with application/ld+json;profile=http://www.w3.org/ns/json-ld#flattened",
"purpose": "Perform flattening of the input in compact form.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=http://www.w3.org/ns/json-ld#flattened",
"httpLink": "<https://w3c.github.io/json-ld-api/tests/http/0011-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"",
"contentType": "application/ld+json"
},
"input": "http/0011-in.jsonld",
"context": "http/0011-context.jsonld",
"expect": "http/0011-out.jsonld"
}, {
"@id": "#t0012",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return flattened input using the specified context with application/ld+json;profile=\"http://www.w3.org/ns/json-ld#flattened http://www.w3.org/ns/json-ld#compacted\"",
"purpose": "Perform flattening of the input in compact form.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=\"http://www.w3.org/ns/json-ld#flattened http://www.w3.org/ns/json-ld#compacted\"",
"httpLink": "<https://w3c.github.io/json-ld-api/tests/http/0012-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"",
"contentType": "application/ld+json"
},
"input": "http/0012-in.jsonld",
"context": "http/0012-context.jsonld",
"expect": "http/0012-out.jsonld"
}, {
"@id": "#t0013",
"@type": ["jld:PositiveEvaluationTest", "jld:HttpTest"],
"name": "Return framed input using the specified frame with application/ld+json;profile=http://www.w3.org/ns/json-ld#framed",
"purpose": "Perform flattening of the input in compact form.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=http://www.w3.org/ns/json-ld#framed",
"httpLink": "<https://w3c.github.io/json-ld-api/tests/http/0013-frame.jsonld>; rel=\"http://www.w3.org/ns/json-ld#frame\"",
"contentType": "application/ld+json"
},
"input": "http/0013-in.jsonld",
"frame": "http/0013-frame.jsonld",
"expect": "http/0013-out.jsonld"
}, {
"@id": "#t0014",
"@type": ["jld:NegativeEvaluationTest", "jld:HttpTest"],
"name": "Return status 406 with application/ld+json;profile=http://www.w3.org/ns/json-ld#framed",
"purpose": "Do not respond to invalid profile parameters (missing frame).",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=http://www.w3.org/ns/json-ld#framed",
"contentType": "text/plain"
},
"input": "http/0014-in.jsonld",
"expect": 406
}, {
"@id": "#t0015",
"@type": ["jld:NegativeEvaluationTest", "jld:HttpTest"],
"name": "Return status 406 with application/ld+json;profile=\"http://www.w3.org/ns/json-ld#framed http://www.w3.org/ns/json-ld#expanded\"",
"purpose": "Do not respond to invalid profile parameters.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=\"http://www.w3.org/ns/json-ld#framed http://www.w3.org/ns/json-ld#expanded\"",
"contentType": "text/plain"
},
"input": "http/0015-in.jsonld",
"expect": 406
}, {
"@id": "#t0016",
"@type": ["jld:NegativeEvaluationTest", "jld:HttpTest"],
"name": "Return status 406 with application/ld+json;profile=\"http://www.w3.org/ns/json-ld#expanded http://www.w3.org/ns/json-ld#framed\"",
"purpose": "Do not respond to invalid profile parameters.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=\"http://www.w3.org/ns/json-ld#expanded http://www.w3.org/ns/json-ld#framed\"",
"contentType": "text/plain"
},
"input": "http/0016-in.jsonld",
"expect": 406
}, {
"@id": "#t0017",
"@type": ["jld:NegativeEvaluationTest", "jld:HttpTest"],
"name": "Return status 406 with application/ld+json;profile=\"http://www.w3.org/ns/json-ld#framed http://www.w3.org/ns/json-ld#compacted\"",
"purpose": "Do not respond to invalid profile parameters.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=\"http://www.w3.org/ns/json-ld#framed http://www.w3.org/ns/json-ld#compacted\"",
"contentType": "text/plain"
},
"input": "http/0017-in.jsonld",
"expect": 406
}, {
"@id": "#t0018",
"@type": ["jld:NegativeEvaluationTest", "jld:HttpTest"],
"name": "Return status 406 with application/ld+json;profile=\"http://www.w3.org/ns/json-ld#compacted http://www.w3.org/ns/json-ld#framed\"",
"purpose": "Do not respond to invalid profile parameters.",
"option": {
"specVersion": "json-ld-1.1",
"httpAccept": "application/ld+json;profile=\"http://www.w3.org/ns/json-ld#compacted http://www.w3.org/ns/json-ld#framed\"",
"contentType": "text/plain"
},
"input": "http/0018-in.jsonld",
"expect": 406
}
]
}
18 changes: 18 additions & 0 deletions tests/http/0001-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"@id": "http://example.org/library",
"@type": "http://example.org/vocab#Library",
"http://example.org/vocab#contains": {"@id": "http://example.org/library/the-republic"}
}, {
"@id": "http://example.org/library/the-republic",
"@type": "http://example.org/vocab#Book",
"http://purl.org/dc/elements/1.1/creator": "Plato",
"http://purl.org/dc/elements/1.1/title": "The Republic",
"http://example.org/vocab#contains": {
"@id": "http://example.org/library/the-republic#introduction",
"@type": "http://example.org/vocab#Chapter",
"http://purl.org/dc/elements/1.1/description": "An introductory chapter on The Republic.",
"http://purl.org/dc/elements/1.1/title": "The Introduction"
}
}
]
18 changes: 18 additions & 0 deletions tests/http/0001-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"@id": "http://example.org/library",
"@type": "http://example.org/vocab#Library",
"http://example.org/vocab#contains": {"@id": "http://example.org/library/the-republic"}
}, {
"@id": "http://example.org/library/the-republic",
"@type": "http://example.org/vocab#Book",
"http://purl.org/dc/elements/1.1/creator": "Plato",
"http://purl.org/dc/elements/1.1/title": "The Republic",
"http://example.org/vocab#contains": {
"@id": "http://example.org/library/the-republic#introduction",
"@type": "http://example.org/vocab#Chapter",
"http://purl.org/dc/elements/1.1/description": "An introductory chapter on The Republic.",
"http://purl.org/dc/elements/1.1/title": "The Introduction"
}
}
]
18 changes: 18 additions & 0 deletions tests/http/0002-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"@id": "http://example.org/library",
"@type": "http://example.org/vocab#Library",
"http://example.org/vocab#contains": {"@id": "http://example.org/library/the-republic"}
}, {
"@id": "http://example.org/library/the-republic",
"@type": "http://example.org/vocab#Book",
"http://purl.org/dc/elements/1.1/creator": "Plato",
"http://purl.org/dc/elements/1.1/title": "The Republic",
"http://example.org/vocab#contains": {
"@id": "http://example.org/library/the-republic#introduction",
"@type": "http://example.org/vocab#Chapter",
"http://purl.org/dc/elements/1.1/description": "An introductory chapter on The Republic.",
"http://purl.org/dc/elements/1.1/title": "The Introduction"
}
}
]
18 changes: 18 additions & 0 deletions tests/http/0002-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"@id": "http://example.org/library",
"@type": ["http://example.org/vocab#Library"],
"http://example.org/vocab#contains": [{"@id": "http://example.org/library/the-republic"}]
}, {
"@id": "http://example.org/library/the-republic",
"@type": ["http://example.org/vocab#Book"],
"http://purl.org/dc/elements/1.1/creator": [{"@value": "Plato"}],
"http://purl.org/dc/elements/1.1/title": [{"@value": "The Republic"}],
"http://example.org/vocab#contains": [{
"@id": "http://example.org/library/the-republic#introduction",
"@type": ["http://example.org/vocab#Chapter"],
"http://purl.org/dc/elements/1.1/description": [{"@value": "An introductory chapter on The Republic."}],
"http://purl.org/dc/elements/1.1/title": [{"@value": "The Introduction"}]
}]
}
]
Loading