@@ -66,7 +66,8 @@ self.testURL = function(url, type, serverType, context) {
66
66
} ;
67
67
68
68
/**
69
- * Invoked when the fetch has completed.
69
+ * Invoked when the fetch has completed. This tests an HTTP response (ie headers
70
+ * and body)
70
71
* @param {Response } response
71
72
*/
72
73
self . testResponse = function ( response ) {
@@ -118,6 +119,10 @@ self.testResponse = function(response) {
118
119
) ;
119
120
} ;
120
121
122
+ /**
123
+ * This is called by testResponse() and validates the JSON body of the response.
124
+ * @param json
125
+ */
121
126
self . validateResponse = function ( json ) {
122
127
123
128
self . path = [ "$" ] ;
@@ -689,6 +694,12 @@ self.validateJCardPropertyType = function(property) {
689
694
"section-3.3" ,
690
695
) ) return ;
691
696
697
+ self . add (
698
+ property [ 0 ] === property [ 0 ] . toLowerCase ( ) ,
699
+ `Property name '${ property [ 0 ] } ' MUST be in lowercase.` ,
700
+ "section-3.3" ,
701
+ ) ;
702
+
692
703
if ( "rir" == self . lastTestedServerType ) {
693
704
self . pushSpec ( "nro" ) ;
694
705
@@ -713,11 +724,17 @@ self.validateJCardPropertyType = function(property) {
713
724
* Validate a JCard property parameter object.
714
725
*/
715
726
self . validateJCardPropertyParameters = function ( property ) {
716
- self . add (
727
+ if ( self . add (
717
728
self . isObject ( property [ 1 ] ) ,
718
729
"Item #2 of a jCard property MUST be an object." ,
719
730
"section-3.3" ,
720
- ) ;
731
+ ) ) {
732
+ self . add (
733
+ Object . keys ( property [ 1 ] ) . length == Object . keys ( property [ 1 ] ) . filter ( n => n === n . toLowerCase ( ) ) . length ,
734
+ "jCard parameter names MUST be lowercase." ,
735
+ "section-3.4"
736
+ )
737
+ }
721
738
} ;
722
739
723
740
/**
@@ -2492,7 +2509,9 @@ self.isULabel = function(label) {
2492
2509
2493
2510
/**
2494
2511
* This stores the JSONPath query that identifies the value in the response that
2495
- * is currently being validated.
2512
+ * is currently being validated. When add() is called, the a JSON Path
2513
+ * expression is generated using this stack, so the specific component of the
2514
+ * JSON response can be associated with the message.
2496
2515
*/
2497
2516
self . path = [ ] ;
2498
2517
@@ -2518,7 +2537,9 @@ self.popPath = function(last) {
2518
2537
2519
2538
/**
2520
2539
* This keeps track of the specification document that the response is being
2521
- * validated against.
2540
+ * validated against. when add() is called, the topmost entry in the stack is
2541
+ * copied into the message, so the message can be associated with a particular
2542
+ * specification (RFC, etc).
2522
2543
*/
2523
2544
self . specStack = [ ] ;
2524
2545
0 commit comments