-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
2279 lines (2039 loc) · 99 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var fs = require('fs');
var etag = require('etag');
var uuid = require('node-uuid');
var btoa = require("btoa");
var atob = require("atob");
var mayktso = require('mayktso');
var config = mayktso.config();
mayktso.init({'config': config, 'omitRoutes': ['/media', '/sender', '/target/', '/receiver', '/consumer', '/discover-inbox-rdf-body', '/discover-inbox-link-header', '/inbox-compacted/$', '/inbox-expanded/$', '/inbox-sender/$', '/send-report', '/summary']});
if(!fs.existsSync('inbox-sender')) { fs.mkdirSync('inbox-sender') }
mayktso.app.use('/media', mayktso.express.static(__dirname + '/media'));
mayktso.app.route('/send-report').all(reportTest);
mayktso.app.route('/summary').all(showSummary);
mayktso.app.route('/sender').all(testSender);
mayktso.app.route('/target/:id').all(getTarget);
mayktso.app.route('/receiver').all(testReceiver);
mayktso.app.route('/consumer').all(testConsumer);
mayktso.app.route('/discover-inbox-link-header').all(getTarget);
mayktso.app.route('/discover-inbox-rdf-body').all(getTarget);
mayktso.app.route('/inbox-compacted/').all(function(req, res, next){
mayktso.handleResource(req, res, next, { jsonld: { profile: 'http://www.w3.org/ns/json-ld#compacted' }});
});
mayktso.app.route('/inbox-expanded/').all(function(req, res, next){
mayktso.handleResource(req, res, next, { jsonld: { profile: 'http://www.w3.org/ns/json-ld#expanded' }});
});
mayktso.app.route('/inbox-sender/').all(function(req, res, next){
var fileNameSuffix = '';
if(req.query && 'discovery' in req.query && req.query['discovery'].length > 0) {
fileNameSuffix = '.' + req.query['discovery'];
}
mayktso.handleResource(req, res, next, { jsonld: { profile: 'http://www.w3.org/ns/json-ld#expanded' }, storeMeta: true, allowSlug: true, fileNameSuffix: fileNameSuffix });
});
// console.log(mayktso.app._router.stack);
var getResource = mayktso.getResource;
var getResourceHead = mayktso.getResourceHead;
var getResourceOptions = mayktso.getResourceOptions;
var postResource = mayktso.postResource;
var htmlEntities = mayktso.htmlEntities;
var preSafe = mayktso.preSafe;
var vocab = mayktso.vocab;
var prefixes = mayktso.prefixes;
var prefixesRDFa = mayktso.prefixesRDFa;
var getGraph = mayktso.getGraph;
var getGraphFromData = mayktso.getGraphFromData;
var serializeData = mayktso.serializeData;
var SimpleRDF = mayktso.SimpleRDF;
var RDFstore = mayktso.RDFstore;
var parseLinkHeader = mayktso.parseLinkHeader;
var parseProfileLinkRelation = mayktso.parseProfileLinkRelation;
var getBaseURL = mayktso.getBaseURL;
var getExternalBaseURL = mayktso.getExternalBaseURL;
var XMLHttpRequest = mayktso.XMLHttpRequest;
var discoverInbox = mayktso.discoverInbox;
var getInboxNotifications = mayktso.getInboxNotifications;
var resStatus = mayktso.resStatus;
var ldnTestsVocab = {
"earlAssertion": { "@id": "http://www.w3.org/ns/earl#Assertion", "@type": "@id" },
"earlinfo": { "@id": "http://www.w3.org/ns/earl#info" },
"earloutcome": { "@id": "http://www.w3.org/ns/earl#outcome", "@type": "@id" },
"earlsubject": { "@id": "http://www.w3.org/ns/earl#subject", "@type": "@id" },
"earlresult": { "@id": "http://www.w3.org/ns/earl#result", "@type": "@id" },
"earltest": { "@id": "http://www.w3.org/ns/earl#test", "@type": "@id" },
"qbObservation": { "@id": "http://purl.org/linked-data/cube#Observation", "@type": "@id" },
"doapProject": { "@id": "http://usefulinc.com/ns/doap#Project", "@type": "@id" },
"doapname": { "@id": "http://usefulinc.com/ns/doap#name" }
}
Object.assign(vocab, ldnTestsVocab);
var ldnTests = {
'sender': {
'testSenderHeaderDiscovery': {
'uri': 'https://www.w3.org/TR/ldn/#test-sender-header-discovery',
'description': 'Inbox discovery (<code>Link</code> header).',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testSenderHeaderPostRequest': {
'uri': 'https://www.w3.org/TR/ldn/#test-sender-header-post-request',
'description': 'Makes <code>POST</code> requests (<code>Link</code> header).',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testSenderHeaderPostContentTypeJSONLD': {
'uri': 'https://www.w3.org/TR/ldn/#test-sender-header-post-content-type-json-ld',
'description': '<code>POST</code> includes <code>Content-Type: application/ld+json</code> (<code>Link</code> header).',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testSenderHeaderPostValidJSONLD': {
'uri': 'https://www.w3.org/TR/ldn/#test-sender-header-post-valid-json-ld',
'description': '<code>POST</code> payload is JSON-LD (<code>Link</code> header).',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testSenderBodyDiscovery': {
'uri': 'https://www.w3.org/TR/ldn/#test-sender-body-discovery',
'description': 'Inbox discovery (RDF body).',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testSenderBodyPostRequest': {
'uri': 'https://www.w3.org/TR/ldn/#test-sender-body-post-request',
'description': 'Makes <code>POST</code> requests (RDF body).',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testSenderBodyPostContentTypeJSONLD': {
'uri': 'https://www.w3.org/TR/ldn/#test-sender-body-post-content-type-json-ld',
'description': '<code>POST</code> includes <code>Content-Type: application/ld+json</code> (RDF body).',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testSenderBodyPostBodyJSONLD': {
'uri': 'https://www.w3.org/TR/ldn/#test-sender-body-post-valid-json-ld',
'description': '<code>POST</code> payload is JSON-LD (RDF body).',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
}
},
'consumer': {
'testConsumerHeaderDiscovery': {
'uri': 'https://www.w3.org/TR/ldn/#test-consumer-header-discovery',
'description': 'Inbox discovery (<code>Link</code> header).',
'earl:mode': 'earl:semiAuto',
'requirement': 'MUST'
},
'testConsumerBodyDiscovery': {
'uri': 'https://www.w3.org/TR/ldn/#test-consumer-body-discovery',
'description': 'Inbox discovery (RDF body).',
'earl:mode': 'earl:semiAuto',
'requirement': 'MUST'
},
'testConsumerListingJSONLDCompacted': {
'uri': 'https://www.w3.org/TR/ldn/#test-consumer-listing-json-ld-compacted',
'description': 'Notification discovery from Inbox using JSON-LD compacted form.',
'earl:mode': 'earl:semiAuto',
'requirement': 'MUST'
},
'testConsumerListingJSONLDExpanded': {
'uri': 'https://www.w3.org/TR/ldn/#test-consumer-listing-json-ld-expanded',
'description': 'Notification discovery from Inbox using JSON-LD expanded form.',
'earl:mode': 'earl:semiAuto',
'requirement': 'MUST'
},
'testConsumerNotificationAnnounce': {
'uri': 'https://www.w3.org/TR/ldn/#test-consumer-notification-announce',
'description': 'Contents of the <samp>announce</samp> notification.',
'earl:mode': 'earl:semiAuto',
'requirement': 'MAY'
},
'testConsumerNotificationChangelog': {
'uri': 'https://www.w3.org/TR/ldn/#test-consumer-notification-changelog',
'description': 'Contents of the <samp>changelog</samp> notification.',
'earl:mode': 'earl:semiAuto',
'requirement': 'MAY'
},
'testConsumerNotificationCitation': {
'uri': 'https://www.w3.org/TR/ldn/#test-consumer-notification-citation',
'description': 'Contents of the <samp>citation</samp> notification.',
'earl:mode': 'earl:semiAuto',
'requirement': 'MAY'
},
'testConsumerNotificationAssessing': {
'uri': 'https://www.w3.org/TR/ldn/#test-consumer-notification-assessing',
'description': 'Contents of the <samp>assessing</samp> notification.',
'earl:mode': 'earl:semiAuto',
'requirement': 'MAY'
},
'testConsumerNotificationComment': {
'uri': 'https://www.w3.org/TR/ldn/#test-consumer-notification-comment',
'description': 'Contents of the <samp>comment</samp> notification.',
'earl:mode': 'earl:semiAuto',
'requirement': 'MAY'
},
'testConsumerNotificationRSVP': {
'uri': 'https://www.w3.org/TR/ldn/#test-consumer-notification-rsvp',
'description': 'Contents of the <samp>rsvp</samp> notifications.',
'earl:mode': 'earl:semiAuto',
'requirement': 'MAY'
}
},
'receiver': {
'testReceiverPostResponse': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-post-response',
'description': 'Accepts <code>POST</code> requests.',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testReceiverPostCreated': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-post-created',
'description': 'Responds to <code>POST</code> requests with <code>Content-Type: application/ld+json</code> with status code <code>201 Created</code> or <code>202 Accepted</code>.',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testReceiverPostLocation': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-post-location',
'description': 'Returns a <code>Location</code> header in response to successful <code>POST</code> requests.',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testReceiverPostLinkProfile': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-post-link-profile',
'description': 'Succeeds when the content type includes a <code>profile</code> parameter.',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testReceiverGetResponse': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-get-response',
'description': 'Returns JSON-LD on <code>GET</code> requests.',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testReceiverGetLDPContains': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-get-ldp-contains',
'description': 'Lists notification URIs with <code>ldp:contains</code>.',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testReceiverGetNotificationsJSONLD': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-get-notifications-json-ld',
'description': 'Notifications are available as JSON-LD.',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testReceiverGetNotificationsRDFSource': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-get-notifications-rdf-source',
'description': 'When requested with no <code>Accept</code> header or <code>*/*</code>, notifications are still returned as RDF.',
'earl:mode': 'earl:automatic',
'requirement': 'MUST'
},
'testReceiverOptionsResponse': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-options-response',
'description': 'Accepts <code>OPTIONS</code> requests.',
'earl:mode': 'earl:automatic',
'requirement': 'MAY'
},
'testReceiverOptionsAcceptPost': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-options-accept-post',
'description': 'Advertises acceptable content types with <code>Accept-Post</code> in response to <code>OPTIONS</code> request.',
'earl:mode': 'earl:automatic',
'requirement': 'MAY',
'dependency': 'testReceiverOptionsResponse'
},
'testReceiverOptionsAcceptPostContainsJSONLD': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-options-accept-post-contains-json-ld',
'description': '<code>Accept-Post</code> includes <code>application/ld+json</code>.',
'earl:mode': 'earl:automatic',
'requirement': 'MAY',
'dependency': 'testReceiverOptionsResponse'
},
'testReceiverPostResponseConstraintsUnmet': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-post-response-contraints-unmet',
'description': 'Fails to process notifications if implementation-specific constraints are not met.',
'earl:mode': 'earl:automatic',
'requirement': 'SHOULD'
},
'testReceiverGetNotificationsLimited': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-get-notifications-limited',
'description': 'Restricts list of notification URIs (eg. according to access control).',
'earl:mode': 'earl:semiAuto',
'requirement': 'MAY'
},
'testReceiverGetLDPContainer': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-get-ldp-container',
'description': 'Inbox has type <code>ldp:Container</code>.',
'earl:mode': 'earl:automatic',
'requirement': 'MAY'
},
'testReceiverGetLDPConstrainedBy': {
'uri': 'https://www.w3.org/TR/ldn/#test-receiver-get-ldp-constrained-by',
'description': 'Advertises constraints with <code>ldp:constrainedBy</code>.',
'earl:mode': 'earl:automatic',
'requirement': 'MAY'
}
}
}
// 'testReceiverHeadResponse': {
// 'description': 'Accepts <code>HEAD</code> requests.',
// 'earl:mode': 'earl:automatic'
// },
// Object.keys(ldnTests).forEach(function(i){
// console.log(Object.keys(ldnTests[i]));
// });
function testSender(req, res, next){
// console.log(req.requestedPath);
// console.log(req);
switch(req.method){
case 'GET':
if(!req.requestedType){
resStatus(res, 406);
}
var data = getTestSenderHTML(req);
if (req.headers['if-none-match'] && (req.headers['if-none-match'] == etag(data))) {
res.status(304);
res.end();
break;
}
res.set('Link', '<http://www.w3.org/ns/ldp#Resource>; rel="type", <http://www.w3.org/ns/ldp#RDFSource>; rel="type"');
res.set('Content-Type', 'text/html;charset=utf-8');
res.set('Content-Length', Buffer.byteLength(data, 'utf-8'));
res.set('ETag', etag(data));
res.set('Vary', 'Origin');
res.set('Allow', 'GET, POST');
res.status(200);
res.send(data);
res.end();
break;
case 'POST':
break;
default:
res.status(405);
res.set('Allow', 'GET, POST');
res.end();
break;
}
return;
}
function getTestSenderHTML(req, results){
var targetId = uuid.v1();
var targetIRI = getExternalBaseURL(req.getUrl()) + 'target/' + targetId;
return `<!DOCTYPE html>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>LDN Tests for Senders</title>
<meta content="width=device-width, initial-scale=1" name="viewport" />
<link href="${req.getRootUrl()}/media/css/ldntests.css" media="all" rel="stylesheet" />
</head>
<body about="" prefix="${prefixesRDFa}" typeof="schema:CreativeWork sioc:Post prov:Entity">
<main>
<article about="" typeof="schema:Article">
<h1 property="schema:name">LDN Tests for Senders</h1>
<div id="content">
<section id="senders" inlist="" rel="schema:hasPart" resource="#senders">
<h2 property="schema:name">Sender</h2>
<div datatype="rdf:HTML" property="schema:description">
<p>Run your sender software to <em>both</em> of these targets which advertise their inboxes through <code>Link</code> header and RDF body respectively:</p>
<ul>
<li><code>${targetIRI}?discovery=link-header</code></li>
<li><code>${targetIRI}?discovery=rdf-body</code></li>
</ul>
<p>To see the test results and to submit a report go to: <code><a href="${targetIRI}">${targetIRI}</a></code>.</p>
<p>Reports will be submitted to an <a about="" rel="ldp:inbox" href="reports/">inbox</a> and can be retrieved.</p>
</div>
</section>
</div>
</article>
</main>
</body>
</html>
`;
}
function testReceiver(req, res, next){
// console.log(req.requestedPath);
// console.log(req);
switch(req.method){
case 'GET':
if(!req.accepts(['text/html', 'application/xhtml+xml', '*/*'])) {
resStatus(res, 406);
}
var data = getTestReceiverHTML(req);
if (req.headers['if-none-match'] && (req.headers['if-none-match'] == etag(data))) {
res.status(304);
res.end();
break;
}
res.set('Link', '<http://www.w3.org/ns/ldp#Resource>; rel="type", <http://www.w3.org/ns/ldp#RDFSource>; rel="type"');
res.set('Content-Type', 'text/html;charset=utf-8');
res.set('Content-Length', Buffer.byteLength(data, 'utf-8'));
res.set('ETag', etag(data));
res.set('Vary', 'Origin');
res.set('Allow', 'GET, POST');
res.status(200);
res.send(data);
res.end();
break;
case 'POST':
var testReceiverPromises = [];
var initTest = { '1': testReceiverOptionsResponse, '2': testReceiverPostResponse, '3': testReceiverGetResponse };
if(req.body['test-receiver-url'] && (req.body['test-receiver-url'].toLowerCase().slice(0,7) == 'http://' || req.body['test-receiver-url'].toLowerCase().slice(0,8) == 'https://')) {
Object.keys(initTest).forEach(function(id) {
testReceiverPromises.push(initTest[id](req));
});
Promise.all(testReceiverPromises)
.then((results) => {
// console.dir(results);
var resultsData = {};
results.forEach(function(r){
Object.assign(resultsData, r['receiver']);
});
// console.dir(resultsData);
var reportHTML = getTestReportHTML(resultsData, 'receiver');
var test = {'url': req.body['test-receiver-url'] };
test['implementationType'] = 'receiver';
test['results'] = resultsData;
resultsData['test-receiver-report-html'] = testResponse(req, test, reportHTML);
var data = getTestReceiverHTML(req, resultsData);
// console.log(data);
res.set('Content-Type', 'text/html;charset=utf-8');
res.set('Allow', 'GET, POST');
res.status(200);
res.send(data);
res.end();
})
.catch((e) => {
console.log('--- catch ---');
console.log(e);
res.end();
});
}
break;
default:
res.status(405);
res.set('Allow', 'GET, POST');
res.end();
break;
}
return;
}
function testReceiverOptionsResponse(req){
var testResults = { 'receiver': {} };
var headers = {};
headers['Content-Type'] = ('test-receiver-mimetype' in req.body) ? req.body['test-receiver-mimetype'] : 'application/ld+json';
var url = req.body['test-receiver-url'];
// console.log('testReceiverOptions: ' + url);
return getResourceOptions(url, headers).then(
function(response){
var acceptPost = response.xhr.getResponseHeader('Accept-Post');
testResults['receiver']['testReceiverOptionsResponse'] = { 'earl:outcome': 'earl:passed', 'earl:info': '' };
if(acceptPost){
testResults['receiver']['testReceiverOptionsAcceptPost'] = { 'earl:outcome': 'earl:passed', 'earl:info': '<code>Accept-Post: ' + acceptPost + '</code>' };
var acceptPosts = acceptPost.split(',');
testResults['receiver']['testReceiverOptionsAcceptPostContainsJSONLD'] = { 'earl:outcome': 'earl:failed', 'earl:info': '<code>Accept-Post: ' + acceptPost + '</code>' };
acceptPosts.forEach(function(i){
var m = i.trim();
if(m == 'application/ld+json' || m == '*/*'){
testResults['receiver']['testReceiverOptionsAcceptPostContainsJSONLD'] = { 'earl:outcome': 'earl:passed', 'earl:info': '' };
}
})
}
else {
testResults['receiver']['testReceiverOptionsAcceptPost'] = { 'earl:outcome': 'earl:failed', 'earl:info': '<code>Accept-Post: ' + acceptPost + '</code>' };
}
return Promise.resolve(testResults);
},
function(reason){
testResults['receiver']['testReceiverOptionsResponse'] = { 'earl:outcome': 'earl:inapplicable', 'earl:info': '<code>HTTP ' + reason.xhr.status + '</code>' };
return Promise.resolve(testResults);
});
}
function testReceiverHeadResponse(req){
var testResults = { 'receiver': {} };
var headers = {};
headers['Content-Type'] = ('test-receiver-mimetype' in req.body) ? req.body['test-receiver-mimetype'] : 'application/ld+json';
var url = req.body['test-receiver-url'];
// console.log('testReceiverHeadResponse: ' + url);
return getResourceHead(url, headers).then(
function(response){
testResults['receiver']['testReceiverHeadResponse'] = { 'earl:outcome': 'earl:passed', 'earl:info': '' };
return Promise.resolve(testResults);
},
function(reason){
testResults['receiver']['testReceiverHeadResponse'] = { 'earl:outcome': 'earl:inapplicable', 'earl:info': '<code>HTTP ' + reason.xhr.status + '</code>' };
return Promise.resolve(testResults);
});
}
function testReceiverGetResponse(req){
var testResults = { 'receiver': {} };
var headers = {};
headers['Accept'] = ('test-receiver-mimetype' in req.body) ? req.body['test-receiver-mimetype'] : 'application/ld+json';
var url = req.body['test-receiver-url'];
// console.log('testReceiverGetResponse: ' + url);
return getResource(url, headers).then(
function(response){
// console.log(response);
testResults['receiver']['testReceiverGetNotificationsLimited'] = { 'earl:outcome': 'earl:inapplicable', 'earl:info': '' };
testResults['receiver']['testReceiverGetLDPContains'] = { 'earl:outcome': 'earl:untested', 'earl:info': '' };
if('test-receiver-get-notifications-limited' in req.body){
testResults['receiver']['testReceiverGetNotificationsLimited'] = { 'earl:outcome': 'earl:passed', 'earl:info': '' };
}
var linkHeaders = parseLinkHeader(response.xhr.getResponseHeader('Link'));
var rdftypes = [];
var ldpContainerFound = false;
testResults['receiver']['testReceiverGetLDPContainer'] = { 'earl:outcome': 'earl:inapplicable', 'earl:info': 'Not found.' };
testResults['receiver']['testReceiverGetLDPConstrainedBy'] = { 'earl:outcome': 'earl:inapplicable', 'earl:info': 'Not found.' };
if('type' in linkHeaders && (linkHeaders['type'].indexOf(vocab.ldpcontainer["@id"]) || linkHeaders['type'].indexOf(vocab.ldpbasiccontainer["@id"]))){
ldpContainerFound = true;
linkHeaders['type'].forEach(function(url){
if(url == vocab.ldpcontainer["@id"] || url == vocab.ldpbasiccontainer["@id"]) {
rdftypes.push('<a href="' + url + '">' + url + '</a>');
}
});
testResults['receiver']['testReceiverGetLDPContainer'] = { 'earl:outcome': 'earl:passed', 'earl:info': 'Found in <code>Link</code> header: ' + rdftypes.join(', ') };
}
if (vocab['ldpconstrainedBy']['@id'] in linkHeaders && linkHeaders[vocab['ldpconstrainedBy']['@id']].length > 0) {
var constrainedBys = [];
linkHeaders[vocab['ldpconstrainedBy']['@id']].forEach(function(url){
constrainedBys.push('<a href="' + url + '">' + url + '</a>');
});
testResults['receiver']['testReceiverGetLDPConstrainedBy'] = { 'earl:outcome': 'earl:passed', 'earl:info': 'Found: ' + constrainedBys.join(', ') };
}
var data = response.xhr.responseText;
try {
JSON.parse(data);
}
catch(e){
testResults['receiver']['testReceiverGetResponse'] = { 'earl:outcome': 'earl:failed', 'earl:info': '<code>HTTP '+ response.xhr.status + '</code> received but it had an empty body (invalid JSON-LD). Consider returning <code>HTTP 200</code> with <code>{ "@id": "", "http://www.w3.org/ns/ldp#contains": [] }</code>, or an <code>HTTP 4xx</code> if that was the real intention, and check the checkbox for <q>Receiver should reject this notification</q> in the test form.' };
return Promise.resolve(testResults);
}
var contentType = response.xhr.getResponseHeader('Content-Type') || undefined;
// console.log(contentType);
if(typeof contentType == undefined){
testResults['receiver']['testReceiverGetResponse'] = { 'earl:outcome': 'earl:failed', 'earl:info': 'No <code>Content-Type</code>. Inbox can not be parsed as <code>' + headers['Accept'] + '</code>.' };
return Promise.resolve(testResults);
}
else if(contentType.split(';')[0].trim() != headers['Accept']) {
testResults['receiver']['testReceiverGetResponse'] = { 'earl:outcome': 'earl:failed', 'earl:info': '<code>Content-Type: ' + contentType + '</code> returned. Inbox can not be parsed as <code>' + headers['Accept'] + '</code>.'};
return Promise.resolve(testResults);
}
else {
testResults['receiver']['testReceiverGetResponse'] = { 'earl:outcome': 'earl:passed', 'earl:info': '' };
var options = {
'contentType': 'application/ld+json',
'subjectURI': url
}
// console.log(data);
// console.log(options);
return getGraphFromData(data, options).then(
function(g) {
var s = SimpleRDF(vocab, options['subjectURI'], g, RDFstore).child(options['subjectURI']);
// console.log(s.iri().toString());
//These checks are extra, not required by the specification
var types = s.rdftype;
var resourceTypes = [];
types._array.forEach(function(type){
resourceTypes.push(type);
});
if(!ldpContainerFound) {
rdfTypes = [];
if(resourceTypes.indexOf(vocab.ldpcontainer["@id"]) > -1 || resourceTypes.indexOf(vocab.ldpbasiccontainer["@id"]) > -1) {
resourceTypes.forEach(function(url){
if(url == vocab.ldpcontainer["@id"] || url == vocab.ldpbasiccontainer["@id"]) {
rdftypes.push('<a href="' + url + '">' + url + '</a>');
}
});
testResults['receiver']['testReceiverGetLDPContainer'] = { 'earl:outcome': 'earl:passed', 'earl:info': 'Found in body: ' + rdftypes.join(', ') };
}
}
var notifications = [];
s.ldpcontains.forEach(function(resource) {
notifications.push(resource.toString());
});
if(notifications.length > 0) {
var notificationsNoun = (notifications.length == 1) ? 'notification' : 'notifications';
testResults['receiver']['testReceiverGetLDPContains'] = { 'earl:outcome': 'earl:passed', 'earl:info': 'Found ' + notifications.length + ' ' + notificationsNoun + '.' };
var testAccepts = ['application/ld+json', '*/*', ''];
var notificationResponses = [];
var getSerialize = function(url, acceptValue) {
return new Promise(function(resolve, reject) {
var http = new XMLHttpRequest();
http.open('GET', url);
if(acceptValue.length > 0){
http.setRequestHeader('Accept', acceptValue);
}
http.onreadystatechange = function() {
if(this.readyState == this.DONE) {
var anchor = '<a href="' + url + '">' + url + '</a>';
switch(this.status){
default:
resolve({ 'url': url, 'Accept': acceptValue, 'Content-Type': cT, 'earl:outcome': 'earl:failed', 'earl:info': anchor + ': HTTP status ' + this.status });
break;
case 401: case 403:
resolve({ 'url': url, 'Accept': acceptValue, 'Content-Type': cT, 'earl:outcome': 'earl:untested', 'earl:info': anchor + ': HTTP status ' + this.status });
break;
case 200:
var data = this.responseText;
var cT = this.getResponseHeader('Content-Type');
if(typeof cT === 'undefined' || !cT) {
resolve({ 'url': url, 'Accept': acceptValue, 'Content-Type': cT, 'earl:outcome': 'earl:failed', 'earl:info': '<code>Content-Type</code> is missing or empty.' });
return;
}
var contentType = cT.split(';')[0].trim();
if(acceptValue == 'application/ld+json' && contentType != 'application/ld+json') {
resolve({ 'url': url, 'Accept': acceptValue, 'Content-Type': cT, 'earl:outcome': 'earl:failed', 'earl:info': anchor + ': <code>Accept: ' + acceptValue + '</code> != <code>Content-Type: ' + cT + '</code>' });
}
else {
var options = { 'subjectURI': '_:ldn' }
var codeAccept = (acceptValue == '') ? 'No <code>Accept</code>' : '<code>Accept: ' + acceptValue + '</code>';
serializeData(data, contentType, 'application/ld+json', options).then(
function(i){
resolve({ 'url': url, 'Accept': acceptValue, 'Content-Type': cT, 'earl:outcome': 'earl:passed', 'earl:info': anchor + ': ' + codeAccept + ' => <code>Content-Type: ' + cT + '</code> <em>can</em> be serialized as JSON-LD' });
},
function(reason){
resolve({ 'url': url, 'Accept': acceptValue, 'Content-Type': cT, 'earl:outcome': 'earl:failed', 'earl:info': anchor + ': ' + codeAccept + ' => <code>Content-Type: ' + cT + '</code> <em>can not</em> be serialized as JSON-LD' });
}
);
}
break;
}
}
};
http.send();
});
}
notifications.forEach(function(url){
testAccepts.forEach(function(acceptValue){
notificationResponses.push(getSerialize(url, acceptValue));
});
});
return Promise.all(notificationResponses)
.then((results) => {
// console.log(results);
var notificationState = [];
var notificationStateJSONLD = [];
var notificationStateRDFSource = [];
var codeJSONLD = 'earl:passed';
var codeRDFSource = 'earl:passed';
results.forEach(function(r){
if(r['Accept'] == 'application/ld+json'){
if (r['earl:outcome'] == 'earl:failed') { codeJSONLD = 'earl:failed'; }
notificationStateJSONLD.push(r['earl:info']);
}
else {
if (r['earl:outcome'] == 'earl:failed') { codeRDFSource = 'earl:failed'; }
notificationStateRDFSource.push(r['earl:info']);
}
notificationState.push(r['earl:info']);
});
notificationStateJSONLD = notificationStateJSONLD.join(', ');
notificationStateRDFSource = notificationStateRDFSource.join(', ');
testResults['receiver']['testReceiverGetNotificationsJSONLD'] = { 'earl:outcome': codeJSONLD, 'earl:info': notificationStateJSONLD };
testResults['receiver']['testReceiverGetNotificationsRDFSource'] = { 'earl:outcome': codeRDFSource, 'earl:info': notificationStateRDFSource };
return Promise.resolve(testResults);
})
.catch((e) => {
console.log('--- catch: notificationResponses ---');
console.log(e);
});
}
else {
testResults['receiver']['testReceiverGetLDPContains'] = { 'earl:outcome': 'earl:inapplicable', 'earl:info': 'Did not find <code>ldp:contains</code>. It may be because there are no notifications (yet or available?). Doublecheck: <samp>inboxURL ldp:contains notificationURL</samp> exists' };
return Promise.resolve(testResults);
}
},
function(reason){
// console.log(reason);
testResults['receiver']['testReceiverGetResponse'] = { 'earl:outcome': 'earl:failed', 'earl:info': 'Inbox can not be parsed as <code>' + headers['Accept'] + '</code>.' };
return Promise.resolve(testResults);
});
}
},
function(reason){
// console.log(reason);
testResults['receiver']['testReceiverGetResponse'] = { 'earl:outcome': 'earl:failed', 'earl:info': '<code>HTTP '+ reason.xhr.status + '</code>, <code>Content-Type: ' + reason.xhr.getResponseHeader('Content-Type') + '</code>' };
return Promise.resolve(testResults);
});
}
function testReceiverPostResponse(req){
var testResults = { 'receiver': {} };
var headers = {};
var url = req.body['test-receiver-url'];
headers['Content-Type'] = 'application/ld+json; profile="http://example.org/profile"; charset=utf-8';
headers['Slug'] = uuid.v1() + '.jsonld';
var data = ('test-receiver-data' in req.body && req.body['test-receiver-data'].length > 0) ? req.body['test-receiver-data'] : '';
// console.log('testReceiverGet: ' + url);
return postResource(url, headers['Slug'], data, headers['Content-Type']).then(
function(response){
// console.log(response);
// POST requests are supported, with and without profiles
var status = '<code>HTTP ' + response.xhr.status + '</code>';
testResults['receiver']['testReceiverPostResponse'] = { 'earl:outcome': 'earl:passed', 'earl:info': status };
testResults['receiver']['testReceiverPostLinkProfile'] = { 'earl:outcome': 'earl:passed', 'earl:info': '' };
testResults['receiver']['testReceiverPostResponseConstraintsUnmet'] = { 'earl:outcome': 'earl:inapplicable', 'earl:info': '' };
// If 201 or 202
if(response.xhr.status == 201 || response.xhr.status == 202) {
// If 'reject' was ticked, creating was wrong, fail
if('test-receiver-reject' in req.body){
testResults['receiver']['testReceiverPostCreated'] = { 'earl:outcome' : 'earl:failed', 'earl:info' : 'Payload did not meet constraints, but the receiver indicated success (' + status + ')' };
testResults['receiver']['testReceiverPostResponseConstraintsUnmet'] = { 'earl:outcome': 'earl:failed', 'earl:info': '' };
return Promise.resolve(testResults);
// Otherwise, pass
}
else{
testResults['receiver']['testReceiverPostCreated'] = { 'earl:outcome': 'earl:passed', 'earl:info': status };
var location = response.xhr.getResponseHeader('Location');
// If 201, check Location header
if(response.xhr.status == 201){
if(location){
var url = location;
if(location.toLowerCase().slice(0,4) != 'http') {
//TODO: baseURL for response.xhr.getResponseHeader('Location') .. check response.responseURL?
url = response.xhr._url.href + location;
if(location[0] == '/'){
var port = (response.xhr._url.port) ? ':' + response.xhr._url.port : '';
url = response.xhr._url.protocol + '//' + response.xhr._url.hostname + port + location;
}
}
var headers = {};
headers['Accept'] = 'application/ld+json';
return getResource(url, headers).then(
//Maybe use checkPostLocationRetrieveable
function(i){
// console.log(i);
testResults['receiver']['testReceiverPostLocation'] = { 'earl:outcome': 'earl:passed', 'earl:info': '<code>Location</code>: <a href="' + url + '">' + url + '</a> found and can be retrieved.' };
return Promise.resolve(testResults);
},
function(j){
// console.log(j);
testResults['receiver']['testReceiverPostLocation'] = { 'earl:outcome': 'earl:failed', 'earl:info': '<code>Location</code>: <a href="' + url + '">' + url + '</a> found but can not be retrieved: <code>HTTP ' + j.xhr.status + '</code> <q>' + j.xhr.responseText + '</q>' };
return Promise.resolve(testResults);
});
}
else {
testResults['receiver']['testReceiverPostLocation'] = { 'earl:outcome': 'earl:failed', 'earl:info': '<code>Location</code> header not found.' };
return Promise.resolve(testResults);
}
}
else {
var url = '';
if(location){
url = '<code>Location</code>: <a href="' + url + '">' + url + '</a> found.';
}
testResults['receiver']['testReceiverPostLocation'] = { 'earl:outcome': 'earl:inapplicable', 'earl:info': url };
return Promise.resolve(testResults);
}
}
}
else {
testResults['receiver']['testReceiverPostResponse'] = { 'earl:outcome': 'earl:failed', 'earl:info': 'Response was <code>HTTP ' + response.xhr.status + '</code>. Should return <code>HTTP 201</code>.'};
return Promise.resolve(testResults);
}
},
function(reason){
// console.log(reason);
var status = '<code>HTTP ' + reason.xhr.status + '</code>';
var responseText = (reason.xhr.responseText.length > 0 ) ? ', <q>' + reason.xhr.responseText + '</q>' : '';
testResults['receiver']['testReceiverPostResponse'] = { 'earl:outcome': 'earl:failed', 'earl:info': status + responseText };
switch(reason.xhr.status){
case 400:
if('test-receiver-reject' in req.body) {
testResults['receiver']['testReceiverPostResponse'] = { 'earl:outcome': 'earl:passed', 'earl:info': 'Deliberately rejected (' + status + ')' };
testResults['receiver']['testReceiverPostResponseConstraintsUnmet'] = { 'earl:outcome': 'earl:passed', 'earl:info': 'Payload successfully filtered out (' + status + ')' };
}
//TODO: Maybe handle other formats here
if(headers['Content-Type'] == 'application/ld+json'){ //TODO: && payload format is valid
testResults['receiver']['testReceiverPostCreated'] = { 'earl:outcome': 'earl:failed', 'earl:info': '<em class="rfc2119">MUST</em> accept notifications where the request body is JSON-LD, with the <code>Content-Type: application/ld+json</code>' };
}
break;
case 405:
testResults['receiver']['testReceiverPostResponse'] = { 'earl:outcome': 'earl:failed', 'earl:info': '<em class="rfc2119">MUST</em> support <code>POST</code> request on the Inbox URL.' };
break;
case 415:
if('test-receiver-reject' in req.body) {
testResults['receiver']['testReceiverPostResponse'] = { 'earl:outcome': 'earl:passed', 'earl:info': status + '. Request with <code>Content-Type: ' + headers['Content-Type'] + '</code> has been rejected.' };
}
else {
testResults['receiver']['testReceiverPostResponse'] = { 'earl:outcome': 'earl:failed', 'earl:info': status + '. Request with <code>Content-Type: ' + headers['Content-Type'] + '</code> is not allowed, or the payload does not correspond to this content-type. Check the payload syntax is valid, and make sure that the receiver is not having trouble with the <code>profile</code> or <code>charset</code> parameter.</code>.' };
}
testResults['receiver']['testReceiverPostLinkProfile'] = { 'earl:outcome': 'earl:inapplicable', 'earl:info': 'The request was possibly rejected due to the <q>profile</q> Link Relation. If the mediatype is recognised, it may be better to accept the request by ignoring the profile parameter.' };
break;
default:
testResults['receiver']['testReceiverPostResponse'] = { 'earl:outcome': 'earl:failed', 'earl:info': status + responseText};
break;
}
return Promise.resolve(testResults);
});
}
function getRequirementLevelCode(level) {
var s = level;
switch(level) {
default: s = outcome; break;
case 'MUST': s = '!'; break;
case 'SHOULD': s = '^'; break;
case 'MAY': s = '~'; break;
}
return s;
}
function getRequirementLevelURL(level) {
var s = level;
switch(level) {
default: s = outcome; break;
case 'MUST': s = 'https://tools.ietf.org/html/rfc2119#section-1'; break;
case 'SHOULD': s = 'https://tools.ietf.org/html/rfc2119#section-3'; break;
case 'MAY': s = 'https://tools.ietf.org/html/rfc2119#section-5'; break;
}
return s;
}
function getEarlOutcomeCode(outcome){
var s = outcome;
switch(outcome) {
default: s = outcome; break;
case 'earl:passed': s = '✔'; break;
case 'earl:failed': s = '✗'; break;
case 'earl:cantTell': s = '?'; break;
case 'earl:inapplicable': s = '⌙'; break;
case 'earl:untested': s = '○'; break;
}
return s;
}
function getEarlOutcomeHTML(){
return `
<dl>
<dt class="earl:passed"><abbr title="Passed">${getEarlOutcomeCode('earl:passed')}</abbr></dt><dd><a href="https://www.w3.org/TR/EARL10-Schema/#passed">Passed</a></dd>
<dt class="earl:failed"><abbr title="Failed">${getEarlOutcomeCode('earl:failed')}</abbr></dt><dd><a href="https://www.w3.org/TR/EARL10-Schema/#failed">Failed</a></dd>
<dt class="earl:cantTell"><abbr title="Cannot tell">${getEarlOutcomeCode('earl:cantTell')}</abbr></dt><dd><a href="https://www.w3.org/TR/EARL10-Schema/#cantTell">Cannot tell</a></dd>
<dt class="earl:inapplicable"><abbr title="Inapplicable">${getEarlOutcomeCode('earl:inapplicable')}</abbr></dt><dd><a href="https://www.w3.org/TR/EARL10-Schema/#inapplicable">Inapplicable</a></dd>
<dt class="earl:untested"><abbr title="Untested">${getEarlOutcomeCode('earl:untested')}</abbr></dt><dd><a href="https://www.w3.org/TR/EARL10-Schema/#untested">Untested</a></dd>
</dl>`;
}
function getTestReportHTML(test, implementation){
var s = [];
implementation = implementation || 'receiver';
Object.keys(ldnTests[implementation]).forEach(function(id){
var testResult = '';
if(typeof test[id] == 'undefined'){
test[id] = { 'earl:outcome': 'earl:untested', 'earl:info': '' };
}
testResult = getEarlOutcomeCode(test[id]['earl:outcome']);
s.push('<tr><td class="' + test[id]['earl:outcome'] + '">' + testResult + '</td><td class="test-description">' + ldnTests[implementation][id]['description'] + '</td><td class="test-message">' + test[id]['earl:info'] + '</td></tr>');
});
return s.join("\n");
}
function testResponse(req, test, reportHTML){
var sendReportURL = req.getRootUrl() + '/send-report';
return `
<div id="test-response">
<table id="test-report">
<caption>Test report</caption>
<thead><tr><th>Result</th><th>Test</th><th>Info</th></tr></thead>
<tfoot><tr><td colspan="4">
${getEarlOutcomeHTML()}
</td></tr></tfoot>
<tbody>
${reportHTML}
</tbody>
</table>
<form action="${sendReportURL}" class="form-tests" method="post">
<fieldset>
<legend>Send LDN ${test['implementationType']} report</legend>
<ul>
<li>
<label for="implementation">Implementation</label>
<input type="text" name="implementation" value="" placeholder="URI of the project/implementation." /> (required)
</li>
<li>
<label for="name">Implementation name</label>
<input type="text" name="name" value="" placeholder="Name of the project/implementation." /> (required)
</li>
<li>
<label for="maintainer">Maintainer</label>
<input type="text" name="maintainer" value="" placeholder="URI of the maintainer, project leader, or organisation." /> (required)
</li>
<li>
<label for="note">Note</label>
<textarea name="note" cols="80" rows="2" placeholder="Enter anything you would like to mention."></textarea>
</li>
</ul>
<input type="hidden" name="test-report-value" value="${btoa(JSON.stringify(test))}" />
<input type="submit" value="Send Report" />
</fieldset>
</form>
</div>`;
}
function getTestReceiverHTML(req, results){
// var selectedOption = (request && request['test-receiver-method']) ? request['test-receiver-method'] : '';
// var receiverMethodOptionsHTML = getSelectOptionsHTML(['GET', 'HEAD', 'OPTIONS', 'POST'], selectedOption);
// selectedOption = (request && request['test-receiver-mimetype']) ? request['test-receiver-mimetype'] : '';
// var receiverMimetypeOptionsHTML = getSelectOptionsHTML(['application/ld+json', 'text/turtle'], selectedOption);
var testsList = '';
Object.keys(ldnTests['receiver']).forEach(function(t) {
testsList += '<li id="'+t+'" about="#'+t+'" typeof="earl:TestCriterion" property="schema:description">'+ldnTests['receiver'][t]['description']+'</li>\n';
});
return `<!DOCTYPE html>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>LDN Tests for Receivers</title>
<meta content="width=device-width, initial-scale=1" name="viewport" />
<link href="${req.getRootUrl()}/media/css/ldntests.css" media="all" rel="stylesheet" />
</head>
<body about="" prefix="${prefixesRDFa}" typeof="schema:CreativeWork sioc:Post prov:Entity">
<main>
<article about="" typeof="schema:Article">
<h1 property="schema:name">LDN Tests for Receivers</h1>
<div id="content">
<section id="receiver" inlist="" rel="schema:hasPart" resource="#receiver">
<h2 property="schema:name">Receiver</h2>
<div datatype="rdf:HTML" property="schema:description">
<p>This form is to test implementations of LDN receivers. Input the URL of an Inbox, and when you submit, it fires off several HTTP requests with the various combinations of parameters and headers that you are required to support in order for senders to create new notifications and consumers to retreive them.</p>
<p>We provide a default notification payload, but if you have a specilised implementation you may want to modify this to your needs.</p>
<p>If your receiver is setup to reject certain payloads (LDN suggests you implement some kinds of constraints or filtering), you can input one such payload and check the <q>Receiver should reject this notification</q> box. If your receiver rejects the POST requests, you will <em>pass</em> the relevant tests.</p>
<p>Reports will be submitted to an <a about="" rel="ldp:inbox" href="reports/">inbox</a>.</p>
<form action="#test-response" class="form-tests" id="test-receiver" method="post">
<fieldset>
<legend>Test Receiver</legend>
<ul>
<li>