diff options
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/bundle_tests.rs | 7 | ||||
-rw-r--r-- | tests/integration/jsr_tests.rs | 70 | ||||
-rw-r--r-- | tests/integration/npm_tests.rs | 20 | ||||
-rw-r--r-- | tests/integration/run_tests.rs | 96 |
4 files changed, 54 insertions, 139 deletions
diff --git a/tests/integration/bundle_tests.rs b/tests/integration/bundle_tests.rs index 0738a0cfe..20f883293 100644 --- a/tests/integration/bundle_tests.rs +++ b/tests/integration/bundle_tests.rs @@ -416,13 +416,6 @@ fn bundle_json_module_escape_sub() { ); } -itest!(lockfile_check_error { - args: "bundle --lock=bundle/lockfile/check_error.json http://127.0.0.1:4545/subdir/mod1.ts", - output: "bundle/lockfile/check_error.out", - exit_code: 10, - http_server: true, -}); - itest!(bundle { args: "bundle subdir/mod1.ts", output: "bundle/bundle.test.out", diff --git a/tests/integration/jsr_tests.rs b/tests/integration/jsr_tests.rs index 83d696093..7da0cc5b5 100644 --- a/tests/integration/jsr_tests.rs +++ b/tests/integration/jsr_tests.rs @@ -141,7 +141,12 @@ console.log(version);"#, .assert_matches_text("0.1.1\n"); let lockfile_path = temp_dir.path().join("deno.lock"); - let mut lockfile = Lockfile::new(lockfile_path.to_path_buf(), false).unwrap(); + let mut lockfile = Lockfile::with_lockfile_content( + lockfile_path.to_path_buf(), + &lockfile_path.read_to_string(), + false, + ) + .unwrap(); *lockfile .content .packages @@ -214,7 +219,7 @@ fn reload_info_not_found_cache_but_exists_remote() { .args("run --cached-only main.ts") .run(); output.assert_exit_code(1); - output.assert_matches_text("error: Failed to resolve version constraint. Try running again without --cached-only + output.assert_matches_text("error: JSR package manifest for '@denotest/add' failed to load. Could not resolve version constraint using only cached data. Try running again without --cached-only at file:///[WILDCARD]main.ts:1:21 "); @@ -251,7 +256,12 @@ console.log(version);"#, .assert_matches_text("0.1.1\n"); let lockfile_path = temp_dir.path().join("deno.lock"); - let mut lockfile = Lockfile::new(lockfile_path.to_path_buf(), false).unwrap(); + let mut lockfile = Lockfile::with_lockfile_content( + lockfile_path.to_path_buf(), + &lockfile_path.read_to_string(), + false, + ) + .unwrap(); let pkg_name = "@denotest/no-module-graph@0.1.1"; let original_integrity = get_lockfile_pkg_integrity(&lockfile, pkg_name); set_lockfile_pkg_integrity(&mut lockfile, pkg_name, "bad_integrity"); @@ -259,18 +269,24 @@ console.log(version);"#, let actual_integrity = test_context.get_jsr_package_integrity("@denotest/no-module-graph/0.1.1"); - let integrity_check_failed_msg = format!("error: Integrity check failed for http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1_meta.json + let integrity_check_failed_msg = format!("[WILDCARD]Integrity check failed for package. The source code is invalid, as it does not match the expected hash in the lock file. -Actual: {} -Expected: bad_integrity - at file:///[WILDCARD]/main.ts:1:21 + Package: @denotest/no-module-graph@0.1.1 + Actual: {} + Expected: bad_integrity + +This could be caused by: + * the lock file may be corrupt + * the source itself may be corrupt + +Use the --lock-write flag to regenerate the lockfile or --reload to reload the source code from the server. ", actual_integrity); test_context .new_command() .args("run --quiet main.ts") .run() .assert_matches_text(&integrity_check_failed_msg) - .assert_exit_code(1); + .assert_exit_code(10); // now try with a vendor folder temp_dir @@ -284,7 +300,7 @@ Expected: bad_integrity .args("run --quiet main.ts") .run() .assert_matches_text(&integrity_check_failed_msg) - .assert_exit_code(1); + .assert_exit_code(10); // now update to the correct integrity set_lockfile_pkg_integrity(&mut lockfile, pkg_name, &original_integrity); @@ -318,7 +334,7 @@ Expected: bad_integrity .args("run --quiet main.ts") .run() .assert_matches_text(&integrity_check_failed_msg) - .assert_exit_code(1); + .assert_exit_code(10); } #[test] @@ -335,39 +351,39 @@ console.log(add);"#, // test it properly checks the checksum on download test_context .new_command() - .args("run main.ts") + .args("run main.ts") .run() .assert_matches_text( "Download http://127.0.0.1:4250/@denotest/bad-manifest-checksum/meta.json Download http://127.0.0.1:4250/@denotest/bad-manifest-checksum/1.0.0_meta.json Download http://127.0.0.1:4250/@denotest/bad-manifest-checksum/1.0.0/mod.ts -error: Integrity check failed. +error: Integrity check failed in package. The package may have been tampered with. -Actual: 9a30ac96b5d5c1b67eca69e1e2cf0798817d9578c8d7d904a81a67b983b35cba -Expected: bad-checksum - at file:///[WILDCARD]main.ts:1:21 + Specifier: http://127.0.0.1:4250/@denotest/bad-manifest-checksum/1.0.0/mod.ts + Actual: 9a30ac96b5d5c1b67eca69e1e2cf0798817d9578c8d7d904a81a67b983b35cba + Expected: bad-checksum + +If you modified your global cache, run again with the --reload flag to restore its state. If you want to modify dependencies locally run again with the --vendor flag or specify `\"vendor\": true` in a deno.json then modify the contents of the vendor/ folder. ", ) - .assert_exit_code(1); + .assert_exit_code(10); // test it properly checks the checksum when loading from the cache test_context .new_command() - .args("run main.ts") + .args("run main.ts") .run() .assert_matches_text( - // ideally the two error messages would be the same... this one comes from - // deno_cache and the one above comes from deno_graph. The thing is, in deno_cache - // (source of this error) it makes sense to include the url in the error message - // because it's not always used in the context of deno_graph - "error: Integrity check failed for http://127.0.0.1:4250/@denotest/bad-manifest-checksum/1.0.0/mod.ts - -Actual: 9a30ac96b5d5c1b67eca69e1e2cf0798817d9578c8d7d904a81a67b983b35cba -Expected: bad-checksum - at file:///[WILDCARD]main.ts:1:21 + "error: Integrity check failed in package. The package may have been tampered with. + + Specifier: http://127.0.0.1:4250/@denotest/bad-manifest-checksum/1.0.0/mod.ts + Actual: 9a30ac96b5d5c1b67eca69e1e2cf0798817d9578c8d7d904a81a67b983b35cba + Expected: bad-checksum + +If you modified your global cache, run again with the --reload flag to restore its state. If you want to modify dependencies locally run again with the --vendor flag or specify `\"vendor\": true` in a deno.json then modify the contents of the vendor/ folder. ", ) - .assert_exit_code(1); + .assert_exit_code(10); } fn get_lockfile_pkg_integrity(lockfile: &Lockfile, pkg_name: &str) -> String { diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs index 63547cfce..923d151be 100644 --- a/tests/integration/npm_tests.rs +++ b/tests/integration/npm_tests.rs @@ -214,19 +214,11 @@ itest!(cached_only { }); itest!(import_map { - args: "run --allow-read --allow-env --import-map npm/import_map/import_map.json npm/import_map/main.js", - output: "npm/import_map/main.out", - envs: env_vars_for_npm_tests(), - http_server: true, - }); - -itest!(lock_file_integrity_failure { - args: "run --allow-read --allow-env --lock npm/lock_file/lock.json npm/lock_file/main.js", - output: "npm/lock_file/main.out", - envs: env_vars_for_npm_tests(), - http_server: true, - exit_code: 10, - }); + args: "run --allow-read --allow-env --import-map npm/import_map/import_map.json npm/import_map/main.js", + output: "npm/import_map/main.out", + envs: env_vars_for_npm_tests(), + http_server: true, +}); itest!(sub_paths { args: "run -A --quiet npm/sub_paths/main.jsx", @@ -1518,7 +1510,7 @@ This could be caused by: * the lock file may be corrupt * the source itself may be corrupt -Use "--lock-write" flag to regenerate the lockfile at "[WILDCARD]deno.lock". +Use the --lock-write flag to regenerate the lockfile at "[WILDCARD]deno.lock". "#) .assert_exit_code(10); } diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index f3fc18fee..91370a87c 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -821,40 +821,6 @@ itest!(lock_check_ok2 { http_server: true, }); -itest!(lock_dynamic_imports { - args: "run --lock=run/lock_dynamic_imports.json --allow-read --allow-net http://127.0.0.1:4545/run/013_dynamic_import.ts", - output: "run/lock_dynamic_imports.out", - exit_code: 10, - http_server: true, -}); - -itest!(lock_check_err { - args: "run --lock=run/lock_check_err.json http://127.0.0.1:4545/run/003_relative_import.ts", - output: "run/lock_check_err.out", - exit_code: 10, - http_server: true, -}); - -itest!(lock_check_err2 { - args: "run --lock=run/lock_check_err2.json run/019_media_types.ts", - output: "run/lock_check_err2.out", - exit_code: 10, - http_server: true, -}); - -itest!(config_file_lock_path { - args: "run --config=run/config_file_lock_path.json run/019_media_types.ts", - output: "run/config_file_lock_path.out", - exit_code: 10, - http_server: true, -}); - -itest!(lock_flag_overrides_config_file_lock_path { - args: "run --lock=run/lock_check_ok2.json --config=run/config_file_lock_path.json run/019_media_types.ts", - output: "run/019_media_types.ts.out", - http_server: true, -}); - itest!(lock_v2_check_ok { args: "run --quiet --lock=run/lock_v2_check_ok.json http://127.0.0.1:4545/run/003_relative_import.ts", @@ -868,33 +834,6 @@ itest!(lock_v2_check_ok2 { http_server: true, }); -itest!(lock_v2_dynamic_imports { - args: "run --lock=run/lock_v2_dynamic_imports.json --allow-read --allow-net http://127.0.0.1:4545/run/013_dynamic_import.ts", - output: "run/lock_v2_dynamic_imports.out", - exit_code: 10, - http_server: true, -}); - -itest!(lock_v2_check_err { - args: "run --lock=run/lock_v2_check_err.json http://127.0.0.1:4545/run/003_relative_import.ts", - output: "run/lock_v2_check_err.out", - exit_code: 10, - http_server: true, -}); - -itest!(lock_v2_check_err2 { - args: "run --lock=run/lock_v2_check_err2.json run/019_media_types.ts", - output: "run/lock_v2_check_err2.out", - exit_code: 10, - http_server: true, -}); - -itest!(lock_only_http_and_https { - args: "run --lock=run/lock_only_http_and_https/deno.lock run/lock_only_http_and_https/main.ts", - output: "run/lock_only_http_and_https/main.out", - http_server: true, -}); - #[test] fn lock_no_declaration_files() { let context = TestContextBuilder::new() @@ -4562,13 +4501,6 @@ async fn websocket_server_idletimeout() { assert_eq!(child.wait().unwrap().code(), Some(123)); } -itest!(auto_discover_lockfile { - args: "run run/auto_discover_lockfile/main.ts", - output: "run/auto_discover_lockfile/main.out", - http_server: true, - exit_code: 10, -}); - itest!(no_lock_flag { args: "run --no-lock run/no_lock_flag/main.ts", output: "run/no_lock_flag/main.out", @@ -4576,20 +4508,6 @@ itest!(no_lock_flag { exit_code: 0, }); -itest!(config_file_lock_false { - args: "run --config=run/config_file_lock_boolean/false.json run/config_file_lock_boolean/main.ts", - output: "run/config_file_lock_boolean/false.main.out", - http_server: true, - exit_code: 0, -}); - -itest!(config_file_lock_true { - args: "run --config=run/config_file_lock_boolean/true.json run/config_file_lock_boolean/main.ts", - output: "run/config_file_lock_boolean/true.main.out", - http_server: true, - exit_code: 10, -}); - itest!(permission_args { args: "run run/001_hello.js --allow-net", output: "run/permission_args.out", @@ -4812,21 +4730,17 @@ console.log(returnsHi());"#, .join("mod1.ts"); mod1_file.write("export function returnsHi() { return 'bye bye bye'; }"); - // won't match the lockfile now - deno_run_cmd - .run() - .assert_matches_text(r#"error: The source code is invalid, as it does not match the expected hash in the lock file. - Specifier: http://localhost:4545/subdir/mod1.ts - Lock file: [WILDCARD]deno.lock -"#) - .assert_exit_code(10); + // this is fine with a lockfile because users are supposed to be able + // to modify the vendor folder + deno_run_cmd.run().assert_matches_text("bye bye bye\n"); // try updating by deleting the lockfile let lockfile = temp_dir.path().join("deno.lock"); lockfile.remove_file(); cache_command.run(); - // now it should run + // should still run and the lockfile should be recreated + // (though with the checksum from the vendor folder) deno_run_cmd.run().assert_matches_text("bye bye bye\n"); assert!(lockfile.exists()); |