bson 4.1.1 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +106 -7
- data/Rakefile +86 -43
- data/ext/bson/{native-endian.h → bson-endian.h} +14 -107
- data/ext/bson/bson-native.h +135 -0
- data/ext/bson/bytebuf.c +133 -0
- data/ext/bson/endian.c +117 -0
- data/ext/bson/extconf.rb +8 -3
- data/ext/bson/init.c +364 -0
- data/ext/bson/libbson-utf8.c +230 -0
- data/ext/bson/read.c +470 -0
- data/ext/bson/util.c +250 -0
- data/ext/bson/write.c +675 -0
- data/lib/bson/active_support.rb +19 -0
- data/lib/bson/array.rb +97 -30
- data/lib/bson/big_decimal.rb +77 -0
- data/lib/bson/binary.rb +510 -70
- data/lib/bson/boolean.rb +15 -4
- data/lib/bson/code.rb +25 -12
- data/lib/bson/code_with_scope.rb +41 -15
- data/lib/bson/config.rb +3 -28
- data/lib/bson/date.rb +16 -4
- data/lib/bson/date_time.rb +6 -4
- data/lib/bson/db_pointer.rb +110 -0
- data/lib/bson/dbref.rb +154 -0
- data/lib/bson/decimal128/builder.rb +456 -0
- data/lib/bson/decimal128.rb +272 -0
- data/lib/bson/document.rb +177 -7
- data/lib/bson/environment.rb +17 -2
- data/lib/bson/error/bson_decode_error.rb +11 -0
- data/lib/bson/error/ext_json_parse_error.rb +11 -0
- data/lib/bson/error/illegal_key.rb +23 -0
- data/lib/bson/error/invalid_binary_type.rb +37 -0
- data/lib/bson/error/invalid_dbref_argument.rb +12 -0
- data/lib/bson/error/invalid_decimal128_argument.rb +25 -0
- data/lib/bson/error/invalid_decimal128_range.rb +27 -0
- data/lib/bson/error/invalid_decimal128_string.rb +26 -0
- data/lib/bson/error/invalid_key.rb +24 -0
- data/lib/bson/error/invalid_object_id.rb +11 -0
- data/lib/bson/error/invalid_regexp_pattern.rb +13 -0
- data/lib/bson/error/unrepresentable_precision.rb +19 -0
- data/lib/bson/error/unserializable_class.rb +13 -0
- data/lib/bson/error/unsupported_binary_subtype.rb +12 -0
- data/lib/bson/error/unsupported_type.rb +11 -0
- data/lib/bson/error.rb +22 -0
- data/lib/bson/ext_json.rb +389 -0
- data/lib/bson/false_class.rb +6 -4
- data/lib/bson/float.rb +43 -7
- data/lib/bson/hash.rb +152 -37
- data/lib/bson/int32.rb +104 -6
- data/lib/bson/int64.rb +111 -8
- data/lib/bson/integer.rb +43 -9
- data/lib/bson/json.rb +3 -1
- data/lib/bson/max_key.rb +21 -10
- data/lib/bson/min_key.rb +21 -10
- data/lib/bson/nil_class.rb +7 -3
- data/lib/bson/object.rb +25 -17
- data/lib/bson/object_id.rb +98 -113
- data/lib/bson/open_struct.rb +59 -0
- data/lib/bson/regexp.rb +129 -56
- data/lib/bson/registry.rb +7 -10
- data/lib/bson/specialized.rb +8 -4
- data/lib/bson/string.rb +12 -32
- data/lib/bson/symbol.rb +107 -11
- data/lib/bson/time.rb +68 -7
- data/lib/bson/time_with_zone.rb +67 -0
- data/lib/bson/timestamp.rb +50 -10
- data/lib/bson/true_class.rb +6 -4
- data/lib/bson/undefined.rb +28 -2
- data/lib/bson/vector.rb +44 -0
- data/lib/bson/version.rb +6 -14
- data/lib/bson.rb +22 -12
- data/spec/README.md +14 -0
- data/spec/bson/array_spec.rb +38 -62
- data/spec/bson/big_decimal_spec.rb +328 -0
- data/spec/bson/binary_spec.rb +199 -53
- data/spec/bson/binary_uuid_spec.rb +190 -0
- data/spec/bson/boolean_spec.rb +2 -1
- data/spec/bson/byte_buffer_read_spec.rb +198 -0
- data/spec/bson/byte_buffer_spec.rb +122 -381
- data/spec/bson/byte_buffer_write_spec.rb +855 -0
- data/spec/bson/code_spec.rb +6 -4
- data/spec/bson/code_with_scope_spec.rb +6 -4
- data/spec/bson/config_spec.rb +1 -35
- data/spec/bson/date_spec.rb +2 -1
- data/spec/bson/date_time_spec.rb +55 -1
- data/spec/bson/dbref_legacy_spec.rb +186 -0
- data/spec/bson/dbref_spec.rb +487 -0
- data/spec/bson/decimal128_spec.rb +1840 -0
- data/spec/bson/document_as_spec.rb +61 -0
- data/spec/bson/document_spec.rb +205 -32
- data/spec/bson/ext_json_parse_spec.rb +346 -0
- data/spec/bson/false_class_spec.rb +9 -1
- data/spec/bson/float_spec.rb +42 -1
- data/spec/bson/hash_as_spec.rb +58 -0
- data/spec/bson/hash_spec.rb +318 -66
- data/spec/bson/int32_spec.rb +248 -1
- data/spec/bson/int64_spec.rb +308 -1
- data/spec/bson/integer_spec.rb +61 -3
- data/spec/bson/json_spec.rb +2 -1
- data/spec/bson/max_key_spec.rb +6 -4
- data/spec/bson/min_key_spec.rb +6 -4
- data/spec/bson/nil_class_spec.rb +2 -1
- data/spec/bson/object_id_spec.rb +95 -5
- data/spec/bson/object_spec.rb +3 -2
- data/spec/bson/open_struct_spec.rb +87 -0
- data/spec/bson/raw_spec.rb +594 -0
- data/spec/bson/regexp_spec.rb +61 -8
- data/spec/bson/registry_spec.rb +3 -2
- data/spec/bson/string_spec.rb +26 -33
- data/spec/bson/symbol_raw_spec.rb +70 -0
- data/spec/bson/symbol_spec.rb +77 -20
- data/spec/bson/time_spec.rb +206 -2
- data/spec/bson/time_with_zone_spec.rb +69 -0
- data/spec/bson/timestamp_spec.rb +58 -2
- data/spec/bson/true_class_spec.rb +9 -1
- data/spec/bson/undefined_spec.rb +28 -1
- data/spec/bson/vector_spec.rb +33 -0
- data/spec/bson_spec.rb +2 -1
- data/spec/runners/binary_vector.rb +78 -0
- data/spec/runners/common_driver.rb +348 -0
- data/spec/runners/corpus.rb +191 -0
- data/spec/runners/corpus_legacy.rb +248 -0
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/bin/get-mongodb-download-url +17 -0
- data/spec/shared/bin/s3-copy +45 -0
- data/spec/shared/bin/s3-upload +69 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/cluster_config.rb +231 -0
- data/spec/shared/lib/mrss/constraints.rb +378 -0
- data/spec/shared/lib/mrss/docker_runner.rb +298 -0
- data/spec/shared/lib/mrss/eg_config_utils.rb +51 -0
- data/spec/shared/lib/mrss/event_subscriber.rb +210 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +238 -0
- data/spec/shared/lib/mrss/release/candidate.rb +281 -0
- data/spec/shared/lib/mrss/release/product_data.rb +144 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +113 -0
- data/spec/shared/lib/mrss/session_registry.rb +69 -0
- data/spec/shared/lib/mrss/session_registry_legacy.rb +60 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +179 -0
- data/spec/shared/lib/mrss/utils.rb +37 -0
- data/spec/shared/lib/tasks/candidate.rake +64 -0
- data/spec/shared/share/Dockerfile.erb +251 -0
- data/spec/shared/share/haproxy-1.conf +16 -0
- data/spec/shared/share/haproxy-2.conf +17 -0
- data/spec/shared/shlib/config.sh +27 -0
- data/spec/shared/shlib/distro.sh +84 -0
- data/spec/shared/shlib/server.sh +423 -0
- data/spec/shared/shlib/set_env.sh +110 -0
- data/spec/spec_helper.rb +61 -1
- data/spec/spec_tests/binary_vector_spec.rb +82 -0
- data/spec/spec_tests/common_driver_spec.rb +84 -0
- data/spec/spec_tests/corpus_legacy_spec.rb +72 -0
- data/spec/spec_tests/corpus_spec.rb +134 -0
- data/spec/spec_tests/data/binary_vector/README.md +61 -0
- data/spec/spec_tests/data/binary_vector/float32.json +65 -0
- data/spec/spec_tests/data/binary_vector/int8.json +57 -0
- data/spec/spec_tests/data/binary_vector/packed_bit.json +83 -0
- data/spec/spec_tests/data/corpus/README.md +15 -0
- data/spec/spec_tests/data/corpus/array.json +49 -0
- data/spec/spec_tests/data/corpus/binary.json +153 -0
- data/spec/spec_tests/data/corpus/boolean.json +27 -0
- data/spec/spec_tests/data/corpus/code.json +67 -0
- data/spec/spec_tests/data/corpus/code_w_scope.json +78 -0
- data/spec/spec_tests/data/corpus/datetime.json +42 -0
- data/spec/spec_tests/data/corpus/dbpointer.json +56 -0
- data/spec/spec_tests/data/corpus/dbref.json +51 -0
- data/spec/spec_tests/data/corpus/decimal128-1.json +317 -0
- data/spec/spec_tests/data/corpus/decimal128-2.json +793 -0
- data/spec/spec_tests/data/corpus/decimal128-3.json +1771 -0
- data/spec/spec_tests/data/corpus/decimal128-4.json +165 -0
- data/spec/spec_tests/data/corpus/decimal128-5.json +402 -0
- data/spec/spec_tests/data/corpus/decimal128-6.json +131 -0
- data/spec/spec_tests/data/corpus/decimal128-7.json +327 -0
- data/spec/spec_tests/data/corpus/document.json +60 -0
- data/spec/spec_tests/data/corpus/double.json +87 -0
- data/spec/spec_tests/data/corpus/int32.json +43 -0
- data/spec/spec_tests/data/corpus/int64.json +43 -0
- data/spec/spec_tests/data/corpus/maxkey.json +12 -0
- data/spec/spec_tests/data/corpus/minkey.json +12 -0
- data/spec/spec_tests/data/corpus/multi-type-deprecated.json +15 -0
- data/spec/spec_tests/data/corpus/multi-type.json +11 -0
- data/spec/spec_tests/data/corpus/null.json +12 -0
- data/spec/spec_tests/data/corpus/oid.json +28 -0
- data/spec/spec_tests/data/corpus/regex.json +65 -0
- data/spec/spec_tests/data/corpus/string.json +72 -0
- data/spec/spec_tests/data/corpus/symbol.json +80 -0
- data/spec/spec_tests/data/corpus/timestamp.json +34 -0
- data/spec/spec_tests/data/corpus/top.json +262 -0
- data/spec/spec_tests/data/corpus/undefined.json +15 -0
- data/spec/spec_tests/data/corpus_legacy/array.json +49 -0
- data/spec/spec_tests/data/corpus_legacy/binary.json +69 -0
- data/spec/spec_tests/data/corpus_legacy/boolean.json +27 -0
- data/spec/spec_tests/data/corpus_legacy/code.json +67 -0
- data/spec/spec_tests/data/corpus_legacy/code_w_scope.json +78 -0
- data/spec/spec_tests/data/corpus_legacy/document.json +36 -0
- data/spec/spec_tests/data/corpus_legacy/double.json +69 -0
- data/spec/spec_tests/data/corpus_legacy/failures/datetime.json +31 -0
- data/spec/spec_tests/data/corpus_legacy/failures/dbpointer.json +42 -0
- data/spec/spec_tests/data/corpus_legacy/failures/int64.json +38 -0
- data/spec/spec_tests/data/corpus_legacy/failures/symbol.json +62 -0
- data/spec/spec_tests/data/corpus_legacy/int32.json +38 -0
- data/spec/spec_tests/data/corpus_legacy/maxkey.json +12 -0
- data/spec/spec_tests/data/corpus_legacy/minkey.json +12 -0
- data/spec/spec_tests/data/corpus_legacy/null.json +12 -0
- data/spec/spec_tests/data/corpus_legacy/oid.json +28 -0
- data/spec/spec_tests/data/corpus_legacy/regex.json +37 -0
- data/spec/spec_tests/data/corpus_legacy/string.json +67 -0
- data/spec/spec_tests/data/corpus_legacy/timestamp.json +18 -0
- data/spec/spec_tests/data/corpus_legacy/top.json +62 -0
- data/spec/spec_tests/data/corpus_legacy/undefined.json +13 -0
- data/spec/spec_tests/data/decimal128/decimal128-1.json +363 -0
- data/spec/spec_tests/data/decimal128/decimal128-2.json +793 -0
- data/spec/spec_tests/data/decimal128/decimal128-3.json +1771 -0
- data/spec/spec_tests/data/decimal128/decimal128-4.json +165 -0
- data/spec/spec_tests/data/decimal128/decimal128-5.json +402 -0
- data/spec/spec_tests/data/decimal128/decimal128-6.json +131 -0
- data/spec/spec_tests/data/decimal128/decimal128-7.json +327 -0
- data/spec/support/shared_examples.rb +32 -11
- data/spec/support/spec_config.rb +17 -0
- data/spec/support/utils.rb +58 -0
- metadata +284 -45
- checksums.yaml.gz.sig +0 -3
- data/ext/bson/native.c +0 -722
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Top-level document validity",
|
|
3
|
+
"bson_type": "0x00",
|
|
4
|
+
"valid": [
|
|
5
|
+
{
|
|
6
|
+
"description": "Dollar-prefixed key in top-level document",
|
|
7
|
+
"canonical_bson": "0F00000010246B6579002A00000000",
|
|
8
|
+
"canonical_extjson": "{\"$key\": {\"$numberInt\": \"42\"}}"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"description": "Dollar as key in top-level document",
|
|
12
|
+
"canonical_bson": "0E00000002240002000000610000",
|
|
13
|
+
"canonical_extjson": "{\"$\": \"a\"}"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"description": "Dotted key in top-level document",
|
|
17
|
+
"canonical_bson": "1000000002612E620002000000630000",
|
|
18
|
+
"canonical_extjson": "{\"a.b\": \"c\"}"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"description": "Dot as key in top-level document",
|
|
22
|
+
"canonical_bson": "0E000000022E0002000000610000",
|
|
23
|
+
"canonical_extjson": "{\".\": \"a\"}"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"decodeErrors": [
|
|
27
|
+
{
|
|
28
|
+
"description": "An object size that's too small to even include the object size, but is a well-formed, empty object",
|
|
29
|
+
"bson": "0100000000"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"description": "An object size that's only enough for the object size, but is a well-formed, empty object",
|
|
33
|
+
"bson": "0400000000"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"description": "One object, with length shorter than size (missing EOO)",
|
|
37
|
+
"bson": "05000000"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"description": "One object, sized correctly, with a spot for an EOO, but the EOO is 0x01",
|
|
41
|
+
"bson": "0500000001"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"description": "One object, sized correctly, with a spot for an EOO, but the EOO is 0xff",
|
|
45
|
+
"bson": "05000000FF"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"description": "One object, sized correctly, with a spot for an EOO, but the EOO is 0x70",
|
|
49
|
+
"bson": "0500000070"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"description": "Byte count is zero (with non-zero input length)",
|
|
53
|
+
"bson": "00000000000000000000"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"description": "Stated length exceeds byte count, with truncated document",
|
|
57
|
+
"bson": "1200000002666F6F0004000000626172"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"description": "Stated length exceeds byte count, with valid envelope",
|
|
61
|
+
"bson": "1300000002666F6F00040000006261720000"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"description": "Stated length less than byte count, with valid envelope",
|
|
65
|
+
"bson": "1100000002666F6F00040000006261720000"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"description": "Invalid BSON type low range",
|
|
69
|
+
"bson": "07000000000000"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"description": "Invalid BSON type high range",
|
|
73
|
+
"bson": "07000000800000"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"description": "Document truncated mid-key",
|
|
77
|
+
"bson": "1200000002666F"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"description": "Null byte in document key",
|
|
81
|
+
"bson": "0D000000107800000100000000"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"parseErrors": [
|
|
85
|
+
{
|
|
86
|
+
"description" : "Bad $regularExpression (extra field)",
|
|
87
|
+
"string" : "{\"a\" : {\"$regularExpression\": {\"pattern\": \"abc\", \"options\": \"\", \"unrelated\": true}}}"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"description" : "Bad $regularExpression (missing options field)",
|
|
91
|
+
"string" : "{\"a\" : {\"$regularExpression\": {\"pattern\": \"abc\"}}}"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"description": "Bad $regularExpression (pattern is number, not string)",
|
|
95
|
+
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": 42, \"options\" : \"\"}}}"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"description": "Bad $regularExpression (options are number, not string)",
|
|
99
|
+
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": \"a\", \"options\" : 0}}}"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"description" : "Bad $regularExpression (missing pattern field)",
|
|
103
|
+
"string" : "{\"a\" : {\"$regularExpression\": {\"options\":\"ix\"}}}"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"description": "Bad $oid (number, not string)",
|
|
107
|
+
"string": "{\"a\" : {\"$oid\" : 42}}"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"description": "Bad $oid (extra field)",
|
|
111
|
+
"string": "{\"a\" : {\"$oid\" : \"56e1fc72e0c917e9c4714161\", \"unrelated\": true}}"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"description": "Bad $numberInt (number, not string)",
|
|
115
|
+
"string": "{\"a\" : {\"$numberInt\" : 42}}"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"description": "Bad $numberInt (extra field)",
|
|
119
|
+
"string": "{\"a\" : {\"$numberInt\" : \"42\", \"unrelated\": true}}"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"description": "Bad $numberLong (number, not string)",
|
|
123
|
+
"string": "{\"a\" : {\"$numberLong\" : 42}}"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"description": "Bad $numberLong (extra field)",
|
|
127
|
+
"string": "{\"a\" : {\"$numberLong\" : \"42\", \"unrelated\": true}}"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"description": "Bad $numberDouble (number, not string)",
|
|
131
|
+
"string": "{\"a\" : {\"$numberDouble\" : 42}}"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"description": "Bad $numberDouble (extra field)",
|
|
135
|
+
"string": "{\"a\" : {\"$numberDouble\" : \".1\", \"unrelated\": true}}"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"description": "Bad $numberDecimal (number, not string)",
|
|
139
|
+
"string": "{\"a\" : {\"$numberDecimal\" : 42}}"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"description": "Bad $numberDecimal (extra field)",
|
|
143
|
+
"string": "{\"a\" : {\"$numberDecimal\" : \".1\", \"unrelated\": true}}"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"description": "Bad $binary (binary is number, not string)",
|
|
147
|
+
"string": "{\"x\" : {\"$binary\" : {\"base64\" : 0, \"subType\" : \"00\"}}}"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"description": "Bad $binary (type is number, not string)",
|
|
151
|
+
"string": "{\"x\" : {\"$binary\" : {\"base64\" : \"\", \"subType\" : 0}}}"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"description": "Bad $binary (missing $type)",
|
|
155
|
+
"string": "{\"x\" : {\"$binary\" : {\"base64\" : \"//8=\"}}}"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"description": "Bad $binary (missing $binary)",
|
|
159
|
+
"string": "{\"x\" : {\"$binary\" : {\"subType\" : \"00\"}}}"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"description": "Bad $binary (extra field)",
|
|
163
|
+
"string": "{\"x\" : {\"$binary\" : {\"base64\" : \"//8=\", \"subType\" : 0, \"unrelated\": true}}}"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"description": "Bad $code (type is number, not string)",
|
|
167
|
+
"string": "{\"a\" : {\"$code\" : 42}}"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"description": "Bad $code (type is number, not string) when $scope is also present",
|
|
171
|
+
"string": "{\"a\" : {\"$code\" : 42, \"$scope\" : {}}}"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"description": "Bad $code (extra field)",
|
|
175
|
+
"string": "{\"a\" : {\"$code\" : \"\", \"unrelated\": true}}"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"description": "Bad $code with $scope (scope is number, not doc)",
|
|
179
|
+
"string": "{\"x\" : {\"$code\" : \"\", \"$scope\" : 42}}"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"description": "Bad $timestamp (type is number, not doc)",
|
|
183
|
+
"string": "{\"a\" : {\"$timestamp\" : 42} }"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"description": "Bad $timestamp ('t' type is string, not number)",
|
|
187
|
+
"string": "{\"a\" : {\"$timestamp\" : {\"t\" : \"123456789\", \"i\" : 42} } }"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"description": "Bad $timestamp ('i' type is string, not number)",
|
|
191
|
+
"string": "{\"a\" : {\"$timestamp\" : {\"t\" : 123456789, \"i\" : \"42\"} } }"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"description": "Bad $timestamp (extra field at same level as $timestamp)",
|
|
195
|
+
"string": "{\"a\" : {\"$timestamp\" : {\"t\" : \"123456789\", \"i\" : \"42\"}, \"unrelated\": true } }"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"description": "Bad $timestamp (extra field at same level as t and i)",
|
|
199
|
+
"string": "{\"a\" : {\"$timestamp\" : {\"t\" : \"123456789\", \"i\" : \"42\", \"unrelated\": true} } }"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"description": "Bad $timestamp (missing t)",
|
|
203
|
+
"string": "{\"a\" : {\"$timestamp\" : {\"i\" : \"42\"} } }"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"description": "Bad $timestamp (missing i)",
|
|
207
|
+
"string": "{\"a\" : {\"$timestamp\" : {\"t\" : \"123456789\"} } }"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"description": "Bad $date (number, not string or hash)",
|
|
211
|
+
"string": "{\"a\" : {\"$date\" : 42}}"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"description": "Bad $date (extra field)",
|
|
215
|
+
"string": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"1356351330501\"}, \"unrelated\": true}}"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"description": "Bad $minKey (boolean, not integer)",
|
|
219
|
+
"string": "{\"a\" : {\"$minKey\" : true}}"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"description": "Bad $minKey (wrong integer)",
|
|
223
|
+
"string": "{\"a\" : {\"$minKey\" : 0}}"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"description": "Bad $minKey (extra field)",
|
|
227
|
+
"string": "{\"a\" : {\"$minKey\" : 1, \"unrelated\": true}}"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"description": "Bad $maxKey (boolean, not integer)",
|
|
231
|
+
"string": "{\"a\" : {\"$maxKey\" : true}}"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"description": "Bad $maxKey (wrong integer)",
|
|
235
|
+
"string": "{\"a\" : {\"$maxKey\" : 0}}"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"description": "Bad $maxKey (extra field)",
|
|
239
|
+
"string": "{\"a\" : {\"$maxKey\" : 1, \"unrelated\": true}}"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"description": "Bad DBpointer (extra field)",
|
|
243
|
+
"string": "{\"a\": {\"$dbPointer\": {\"a\": {\"$numberInt\": \"1\"}, \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}, \"c\": {\"$numberInt\": \"2\"}, \"$ref\": \"b\"}}}"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"description" : "Null byte in document key",
|
|
247
|
+
"string" : "{\"a\\u0000\": 1 }"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"description" : "Null byte in sub-document key",
|
|
251
|
+
"string" : "{\"a\" : {\"b\\u0000\": 1 }}"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"description": "Null byte in $regularExpression pattern",
|
|
255
|
+
"string": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"b\\u0000\", \"options\" : \"i\"}}}"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"description": "Null byte in $regularExpression options",
|
|
259
|
+
"string": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"b\", \"options\" : \"i\\u0000\"}}}"
|
|
260
|
+
}
|
|
261
|
+
]
|
|
262
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Undefined type (deprecated)",
|
|
3
|
+
"bson_type": "0x06",
|
|
4
|
+
"deprecated": true,
|
|
5
|
+
"test_key": "a",
|
|
6
|
+
"valid": [
|
|
7
|
+
{
|
|
8
|
+
"description": "Undefined",
|
|
9
|
+
"canonical_bson": "0800000006610000",
|
|
10
|
+
"canonical_extjson": "{\"a\" : {\"$undefined\" : true}}",
|
|
11
|
+
"converted_bson": "080000000A610000",
|
|
12
|
+
"converted_extjson": "{\"a\" : null}"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Array",
|
|
3
|
+
"bson_type": "0x04",
|
|
4
|
+
"test_key": "a",
|
|
5
|
+
"valid": [
|
|
6
|
+
{
|
|
7
|
+
"description": "Empty",
|
|
8
|
+
"bson": "0D000000046100050000000000",
|
|
9
|
+
"extjson": "{\"a\" : []}"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"description": "Single Element Array",
|
|
13
|
+
"bson": "140000000461000C0000001030000A0000000000",
|
|
14
|
+
"extjson": "{\"a\" : [10]}"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"description": "Single Element Array with index set incorrectly to empty string",
|
|
18
|
+
"bson": "130000000461000B00000010000A0000000000",
|
|
19
|
+
"canonical_bson": "140000000461000C0000001030000A0000000000",
|
|
20
|
+
"extjson": "{\"a\" : [10]}"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"description": "Single Element Array with index set incorrectly to ab",
|
|
24
|
+
"bson": "150000000461000D000000106162000A0000000000",
|
|
25
|
+
"canonical_bson": "140000000461000C0000001030000A0000000000",
|
|
26
|
+
"extjson": "{\"a\" : [10]}"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"description": "Multi Element Array with duplicate indexes",
|
|
30
|
+
"bson": "1b000000046100130000001030000a000000103000140000000000",
|
|
31
|
+
"canonical_bson": "1b000000046100130000001030000a000000103100140000000000",
|
|
32
|
+
"extjson": "{\"a\" : [10, 20]}"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"decodeErrors": [
|
|
36
|
+
{
|
|
37
|
+
"description": "Array length too long: eats outer terminator",
|
|
38
|
+
"bson": "140000000461000D0000001030000A0000000000"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"description": "Array length too short: leaks terminator",
|
|
42
|
+
"bson": "140000000461000B0000001030000A0000000000"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"description": "Invalid Array: bad string length in field",
|
|
46
|
+
"bson": "1A00000004666F6F00100000000230000500000062617A000000"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Binary type",
|
|
3
|
+
"bson_type": "0x05",
|
|
4
|
+
"test_key": "x",
|
|
5
|
+
"valid": [
|
|
6
|
+
{
|
|
7
|
+
"description": "subtype 0x00 (Zero-length)",
|
|
8
|
+
"bson": "0D000000057800000000000000",
|
|
9
|
+
"extjson": "{\"x\" : {\"$binary\" : \"\", \"$type\" : \"00\"}}"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"description": "subtype 0x00",
|
|
13
|
+
"bson": "0F0000000578000200000000FFFF00",
|
|
14
|
+
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"00\"}}"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"description": "subtype 0x01",
|
|
18
|
+
"bson": "0F0000000578000200000001FFFF00",
|
|
19
|
+
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"01\"}}"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"description": "subtype 0x02",
|
|
23
|
+
"bson": "13000000057800060000000202000000ffff00",
|
|
24
|
+
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"02\"}}"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"description": "subtype 0x03",
|
|
28
|
+
"bson": "1D000000057800100000000373FFD26444B34C6990E8E7D1DFC035D400",
|
|
29
|
+
"extjson": "{\"x\" : {\"$binary\" : \"c//SZESzTGmQ6OfR38A11A==\", \"$type\" : \"03\"}}"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"description": "subtype 0x04",
|
|
33
|
+
"bson": "1D000000057800100000000473FFD26444B34C6990E8E7D1DFC035D400",
|
|
34
|
+
"extjson": "{\"x\" : {\"$binary\" : \"c//SZESzTGmQ6OfR38A11A==\", \"$type\" : \"04\"}}"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"description": "subtype 0x05",
|
|
38
|
+
"bson": "1D000000057800100000000573FFD26444B34C6990E8E7D1DFC035D400",
|
|
39
|
+
"extjson": "{\"x\" : {\"$binary\" : \"c//SZESzTGmQ6OfR38A11A==\", \"$type\" : \"05\"}}"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"description": "subtype 0x80",
|
|
43
|
+
"bson": "0F0000000578000200000080FFFF00",
|
|
44
|
+
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"80\"}}"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"decodeErrors": [
|
|
48
|
+
{
|
|
49
|
+
"description": "Length longer than document",
|
|
50
|
+
"bson": "1D000000057800FF0000000573FFD26444B34C6990E8E7D1DFC035D400"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"description": "Negative length",
|
|
54
|
+
"bson": "0D000000057800FFFFFFFF0000"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"description": "subtype 0x02 length too long ",
|
|
58
|
+
"bson": "13000000057800060000000203000000FFFF00"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"description": "subtype 0x02 length too short",
|
|
62
|
+
"bson": "13000000057800060000000201000000FFFF00"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"description": "subtype 0x02 length negative one",
|
|
66
|
+
"bson": "130000000578000600000002FFFFFFFFFFFF00"
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Boolean",
|
|
3
|
+
"bson_type": "0x08",
|
|
4
|
+
"test_key": "b",
|
|
5
|
+
"valid": [
|
|
6
|
+
{
|
|
7
|
+
"description": "True",
|
|
8
|
+
"bson": "090000000862000100",
|
|
9
|
+
"extjson": "{\"b\" : true}"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"description": "False",
|
|
13
|
+
"bson": "090000000862000000",
|
|
14
|
+
"extjson": "{\"b\" : false}"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"decodeErrors": [
|
|
18
|
+
{
|
|
19
|
+
"description": "Invalid boolean value of 2",
|
|
20
|
+
"bson": "090000000862000200"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"description": "Invalid boolean value of -1",
|
|
24
|
+
"bson": "09000000086200FF00"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Code",
|
|
3
|
+
"bson_type": "0x0D",
|
|
4
|
+
"test_key": "a",
|
|
5
|
+
"valid": [
|
|
6
|
+
{
|
|
7
|
+
"description": "Empty string",
|
|
8
|
+
"bson": "0D0000000D6100010000000000",
|
|
9
|
+
"extjson": "{\"a\" : {\"$code\" : \"\"}}"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"description": "Single character",
|
|
13
|
+
"bson": "0E0000000D610002000000620000",
|
|
14
|
+
"extjson": "{\"a\" : {\"$code\" : \"b\"}}"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"description": "Multi-character",
|
|
18
|
+
"bson": "190000000D61000D0000006162616261626162616261620000",
|
|
19
|
+
"extjson": "{\"a\" : {\"$code\" : \"abababababab\"}}"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"description": "two-byte UTF-8 (\u00e9)",
|
|
23
|
+
"bson": "190000000261000D000000C3A9C3A9C3A9C3A9C3A9C3A90000",
|
|
24
|
+
"extjson": "{\"a\" : \"\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\"}"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"description": "three-byte UTF-8 (\u2606)",
|
|
28
|
+
"bson": "190000000261000D000000E29886E29886E29886E298860000",
|
|
29
|
+
"extjson": "{\"a\" : \"\\u2606\\u2606\\u2606\\u2606\"}"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"description": "Embedded nulls",
|
|
33
|
+
"bson": "190000000261000D0000006162006261620062616261620000",
|
|
34
|
+
"extjson": "{\"a\" : \"ab\\u0000bab\\u0000babab\"}"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"decodeErrors": [
|
|
38
|
+
{
|
|
39
|
+
"description": "bad code string length: 0 (but no 0x00 either)",
|
|
40
|
+
"bson": "0C0000000261000000000000"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"description": "bad code string length: -1",
|
|
44
|
+
"bson": "0C000000026100FFFFFFFF00"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"description": "bad code string length: eats terminator",
|
|
48
|
+
"bson": "10000000026100050000006200620000"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"description": "bad code string length: longer than rest of document",
|
|
52
|
+
"bson": "120000000200FFFFFF00666F6F6261720000"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"description": "code string is not null-terminated",
|
|
56
|
+
"bson": "1000000002610004000000616263FF00"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"description": "empty code string, but extra null",
|
|
60
|
+
"bson": "0E00000002610001000000000000"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"description": "invalid UTF-8",
|
|
64
|
+
"bson": "0E00000002610002000000E90000"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "CodeWithScope",
|
|
3
|
+
"bson_type": "0x0F",
|
|
4
|
+
"test_key": "a",
|
|
5
|
+
"valid": [
|
|
6
|
+
{
|
|
7
|
+
"description": "Empty code string, empty scope",
|
|
8
|
+
"bson": "160000000F61000E0000000100000000050000000000",
|
|
9
|
+
"extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {}}}"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"description": "Non-empty code string, empty scope",
|
|
13
|
+
"bson": "1A0000000F610012000000050000006162636400050000000000",
|
|
14
|
+
"extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {}}}"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"description": "Empty code string, non-empty scope",
|
|
18
|
+
"bson": "1D0000000F61001500000001000000000C000000107800010000000000",
|
|
19
|
+
"extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {\"x\" : 1}}}"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"description": "Non-empty code string and non-empty scope",
|
|
23
|
+
"bson": "210000000F6100190000000500000061626364000C000000107800010000000000",
|
|
24
|
+
"extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {\"x\" : 1}}}"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"description": "Unicode and embedded null in code string, empty scope",
|
|
28
|
+
"bson": "1A0000000F61001200000005000000C3A9006400050000000000",
|
|
29
|
+
"extjson": "{\"a\" : {\"$code\" : \"\\u00e9\\u0000d\", \"$scope\" : {}}}"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"decodeErrors": [
|
|
33
|
+
{
|
|
34
|
+
"description": "field length zero",
|
|
35
|
+
"bson": "280000000F6100000000000500000061626364001300000010780001000000107900010000000000"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"description": "field length negative",
|
|
39
|
+
"bson": "280000000F6100FFFFFFFF0500000061626364001300000010780001000000107900010000000000"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"description": "field length too short (less than minimum size)",
|
|
43
|
+
"bson": "160000000F61000D0000000100000000050000000000"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"description": "field length too short (truncates scope)",
|
|
47
|
+
"bson": "280000000F61001F0000000500000061626364001300000010780001000000107900010000000000"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"description": "field length too long (clips outer doc)",
|
|
51
|
+
"bson": "280000000F6100210000000500000061626364001300000010780001000000107900010000000000"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"description": "field length too long (longer than outer doc)",
|
|
55
|
+
"bson": "280000000F6100FF0000000500000061626364001300000010780001000000107900010000000000"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"description": "bad code string: length too short",
|
|
59
|
+
"bson": "280000000F6100200000000400000061626364001300000010780001000000107900010000000000"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"description": "bad code string: length too long (clips scope)",
|
|
63
|
+
"bson": "280000000F6100200000000600000061626364001300000010780001000000107900010000000000"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"description": "bad code string: negative length",
|
|
67
|
+
"bson": "280000000F610020000000FFFFFFFF61626364001300000010780001000000107900010000000000"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"description": "bad code string: length longer than field",
|
|
71
|
+
"bson": "280000000F610020000000FF00000061626364001300000010780001000000107900010000000000"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"description": "bad scope doc (field has bad string length)",
|
|
75
|
+
"bson": "1C0000000F001500000001000000000C000000020000000000000000"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Document",
|
|
3
|
+
"bson_type": "0x03",
|
|
4
|
+
"test_key": "x",
|
|
5
|
+
"valid": [
|
|
6
|
+
{
|
|
7
|
+
"description": "Empty subdoc",
|
|
8
|
+
"bson": "0D000000037800050000000000",
|
|
9
|
+
"extjson": "{\"x\" : {}}"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"description": "Empty-string key subdoc",
|
|
13
|
+
"bson": "150000000378000D00000002000200000062000000",
|
|
14
|
+
"extjson": "{\"x\" : {\"\" : \"b\"}}"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"description": "Single-character key subdoc",
|
|
18
|
+
"bson": "160000000378000E0000000261000200000062000000",
|
|
19
|
+
"extjson": "{\"x\" : {\"a\" : \"b\"}}"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"decodeErrors": [
|
|
23
|
+
{
|
|
24
|
+
"description": "Subdocument length too long: eats outer terminator",
|
|
25
|
+
"bson": "1800000003666F6F000F0000001062617200FFFFFF7F0000"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"description": "Subdocument length too short: leaks terminator",
|
|
29
|
+
"bson": "1500000003666F6F000A0000000862617200010000"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"description": "Invalid subdocument: bad string length in field",
|
|
33
|
+
"bson": "1C00000003666F6F001200000002626172000500000062617A000000"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|