|
50 | 50 | # Special values (like inf/nan) should be rejected. Note that these values are
|
51 | 51 | # not technically valid JSON, but extensions that some programming languages
|
52 | 52 | # support automatically.
|
| 53 | +# |
| 54 | +# Note that these tests don't explictely check for M_BAD_JSON since the |
| 55 | +# homeserver's parser might not even be able to parse the string. |
53 | 56 | test "Invalid JSON special values",
|
54 | 57 | requires => [ local_user_and_room_fixtures(
|
55 | 58 | room_opts => { room_version => "6" }
|
|
69 | 72 | msgtype => "sytest.dummy",
|
70 | 73 | body => "NaN" + 0,
|
71 | 74 | },
|
72 |
| - )->main::expect_bad_json, |
| 75 | + )->main::expect_http_400, |
73 | 76 |
|
74 | 77 | do_request_json_for( $user,
|
75 | 78 | method => "POST",
|
|
78 | 81 | msgtype => "sytest.dummy",
|
79 | 82 | body => "inf" + 0,
|
80 | 83 | },
|
81 |
| - )->main::expect_bad_json, |
| 84 | + )->main::expect_http_400, |
82 | 85 |
|
83 | 86 | do_request_json_for( $user,
|
84 | 87 | method => "POST",
|
|
87 | 90 | msgtype => "sytest.dummy",
|
88 | 91 | body => "-inf" + 0,
|
89 | 92 | },
|
90 |
| - )->main::expect_bad_json, |
| 93 | + )->main::expect_http_400, |
91 | 94 |
|
92 | 95 | # Try some Python magic values.
|
93 | 96 | $user->http->do_request(
|
|
98 | 101 | },
|
99 | 102 | content => '{"msgtype": "sytest.dummy", "body": Infinity}',
|
100 | 103 | content_type => "application/json",
|
101 |
| - )->main::expect_bad_json, |
| 104 | + )->main::expect_http_400, |
102 | 105 |
|
103 | 106 | $user->http->do_request(
|
104 | 107 | method => "POST",
|
|
108 | 111 | },
|
109 | 112 | content => '{"msgtype": "sytest.dummy", "body": -Infinity}',
|
110 | 113 | content_type => "application/json",
|
111 |
| - )->main::expect_bad_json, |
| 114 | + )->main::expect_http_400, |
112 | 115 |
|
113 | 116 | $user->http->do_request(
|
114 | 117 | method => "POST",
|
|
118 | 121 | },
|
119 | 122 | content => '{"msgtype": "sytest.dummy", "body": NaN}',
|
120 | 123 | content_type => "application/json",
|
121 |
| - )->main::expect_bad_json, |
| 124 | + )->main::expect_http_400, |
122 | 125 | );
|
123 | 126 | };
|
0 commit comments