-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5914 from BengangY/feature/non-cdn-update
Merge feature/non-cdn-update to master
- Loading branch information
Showing
31 changed files
with
965 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) Cloud Software Group, Inc. | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published | ||
# by the Free Software Foundation; version 2.1 only. with the special | ||
# exception on linking described in file LICENSE. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
|
||
test_file_dir=$1 | ||
mkdir -p "${test_file_dir}" | ||
cd "${test_file_dir}" || exit | ||
|
||
echo "========= Generating regular tar file =========" | ||
echo "This is file-1" > file1.txt | ||
echo "This is file-2" > file2.txt | ||
tar -cvf test_tar_ext_regular.tar file1.txt file2.txt | ||
|
||
echo "========= Generating tar file with illegal path =========" | ||
mkdir test_illegal_dir | ||
touch test_illegal_dir/file | ||
tar --absolute-names -cvf test_tar_ext_illegal_path.tar test_illegal_dir/../file1.txt | ||
|
||
echo "========= Generating tar file trying to escape the current dir =========" | ||
mkdir current_dir | ||
mkdir another_dir | ||
touch current_dir/file | ||
touch another_dir/escaped_file | ||
tar --absolute-names -cvf current_dir/test_tar_ext_trying_to_escape.tar current_dir/../another_dir/escaped_file | ||
|
||
echo "========= Generating tar file with absolute path starting from '/' =========" | ||
tar --absolute-names -cvf test_tar_ext_absolute_path.tar /usr/bin/ls | ||
|
||
echo "========= Generating tar file with unsupported file type =========" | ||
ln -s file1.txt link | ||
tar -cvf test_tar_ext_unsupported_file_type.tar link | ||
|
||
echo "========= Generating tar file unpacked exceeds max size limit =========" | ||
dd if=/dev/zero of=file1 bs=1M count=1 | ||
dd if=/dev/zero of=file2 bs=1M count=1 | ||
dd if=/dev/zero of=file3 bs=1M count=1 | ||
tar -cvf test_tar_ext_unpacked_exceeds_max_size.tar file1 file2 file3 | ||
|
||
echo "========= Generating size mismatch tar file =========" | ||
split -b 100000 test_tar_ext_unpacked_exceeds_max_size.tar test_tar_ext_file_size_mismatch. | ||
mv test_tar_ext_file_size_mismatch.aa test_tar_ext_file_size_mismatch.tar | ||
|
||
echo "========= Generating incomplete tar file =========" | ||
mv file1.txt test_tar_ext_file_incomplete.tar | ||
|
||
echo "========= Generating corrupted tar file =========" | ||
cp test_tar_ext_regular.tar test_tar_ext_corrupted_file.tar | ||
sed -i 's/file1.txt/file3.txt/g' test_tar_ext_corrupted_file.tar | ||
|
||
echo "========= Generating unpacking failure file =========" | ||
cp test_tar_ext_regular.tar test_tar_ext_unpacking_failure.tar | ||
sed -i 's/file1.txt/file.txt/g' test_tar_ext_unpacking_failure.tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
(* | ||
* Copyright (c) Cloud Software Group, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation; version 2.1 only. with the special | ||
* exception on linking described in file LICENSE. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
*) | ||
|
||
module T = Test_common | ||
|
||
let test_set_remote_and_bundle_repos () = | ||
let __context = T.make_test_database () in | ||
let name_label = "remote" in | ||
let name_description = "remote" in | ||
let binary_url = "https://repo.example.com" in | ||
let source_url = "https://repo-src.example.com" in | ||
let gpgkey_path = "" in | ||
let ref_remote = | ||
Repository.introduce ~__context ~name_label ~name_description ~binary_url | ||
~source_url ~update:true ~gpgkey_path | ||
in | ||
let ref_bundle = | ||
Repository.introduce_bundle ~__context ~name_label:"bundle" | ||
~name_description:"bundle" | ||
in | ||
let self = Helpers.get_pool ~__context in | ||
Alcotest.check_raises "test_set_remote_and_bundle_repos" | ||
Api_errors.(Server_error (bundle_repo_should_be_single_enabled, [])) | ||
(fun () -> | ||
Xapi_pool.set_repositories ~__context ~self | ||
~value:[ref_remote; ref_bundle] | ||
) | ||
|
||
let test_add_bundle_repo () = | ||
let __context = T.make_test_database () in | ||
let name_label = "remote" in | ||
let name_description = "remote" in | ||
let binary_url = "https://repo.example.com" in | ||
let source_url = "https://repo-src.example.com" in | ||
let gpgkey_path = "" in | ||
let ref_remote = | ||
Repository.introduce ~__context ~name_label ~name_description ~binary_url | ||
~source_url ~update:true ~gpgkey_path | ||
in | ||
let ref_bundle = | ||
Repository.introduce_bundle ~__context ~name_label:"bundle" | ||
~name_description:"bundle" | ||
in | ||
let self = Helpers.get_pool ~__context in | ||
Alcotest.check_raises "test_add_bundle_repo" | ||
Api_errors.(Server_error (bundle_repo_should_be_single_enabled, [])) | ||
(fun () -> | ||
Xapi_pool.set_repositories ~__context ~self ~value:[ref_remote] ; | ||
Xapi_pool.add_repository ~__context ~self ~value:ref_bundle | ||
) | ||
|
||
let test_add_remote_repo () = | ||
let __context = T.make_test_database () in | ||
let name_label = "remote" in | ||
let name_description = "remote" in | ||
let binary_url = "https://repo.example.com" in | ||
let source_url = "https://repo-src.example.com" in | ||
let gpgkey_path = "" in | ||
let ref_remote = | ||
Repository.introduce ~__context ~name_label ~name_description ~binary_url | ||
~source_url ~update:true ~gpgkey_path | ||
in | ||
let ref_bundle = | ||
Repository.introduce_bundle ~__context ~name_label:"bundle" | ||
~name_description:"bundle" | ||
in | ||
let self = Helpers.get_pool ~__context in | ||
Alcotest.check_raises "test_add_remote_repo" | ||
Api_errors.(Server_error (bundle_repo_should_be_single_enabled, [])) | ||
(fun () -> | ||
Xapi_pool.set_repositories ~__context ~self ~value:[ref_bundle] ; | ||
Xapi_pool.add_repository ~__context ~self ~value:ref_remote | ||
) | ||
|
||
let test_can_not_enable_bundle_repo_auto_sync () = | ||
let __context = T.make_test_database () in | ||
let ref_bundle = | ||
Repository.introduce_bundle ~__context ~name_label:"bundle" | ||
~name_description:"bundle" | ||
in | ||
let self = Helpers.get_pool ~__context in | ||
Alcotest.check_raises "test_can_not_enable_bundle_repo_auto_sync" | ||
Api_errors.(Server_error (can_not_sync_updates, [])) | ||
(fun () -> | ||
Xapi_pool.set_repositories ~__context ~self ~value:[ref_bundle] ; | ||
Xapi_pool.set_update_sync_enabled ~__context ~self ~value:true | ||
) | ||
|
||
let test = | ||
[ | ||
( "test_set_remote_and_bundle_repos" | ||
, `Quick | ||
, test_set_remote_and_bundle_repos | ||
) | ||
; ("test_add_bundle_repo", `Quick, test_add_bundle_repo) | ||
; ("test_add_remote_repo", `Quick, test_add_remote_repo) | ||
; ( "test_can_not_enable_bundle_repo_auto_sync" | ||
, `Quick | ||
, test_can_not_enable_bundle_repo_auto_sync | ||
) | ||
] | ||
|
||
let () = | ||
Suite_init.harness_init () ; | ||
Alcotest.run "Test Pool Repository suite" [("Test_pool_repository", test)] |
Oops, something went wrong.