Skip to content

Commit c6789ee

Browse files
committed
[299] Add tests for invalid use of fragments in "$id"
1 parent d17e1ba commit c6789ee

File tree

1 file changed

+158
-2
lines changed

1 file changed

+158
-2
lines changed

tests/draft2019-09/ref.json

+158-2
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
"tests": [
274274
{
275275
"description": "valid tree",
276-
"data": {
276+
"data": {
277277
"meta": "root",
278278
"nodes": [
279279
{
@@ -302,7 +302,7 @@
302302
},
303303
{
304304
"description": "invalid tree",
305-
"data": {
305+
"data": {
306306
"meta": "root",
307307
"nodes": [
308308
{
@@ -358,6 +358,162 @@
358358
}
359359
]
360360
},
361+
{
362+
"description": "Location-independent identifier name, fragments disallowed",
363+
"schema": {
364+
"$ref": "#foo",
365+
"$defs": {
366+
"A": {
367+
"$id": "#foo",
368+
"type": "integer"
369+
}
370+
}
371+
},
372+
"tests": [
373+
{
374+
"data": 1,
375+
"description": "match",
376+
"valid": false
377+
},
378+
{
379+
"data": "a",
380+
"description": "mismatch",
381+
"valid": false
382+
}
383+
]
384+
},
385+
{
386+
"description": "Location-independent identifier path, fragments disallowed",
387+
"schema": {
388+
"$ref": "#/a/b",
389+
"$defs": {
390+
"A": {
391+
"$id": "#/a/b",
392+
"type": "integer"
393+
}
394+
}
395+
},
396+
"tests": [
397+
{
398+
"data": 1,
399+
"description": "match",
400+
"valid": false
401+
},
402+
{
403+
"data": "a",
404+
"description": "mismatch",
405+
"valid": false
406+
}
407+
]
408+
},
409+
{
410+
"description": "Location-independent identifier name with absolute URI, fragments disallowed",
411+
"schema": {
412+
"$ref": "http://localhost:1234/bar#foo",
413+
"$defs": {
414+
"A": {
415+
"$id": "http://localhost:1234/bar#foo",
416+
"type": "integer"
417+
}
418+
}
419+
},
420+
"tests": [
421+
{
422+
"data": 1,
423+
"description": "match",
424+
"valid": false
425+
},
426+
{
427+
"data": "a",
428+
"description": "mismatch",
429+
"valid": false
430+
}
431+
]
432+
},
433+
{
434+
"description": "Location-independent identifier path with absolute URI, fragments disallowed",
435+
"schema": {
436+
"$ref": "http://localhost:1234/bar#/a/b",
437+
"$defs": {
438+
"A": {
439+
"$id": "http://localhost:1234/bar#/a/b",
440+
"type": "integer"
441+
}
442+
}
443+
},
444+
"tests": [
445+
{
446+
"data": 1,
447+
"description": "match",
448+
"valid": false
449+
},
450+
{
451+
"data": "a",
452+
"description": "mismatch",
453+
"valid": false
454+
}
455+
]
456+
},
457+
{
458+
"description": "Location-independent identifier name with base URI change in subschema, fragments disallowed",
459+
"schema": {
460+
"$id": "http://localhost:1234/root",
461+
"$ref": "http://localhost:1234/nested.json#foo",
462+
"$defs": {
463+
"A": {
464+
"$id": "nested.json",
465+
"definitions": {
466+
"B": {
467+
"$id": "#foo",
468+
"type": "integer"
469+
}
470+
}
471+
}
472+
}
473+
},
474+
"tests": [
475+
{
476+
"data": 1,
477+
"description": "match",
478+
"valid": false
479+
},
480+
{
481+
"data": "a",
482+
"description": "mismatch",
483+
"valid": false
484+
}
485+
]
486+
},
487+
{
488+
"description": "Location-independent identifier path with base URI change in subschema, fragments disallowed",
489+
"schema": {
490+
"$id": "http://localhost:1234/root",
491+
"$ref": "http://localhost:1234/nested.json#/a/b",
492+
"$defs": {
493+
"A": {
494+
"$id": "nested.json",
495+
"definitions": {
496+
"B": {
497+
"$id": "#/a/b",
498+
"type": "integer"
499+
}
500+
}
501+
}
502+
}
503+
},
504+
"tests": [
505+
{
506+
"data": 1,
507+
"description": "match",
508+
"valid": false
509+
},
510+
{
511+
"data": "a",
512+
"description": "mismatch",
513+
"valid": false
514+
}
515+
]
516+
},
361517
{
362518
"description": "ref creates new scope when adjacent to keywords",
363519
"schema": {

0 commit comments

Comments
 (0)