kreuzberg 4.1.1 → 4.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 +4 -4
- data/Gemfile.lock +4 -4
- data/README.md +8 -5
- data/ext/kreuzberg_rb/native/Cargo.toml +2 -2
- data/ext/kreuzberg_rb/native/libpdfium.so +0 -0
- data/ext/kreuzberg_rb/native/src/config/types.rs +23 -13
- data/kreuzberg.gemspec +14 -2
- data/lib/kreuzberg/api_proxy.rb +0 -1
- data/lib/kreuzberg/cli_proxy.rb +0 -1
- data/lib/kreuzberg/config.rb +70 -35
- data/lib/kreuzberg/mcp_proxy.rb +0 -1
- data/lib/kreuzberg/version.rb +1 -1
- data/sig/kreuzberg.rbs +5 -1
- data/spec/binding/batch_operations_spec.rb +80 -0
- data/spec/binding/metadata_types_spec.rb +77 -57
- data/spec/serialization_spec.rb +134 -0
- data/spec/unit/config/output_format_spec.rb +380 -0
- data/vendor/Cargo.toml +1 -1
- data/vendor/kreuzberg/Cargo.toml +3 -3
- data/vendor/kreuzberg/README.md +1 -1
- data/vendor/kreuzberg/src/embeddings.rs +4 -4
- data/vendor/kreuzberg/src/mcp/format.rs +237 -39
- data/vendor/kreuzberg/src/mcp/params.rs +26 -33
- data/vendor/kreuzberg/src/mcp/server.rs +6 -3
- data/vendor/kreuzberg/src/mcp/tools/extraction.rs +16 -23
- data/vendor/kreuzberg/tests/api_chunk.rs +40 -30
- data/vendor/kreuzberg/tests/api_consistency.rs +349 -0
- data/vendor/kreuzberg/tests/api_embed.rs +84 -50
- data/vendor/kreuzberg/tests/api_large_pdf_extraction_diagnostics.rs +8 -2
- data/vendor/kreuzberg/tests/api_tests.rs +298 -139
- data/vendor/kreuzberg/tests/archive_integration.rs +63 -56
- data/vendor/kreuzberg/tests/batch_orchestration.rs +22 -14
- data/vendor/kreuzberg/tests/batch_pooling_benchmark.rs +13 -13
- data/vendor/kreuzberg/tests/batch_processing.rs +13 -9
- data/vendor/kreuzberg/tests/bibtex_parity_test.rs +10 -10
- data/vendor/kreuzberg/tests/concurrency_stress.rs +10 -6
- data/vendor/kreuzberg/tests/config_behavioral.rs +414 -0
- data/vendor/kreuzberg/tests/config_features.rs +19 -15
- data/vendor/kreuzberg/tests/config_integration_test.rs +68 -68
- data/vendor/kreuzberg/tests/config_loading_tests.rs +71 -62
- data/vendor/kreuzberg/tests/contract_mcp.rs +314 -0
- data/vendor/kreuzberg/tests/core_integration.rs +55 -53
- data/vendor/kreuzberg/tests/docbook_extractor_tests.rs +23 -23
- data/vendor/kreuzberg/tests/docx_metadata_extraction_test.rs +15 -14
- data/vendor/kreuzberg/tests/docx_vs_pandoc_comparison.rs +4 -4
- data/vendor/kreuzberg/tests/email_integration.rs +7 -7
- data/vendor/kreuzberg/tests/epub_native_extractor_tests.rs +2 -2
- data/vendor/kreuzberg/tests/error_handling.rs +13 -11
- data/vendor/kreuzberg/tests/fictionbook_extractor_tests.rs +2 -2
- data/vendor/kreuzberg/tests/html_table_test.rs +11 -11
- data/vendor/kreuzberg/tests/instrumentation_test.rs +18 -13
- data/vendor/kreuzberg/tests/jats_extractor_tests.rs +17 -17
- data/vendor/kreuzberg/tests/jupyter_extractor_tests.rs +9 -9
- data/vendor/kreuzberg/tests/keywords_integration.rs +25 -25
- data/vendor/kreuzberg/tests/keywords_quality.rs +9 -9
- data/vendor/kreuzberg/tests/latex_extractor_tests.rs +2 -2
- data/vendor/kreuzberg/tests/markdown_extractor_tests.rs +1 -1
- data/vendor/kreuzberg/tests/mcp_integration.rs +849 -0
- data/vendor/kreuzberg/tests/mime_detection.rs +72 -41
- data/vendor/kreuzberg/tests/ocr_errors.rs +10 -4
- data/vendor/kreuzberg/tests/ocr_language_registry.rs +1 -1
- data/vendor/kreuzberg/tests/ocr_stress.rs +3 -3
- data/vendor/kreuzberg/tests/odt_extractor_tests.rs +6 -6
- data/vendor/kreuzberg/tests/opml_extractor_tests.rs +2 -2
- data/vendor/kreuzberg/tests/orgmode_extractor_tests.rs +2 -2
- data/vendor/kreuzberg/tests/page_markers.rs +1 -1
- data/vendor/kreuzberg/tests/pdf_hierarchy_detection.rs +6 -6
- data/vendor/kreuzberg/tests/pdf_text_merging.rs +2 -2
- data/vendor/kreuzberg/tests/pipeline_integration.rs +77 -61
- data/vendor/kreuzberg/tests/plugin_ocr_backend_test.rs +97 -77
- data/vendor/kreuzberg/tests/plugin_postprocessor_test.rs +78 -61
- data/vendor/kreuzberg/tests/plugin_system.rs +49 -46
- data/vendor/kreuzberg/tests/plugin_validator_test.rs +109 -97
- data/vendor/kreuzberg/tests/pptx_regression_tests.rs +40 -30
- data/vendor/kreuzberg/tests/registry_integration_tests.rs +26 -23
- data/vendor/kreuzberg/tests/rst_extractor_tests.rs +1 -1
- data/vendor/kreuzberg/tests/rtf_extractor_tests.rs +18 -18
- data/vendor/kreuzberg/tests/security_validation.rs +20 -19
- data/vendor/kreuzberg/tests/serialization_integration.rs +112 -0
- data/vendor/kreuzberg/tests/stopwords_integration_test.rs +36 -36
- data/vendor/kreuzberg/tests/test_fastembed.rs +8 -8
- data/vendor/kreuzberg/tests/typst_extractor_tests.rs +9 -9
- data/vendor/kreuzberg/tests/xlsx_metadata_extraction_test.rs +12 -9
- data/vendor/kreuzberg-tesseract/Cargo.toml +3 -3
- data/vendor/kreuzberg-tesseract/build.rs +4 -4
- data/vendor/kreuzberg-tesseract/src/lib.rs +6 -6
- data/vendor/kreuzberg-tesseract/tests/integration_test.rs +3 -3
- metadata +13 -2
|
@@ -57,7 +57,7 @@ fn restore_env(saved: Vec<(String, Option<String>)>) {
|
|
|
57
57
|
fn test_config_precedence_env_over_file() {
|
|
58
58
|
let saved = save_env(&["KREUZBERG_HOST", "KREUZBERG_PORT"]);
|
|
59
59
|
|
|
60
|
-
let dir = tempdir().
|
|
60
|
+
let dir = tempdir().expect("Operation failed");
|
|
61
61
|
let config_path = dir.path().join("config.toml");
|
|
62
62
|
|
|
63
63
|
// Create config file with file values
|
|
@@ -68,19 +68,19 @@ host = "file-host"
|
|
|
68
68
|
port = 8001
|
|
69
69
|
"#,
|
|
70
70
|
)
|
|
71
|
-
.
|
|
71
|
+
.expect("Operation failed");
|
|
72
72
|
|
|
73
73
|
// Set env vars (should override file)
|
|
74
74
|
set_env("KREUZBERG_HOST", "env-host");
|
|
75
75
|
set_env("KREUZBERG_PORT", "8002");
|
|
76
76
|
|
|
77
77
|
// Load and apply
|
|
78
|
-
let mut config = ServerConfig::from_file(&config_path).
|
|
78
|
+
let mut config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
79
79
|
assert_eq!(config.host, "file-host");
|
|
80
80
|
assert_eq!(config.port, 8001);
|
|
81
81
|
|
|
82
82
|
// Apply env overrides
|
|
83
|
-
config.apply_env_overrides().
|
|
83
|
+
config.apply_env_overrides().expect("Operation failed");
|
|
84
84
|
|
|
85
85
|
// Verify env vars won (Env > File)
|
|
86
86
|
assert_eq!(config.host, "env-host", "Env HOST should override file HOST");
|
|
@@ -93,7 +93,7 @@ port = 8001
|
|
|
93
93
|
// Test 2: File-only configuration
|
|
94
94
|
#[test]
|
|
95
95
|
fn test_file_only_configuration() {
|
|
96
|
-
let dir = tempdir().
|
|
96
|
+
let dir = tempdir().expect("Operation failed");
|
|
97
97
|
let config_path = dir.path().join("config.toml");
|
|
98
98
|
|
|
99
99
|
// Create config with specific values
|
|
@@ -107,9 +107,9 @@ max_request_body_bytes = 50000000
|
|
|
107
107
|
max_multipart_field_bytes = 75000000
|
|
108
108
|
"#,
|
|
109
109
|
)
|
|
110
|
-
.
|
|
110
|
+
.expect("Operation failed");
|
|
111
111
|
|
|
112
|
-
let config = ServerConfig::from_file(&config_path).
|
|
112
|
+
let config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
113
113
|
|
|
114
114
|
assert_eq!(config.host, "192.168.1.100");
|
|
115
115
|
assert_eq!(config.port, 9000);
|
|
@@ -140,7 +140,7 @@ fn test_env_only_configuration() {
|
|
|
140
140
|
assert_eq!(config.port, 8000);
|
|
141
141
|
|
|
142
142
|
// Apply env overrides
|
|
143
|
-
config.apply_env_overrides().
|
|
143
|
+
config.apply_env_overrides().expect("Operation failed");
|
|
144
144
|
|
|
145
145
|
// Verify env vars are used
|
|
146
146
|
assert_eq!(config.host, "0.0.0.0");
|
|
@@ -171,7 +171,7 @@ fn test_default_configuration() {
|
|
|
171
171
|
// Test 5: Backward compatibility - file without [server] section
|
|
172
172
|
#[test]
|
|
173
173
|
fn test_backward_compatibility_no_server_section() {
|
|
174
|
-
let dir = tempdir().
|
|
174
|
+
let dir = tempdir().expect("Operation failed");
|
|
175
175
|
let config_path = dir.path().join("config.toml");
|
|
176
176
|
|
|
177
177
|
// Create config with only extraction settings (no [server] section)
|
|
@@ -183,10 +183,10 @@ use_cache = false
|
|
|
183
183
|
enable_quality_processing = true
|
|
184
184
|
"#,
|
|
185
185
|
)
|
|
186
|
-
.
|
|
186
|
+
.expect("Operation failed");
|
|
187
187
|
|
|
188
188
|
// ServerConfig::from_file should load with defaults for missing [server] section
|
|
189
|
-
let config = ServerConfig::from_file(&config_path).
|
|
189
|
+
let config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
190
190
|
|
|
191
191
|
// Verify ServerConfig fields have defaults
|
|
192
192
|
assert_eq!(config.host, "127.0.0.1");
|
|
@@ -197,7 +197,7 @@ enable_quality_processing = true
|
|
|
197
197
|
// Test 6: All three formats - TOML
|
|
198
198
|
#[test]
|
|
199
199
|
fn test_config_format_toml() {
|
|
200
|
-
let dir = tempdir().
|
|
200
|
+
let dir = tempdir().expect("Operation failed");
|
|
201
201
|
let config_path = dir.path().join("config.toml");
|
|
202
202
|
|
|
203
203
|
fs::write(
|
|
@@ -208,9 +208,9 @@ port = 7000
|
|
|
208
208
|
cors_origins = ["https://test.com"]
|
|
209
209
|
"#,
|
|
210
210
|
)
|
|
211
|
-
.
|
|
211
|
+
.expect("Operation failed");
|
|
212
212
|
|
|
213
|
-
let config = ServerConfig::from_file(&config_path).
|
|
213
|
+
let config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
214
214
|
assert_eq!(config.host, "10.0.0.1");
|
|
215
215
|
assert_eq!(config.port, 7000);
|
|
216
216
|
}
|
|
@@ -218,7 +218,7 @@ cors_origins = ["https://test.com"]
|
|
|
218
218
|
// Test 7: All three formats - YAML
|
|
219
219
|
#[test]
|
|
220
220
|
fn test_config_format_yaml() {
|
|
221
|
-
let dir = tempdir().
|
|
221
|
+
let dir = tempdir().expect("Operation failed");
|
|
222
222
|
let config_path = dir.path().join("config.yaml");
|
|
223
223
|
|
|
224
224
|
fs::write(
|
|
@@ -230,9 +230,9 @@ cors_origins:
|
|
|
230
230
|
- https://test.com
|
|
231
231
|
"#,
|
|
232
232
|
)
|
|
233
|
-
.
|
|
233
|
+
.expect("Operation failed");
|
|
234
234
|
|
|
235
|
-
let config = ServerConfig::from_file(&config_path).
|
|
235
|
+
let config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
236
236
|
assert_eq!(config.host, "10.0.0.2");
|
|
237
237
|
assert_eq!(config.port, 7001);
|
|
238
238
|
}
|
|
@@ -240,7 +240,7 @@ cors_origins:
|
|
|
240
240
|
// Test 8: All three formats - JSON
|
|
241
241
|
#[test]
|
|
242
242
|
fn test_config_format_json() {
|
|
243
|
-
let dir = tempdir().
|
|
243
|
+
let dir = tempdir().expect("Operation failed");
|
|
244
244
|
let config_path = dir.path().join("config.json");
|
|
245
245
|
|
|
246
246
|
fs::write(
|
|
@@ -252,9 +252,9 @@ fn test_config_format_json() {
|
|
|
252
252
|
}
|
|
253
253
|
"#,
|
|
254
254
|
)
|
|
255
|
-
.
|
|
255
|
+
.expect("Operation failed");
|
|
256
256
|
|
|
257
|
-
let config = ServerConfig::from_file(&config_path).
|
|
257
|
+
let config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
258
258
|
assert_eq!(config.host, "10.0.0.3");
|
|
259
259
|
assert_eq!(config.port, 7002);
|
|
260
260
|
}
|
|
@@ -262,7 +262,7 @@ fn test_config_format_json() {
|
|
|
262
262
|
// Test 9: CORS configuration - empty (allow all)
|
|
263
263
|
#[test]
|
|
264
264
|
fn test_cors_configuration_allow_all() {
|
|
265
|
-
let dir = tempdir().
|
|
265
|
+
let dir = tempdir().expect("Operation failed");
|
|
266
266
|
let config_path = dir.path().join("config.toml");
|
|
267
267
|
|
|
268
268
|
fs::write(
|
|
@@ -273,9 +273,9 @@ port = 8000
|
|
|
273
273
|
# Empty cors_origins means allow all
|
|
274
274
|
"#,
|
|
275
275
|
)
|
|
276
|
-
.
|
|
276
|
+
.expect("Operation failed");
|
|
277
277
|
|
|
278
|
-
let config = ServerConfig::from_file(&config_path).
|
|
278
|
+
let config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
279
279
|
|
|
280
280
|
assert!(config.cors_allows_all(), "Empty cors_origins should allow all");
|
|
281
281
|
assert!(config.is_origin_allowed("https://any.com"));
|
|
@@ -285,7 +285,7 @@ port = 8000
|
|
|
285
285
|
// Test 10: CORS configuration - specific origins
|
|
286
286
|
#[test]
|
|
287
287
|
fn test_cors_configuration_specific_origins() {
|
|
288
|
-
let dir = tempdir().
|
|
288
|
+
let dir = tempdir().expect("Operation failed");
|
|
289
289
|
let config_path = dir.path().join("config.toml");
|
|
290
290
|
|
|
291
291
|
fs::write(
|
|
@@ -296,9 +296,9 @@ port = 8000
|
|
|
296
296
|
cors_origins = ["https://app1.com", "https://app2.com"]
|
|
297
297
|
"#,
|
|
298
298
|
)
|
|
299
|
-
.
|
|
299
|
+
.expect("Operation failed");
|
|
300
300
|
|
|
301
|
-
let config = ServerConfig::from_file(&config_path).
|
|
301
|
+
let config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
302
302
|
|
|
303
303
|
assert!(!config.cors_allows_all(), "Specific origins should not allow all");
|
|
304
304
|
assert!(config.is_origin_allowed("https://app1.com"));
|
|
@@ -312,7 +312,7 @@ cors_origins = ["https://app1.com", "https://app2.com"]
|
|
|
312
312
|
fn test_cors_precedence_env_over_file() {
|
|
313
313
|
let saved = save_env(&["KREUZBERG_CORS_ORIGINS"]);
|
|
314
314
|
|
|
315
|
-
let dir = tempdir().
|
|
315
|
+
let dir = tempdir().expect("Operation failed");
|
|
316
316
|
let config_path = dir.path().join("config.toml");
|
|
317
317
|
|
|
318
318
|
fs::write(
|
|
@@ -321,15 +321,15 @@ fn test_cors_precedence_env_over_file() {
|
|
|
321
321
|
cors_origins = ["https://file.com"]
|
|
322
322
|
"#,
|
|
323
323
|
)
|
|
324
|
-
.
|
|
324
|
+
.expect("Operation failed");
|
|
325
325
|
|
|
326
326
|
set_env("KREUZBERG_CORS_ORIGINS", "https://env1.com, https://env2.com");
|
|
327
327
|
|
|
328
|
-
let mut config = ServerConfig::from_file(&config_path).
|
|
328
|
+
let mut config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
329
329
|
assert_eq!(config.cors_origins.len(), 1);
|
|
330
330
|
assert_eq!(config.cors_origins[0], "https://file.com");
|
|
331
331
|
|
|
332
|
-
config.apply_env_overrides().
|
|
332
|
+
config.apply_env_overrides().expect("Operation failed");
|
|
333
333
|
|
|
334
334
|
assert_eq!(config.cors_origins.len(), 2);
|
|
335
335
|
assert!(config.cors_origins.contains(&"https://env1.com".to_string()));
|
|
@@ -342,7 +342,7 @@ cors_origins = ["https://file.com"]
|
|
|
342
342
|
// Test 12: Legacy max_upload_mb backward compatibility
|
|
343
343
|
#[test]
|
|
344
344
|
fn test_legacy_max_upload_mb_in_file() {
|
|
345
|
-
let dir = tempdir().
|
|
345
|
+
let dir = tempdir().expect("Operation failed");
|
|
346
346
|
let config_path = dir.path().join("config.toml");
|
|
347
347
|
|
|
348
348
|
fs::write(
|
|
@@ -353,9 +353,9 @@ port = 8000
|
|
|
353
353
|
max_upload_mb = 50
|
|
354
354
|
"#,
|
|
355
355
|
)
|
|
356
|
-
.
|
|
356
|
+
.expect("Operation failed");
|
|
357
357
|
|
|
358
|
-
let config = ServerConfig::from_file(&config_path).
|
|
358
|
+
let config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
359
359
|
|
|
360
360
|
assert_eq!(config.max_upload_mb, Some(50));
|
|
361
361
|
// Should be converted to bytes
|
|
@@ -373,7 +373,7 @@ fn test_legacy_max_upload_mb_env_override() {
|
|
|
373
373
|
let mut config = ServerConfig::default();
|
|
374
374
|
assert!(config.max_upload_mb.is_none());
|
|
375
375
|
|
|
376
|
-
config.apply_env_overrides().
|
|
376
|
+
config.apply_env_overrides().expect("Operation failed");
|
|
377
377
|
|
|
378
378
|
assert_eq!(config.max_upload_mb, Some(75));
|
|
379
379
|
assert_eq!(config.max_multipart_field_bytes, 75 * 1_048_576);
|
|
@@ -427,7 +427,7 @@ fn test_invalid_env_max_request_body_bytes() {
|
|
|
427
427
|
fn test_partial_overrides_host_only() {
|
|
428
428
|
let saved = save_env(&["KREUZBERG_HOST", "KREUZBERG_PORT"]);
|
|
429
429
|
|
|
430
|
-
let dir = tempdir().
|
|
430
|
+
let dir = tempdir().expect("Operation failed");
|
|
431
431
|
let config_path = dir.path().join("config.toml");
|
|
432
432
|
|
|
433
433
|
fs::write(
|
|
@@ -437,13 +437,13 @@ host = "file-host"
|
|
|
437
437
|
port = 8001
|
|
438
438
|
"#,
|
|
439
439
|
)
|
|
440
|
-
.
|
|
440
|
+
.expect("Operation failed");
|
|
441
441
|
|
|
442
442
|
set_env("KREUZBERG_HOST", "env-host");
|
|
443
443
|
// Explicitly don't set KREUZBERG_PORT
|
|
444
444
|
|
|
445
|
-
let mut config = ServerConfig::from_file(&config_path).
|
|
446
|
-
config.apply_env_overrides().
|
|
445
|
+
let mut config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
446
|
+
config.apply_env_overrides().expect("Operation failed");
|
|
447
447
|
|
|
448
448
|
assert_eq!(config.host, "env-host", "Host should be overridden by env");
|
|
449
449
|
assert_eq!(config.port, 8001, "Port should keep file value");
|
|
@@ -458,7 +458,7 @@ port = 8001
|
|
|
458
458
|
fn test_partial_overrides_port_only() {
|
|
459
459
|
let saved = save_env(&["KREUZBERG_HOST", "KREUZBERG_PORT"]);
|
|
460
460
|
|
|
461
|
-
let dir = tempdir().
|
|
461
|
+
let dir = tempdir().expect("Operation failed");
|
|
462
462
|
let config_path = dir.path().join("config.toml");
|
|
463
463
|
|
|
464
464
|
fs::write(
|
|
@@ -468,13 +468,13 @@ host = "file-host"
|
|
|
468
468
|
port = 8001
|
|
469
469
|
"#,
|
|
470
470
|
)
|
|
471
|
-
.
|
|
471
|
+
.expect("Operation failed");
|
|
472
472
|
|
|
473
473
|
set_env("KREUZBERG_PORT", "9000");
|
|
474
474
|
// Explicitly don't set KREUZBERG_HOST
|
|
475
475
|
|
|
476
|
-
let mut config = ServerConfig::from_file(&config_path).
|
|
477
|
-
config.apply_env_overrides().
|
|
476
|
+
let mut config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
477
|
+
config.apply_env_overrides().expect("Operation failed");
|
|
478
478
|
|
|
479
479
|
assert_eq!(config.host, "file-host", "Host should keep file value");
|
|
480
480
|
assert_eq!(config.port, 9000, "Port should be overridden by env");
|
|
@@ -494,7 +494,7 @@ fn test_complex_scenario_multiple_settings() {
|
|
|
494
494
|
"KREUZBERG_MAX_REQUEST_BODY_BYTES",
|
|
495
495
|
]);
|
|
496
496
|
|
|
497
|
-
let dir = tempdir().
|
|
497
|
+
let dir = tempdir().expect("Operation failed");
|
|
498
498
|
let config_path = dir.path().join("config.toml");
|
|
499
499
|
|
|
500
500
|
fs::write(
|
|
@@ -507,7 +507,7 @@ max_request_body_bytes = 50000000
|
|
|
507
507
|
max_multipart_field_bytes = 75000000
|
|
508
508
|
"#,
|
|
509
509
|
)
|
|
510
|
-
.
|
|
510
|
+
.expect("Operation failed");
|
|
511
511
|
|
|
512
512
|
// Override some settings
|
|
513
513
|
set_env("KREUZBERG_HOST", "0.0.0.0");
|
|
@@ -515,8 +515,8 @@ max_multipart_field_bytes = 75000000
|
|
|
515
515
|
set_env("KREUZBERG_CORS_ORIGINS", "https://env.com");
|
|
516
516
|
// Don't set max_request_body_bytes - should keep file value
|
|
517
517
|
|
|
518
|
-
let mut config = ServerConfig::from_file(&config_path).
|
|
519
|
-
config.apply_env_overrides().
|
|
518
|
+
let mut config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
519
|
+
config.apply_env_overrides().expect("Operation failed");
|
|
520
520
|
|
|
521
521
|
assert_eq!(config.host, "0.0.0.0");
|
|
522
522
|
assert_eq!(config.port, 3000);
|
|
@@ -565,7 +565,7 @@ fn test_upload_limits_to_mb_conversion() {
|
|
|
565
565
|
// Test 21: Serialization consistency
|
|
566
566
|
#[test]
|
|
567
567
|
fn test_serialization_consistency() {
|
|
568
|
-
let dir = tempdir().
|
|
568
|
+
let dir = tempdir().expect("Operation failed");
|
|
569
569
|
let config_path = dir.path().join("config.toml");
|
|
570
570
|
|
|
571
571
|
let original = r#"
|
|
@@ -576,15 +576,15 @@ max_request_body_bytes = 50000000
|
|
|
576
576
|
max_multipart_field_bytes = 75000000
|
|
577
577
|
"#;
|
|
578
578
|
|
|
579
|
-
fs::write(&config_path, original).
|
|
579
|
+
fs::write(&config_path, original).expect("Operation failed");
|
|
580
580
|
|
|
581
|
-
let config = ServerConfig::from_file(&config_path).
|
|
581
|
+
let config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
582
582
|
|
|
583
583
|
// Serialize back
|
|
584
|
-
let serialized = toml::to_string(&config).
|
|
584
|
+
let serialized = toml::to_string(&config).expect("Operation failed");
|
|
585
585
|
|
|
586
586
|
// Deserialize again
|
|
587
|
-
let config2: ServerConfig = toml::from_str(&serialized).
|
|
587
|
+
let config2: ServerConfig = toml::from_str(&serialized).expect("Failed to parse string");
|
|
588
588
|
|
|
589
589
|
// Verify consistency
|
|
590
590
|
assert_eq!(config.host, config2.host);
|
|
@@ -600,7 +600,7 @@ max_multipart_field_bytes = 75000000
|
|
|
600
600
|
fn test_empty_cors_to_specific_via_env() {
|
|
601
601
|
let saved = save_env(&["KREUZBERG_CORS_ORIGINS"]);
|
|
602
602
|
|
|
603
|
-
let dir = tempdir().
|
|
603
|
+
let dir = tempdir().expect("Operation failed");
|
|
604
604
|
let config_path = dir.path().join("config.toml");
|
|
605
605
|
|
|
606
606
|
fs::write(
|
|
@@ -610,14 +610,14 @@ host = "127.0.0.1"
|
|
|
610
610
|
port = 8000
|
|
611
611
|
"#,
|
|
612
612
|
)
|
|
613
|
-
.
|
|
613
|
+
.expect("Operation failed");
|
|
614
614
|
|
|
615
|
-
let mut config = ServerConfig::from_file(&config_path).
|
|
615
|
+
let mut config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
616
616
|
assert!(config.cors_allows_all(), "File config allows all origins");
|
|
617
617
|
|
|
618
618
|
// Override with specific origins
|
|
619
619
|
set_env("KREUZBERG_CORS_ORIGINS", "https://restricted.com");
|
|
620
|
-
config.apply_env_overrides().
|
|
620
|
+
config.apply_env_overrides().expect("Operation failed");
|
|
621
621
|
|
|
622
622
|
assert!(!config.cors_allows_all(), "Should now restrict to specific origin");
|
|
623
623
|
assert!(config.is_origin_allowed("https://restricted.com"));
|
|
@@ -630,7 +630,7 @@ port = 8000
|
|
|
630
630
|
// Test 23: Max upload limits in different formats
|
|
631
631
|
#[test]
|
|
632
632
|
fn test_max_limits_across_formats() {
|
|
633
|
-
let dir = tempdir().
|
|
633
|
+
let dir = tempdir().expect("Operation failed");
|
|
634
634
|
|
|
635
635
|
// Test TOML
|
|
636
636
|
let toml_path = dir.path().join("config.toml");
|
|
@@ -641,9 +641,9 @@ max_request_body_bytes = 100000000
|
|
|
641
641
|
max_multipart_field_bytes = 200000000
|
|
642
642
|
"#,
|
|
643
643
|
)
|
|
644
|
-
.
|
|
644
|
+
.expect("Operation failed");
|
|
645
645
|
|
|
646
|
-
let toml_config = ServerConfig::from_file(&toml_path).
|
|
646
|
+
let toml_config = ServerConfig::from_file(&toml_path).expect("Operation failed");
|
|
647
647
|
assert_eq!(toml_config.max_request_body_bytes, 100_000_000);
|
|
648
648
|
assert_eq!(toml_config.max_multipart_field_bytes, 200_000_000);
|
|
649
649
|
|
|
@@ -656,9 +656,9 @@ max_request_body_bytes: 100000000
|
|
|
656
656
|
max_multipart_field_bytes: 200000000
|
|
657
657
|
"#,
|
|
658
658
|
)
|
|
659
|
-
.
|
|
659
|
+
.expect("Operation failed");
|
|
660
660
|
|
|
661
|
-
let yaml_config = ServerConfig::from_file(&yaml_path).
|
|
661
|
+
let yaml_config = ServerConfig::from_file(&yaml_path).expect("Operation failed");
|
|
662
662
|
assert_eq!(yaml_config.max_request_body_bytes, 100_000_000);
|
|
663
663
|
assert_eq!(yaml_config.max_multipart_field_bytes, 200_000_000);
|
|
664
664
|
|
|
@@ -672,9 +672,9 @@ max_multipart_field_bytes: 200000000
|
|
|
672
672
|
}
|
|
673
673
|
"#,
|
|
674
674
|
)
|
|
675
|
-
.
|
|
675
|
+
.expect("Operation failed");
|
|
676
676
|
|
|
677
|
-
let json_config = ServerConfig::from_file(&json_path).
|
|
677
|
+
let json_config = ServerConfig::from_file(&json_path).expect("Operation failed");
|
|
678
678
|
assert_eq!(json_config.max_request_body_bytes, 100_000_000);
|
|
679
679
|
assert_eq!(json_config.max_multipart_field_bytes, 200_000_000);
|
|
680
680
|
}
|
|
@@ -688,13 +688,13 @@ fn test_port_validation_bounds() {
|
|
|
688
688
|
// Valid port: 0
|
|
689
689
|
set_env("KREUZBERG_PORT", "0");
|
|
690
690
|
let mut config = ServerConfig::default();
|
|
691
|
-
config.apply_env_overrides().
|
|
691
|
+
config.apply_env_overrides().expect("Operation failed");
|
|
692
692
|
assert_eq!(config.port, 0);
|
|
693
693
|
|
|
694
694
|
// Valid port: 65535 (max u16)
|
|
695
695
|
set_env("KREUZBERG_PORT", "65535");
|
|
696
696
|
let mut config = ServerConfig::default();
|
|
697
|
-
config.apply_env_overrides().
|
|
697
|
+
config.apply_env_overrides().expect("Operation failed");
|
|
698
698
|
assert_eq!(config.port, 65535);
|
|
699
699
|
|
|
700
700
|
// Invalid port: too large
|
|
@@ -719,7 +719,7 @@ fn test_multiple_env_overrides_simultaneous() {
|
|
|
719
719
|
"KREUZBERG_MAX_MULTIPART_FIELD_BYTES",
|
|
720
720
|
]);
|
|
721
721
|
|
|
722
|
-
let dir = tempdir().
|
|
722
|
+
let dir = tempdir().expect("Operation failed");
|
|
723
723
|
let config_path = dir.path().join("config.toml");
|
|
724
724
|
|
|
725
725
|
fs::write(
|
|
@@ -729,7 +729,7 @@ host = "127.0.0.1"
|
|
|
729
729
|
port = 8000
|
|
730
730
|
"#,
|
|
731
731
|
)
|
|
732
|
-
.
|
|
732
|
+
.expect("Operation failed");
|
|
733
733
|
|
|
734
734
|
// Set all env vars
|
|
735
735
|
set_env("KREUZBERG_HOST", "192.168.1.1");
|
|
@@ -738,8 +738,8 @@ port = 8000
|
|
|
738
738
|
set_env("KREUZBERG_MAX_REQUEST_BODY_BYTES", "150000000");
|
|
739
739
|
set_env("KREUZBERG_MAX_MULTIPART_FIELD_BYTES", "250000000");
|
|
740
740
|
|
|
741
|
-
let mut config = ServerConfig::from_file(&config_path).
|
|
742
|
-
config.apply_env_overrides().
|
|
741
|
+
let mut config = ServerConfig::from_file(&config_path).expect("Operation failed");
|
|
742
|
+
config.apply_env_overrides().expect("Operation failed");
|
|
743
743
|
|
|
744
744
|
// All should be overridden
|
|
745
745
|
assert_eq!(config.host, "192.168.1.1");
|