diff --git a/BUILD.gn b/BUILD.gn index d9787e3c04d3d65e009e6f8b6d875cc8236f30b7..e7238b50bd6cdaa74f9c1fad265647b2e6952376 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -21,5 +21,8 @@ group("fuzztest") { group("unittest") { testonly = true - deps = [ "test/unittest:sys_installer_unittest" ] + deps = [ + "test/unittest:sys_installer_unittest", + "test/unittest/module_update_test:module_update_package_test" + ] } diff --git a/test/unittest/module_update_test/BUILD.gn b/test/unittest/module_update_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..661a788349597d745527ff6157cbf950c9cb06c4 --- /dev/null +++ b/test/unittest/module_update_test/BUILD.gn @@ -0,0 +1,45 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/templates/update/module_update.gni") + +ohos_shared_library("module_update_library_test") { + stable = true + sources = [ "module_update_library_test.cpp" ] + part_name = "sys_installer" +} + +ohos_executable("module_update_binary_test") { + stable = true + sources = [ "module_update_binary_test.cpp" ] + install_enable = true + part_name = "sys_installer" +} + +ohos_module_package("module_update_package_test") { + libraries = [ + ":module_update_library_test", + ] + + binaries = [ + ":module_update_binary_test" + ] + + module_config = "config.json" + + zip_private_key = "key/rsa_private_key2048.pem" + sign_cert = "sign_cert/signing_cert.crt" + + part_name = "sys_installer" +} \ No newline at end of file diff --git a/test/unittest/module_update_test/config.json b/test/unittest/module_update_test/config.json new file mode 100644 index 0000000000000000000000000000000000000000..e871525956f51b6bca5942d45f988d74bf5c525f --- /dev/null +++ b/test/unittest/module_update_test/config.json @@ -0,0 +1,5 @@ +{ + "name": "module_test", + "id": 1234, + "version": "1.0.1" +} \ No newline at end of file diff --git a/test/unittest/module_update_test/key/rsa_private_key2048.pem b/test/unittest/module_update_test/key/rsa_private_key2048.pem new file mode 100755 index 0000000000000000000000000000000000000000..b44ddc3754ce095dc508675d91b65d5d08d47b28 --- /dev/null +++ b/test/unittest/module_update_test/key/rsa_private_key2048.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA49SUn9WClk/whGbVLVc8ol4FiSt/jw5EZ8T9PVFiYirAf4Cm +R0/bBZhlGiHtfFSOeHwednGhdbDVPb9dZl/a9SwhuCPhhQVICne8RvqzgJFsgpO5 +CBxW1xspM/HDuz9c5gOLnu1+df3EASsv56xh6hH1LOe5QkGEA5QPZ9WoRlOJaP5T +ndZ+BEih4IPgQswRlCRFpx/Idiv8gi4bg9ZxmJ8CVMusSPHGm64dvlkn+LSZ9KMh +vhWFSZAFtcHK9hz55wQwMrhN+LCjVZA+MPUvaU1L+cT0ZDh+qxH0MQuL1wbgkd1b +HfYCUu+8D2q0PLfk4d6ncZRvjiChalX5g2mVLQIDAQABAoIBACIhhKp1N/0AuM19 +Ak6qlQDWCQpFo/RwdLr+/dkjyhNeyDvRsBda1Tr/W5YQox1PJZDTN1UTLNcOyMNZ +WcqubYTxOZP2fCCLbAF1cpVHlYCbSKA/NScL586N2RxZCbORiH9E5LPIbHuMqsJq +D+ErJ/gC/LHffRd57ScEFVK+5VizfrCddBsPbbF2aCoQZyiDX4DBIQ+kMUgNChN7 +I7J5yA8DrTjzEATArOlnKUvnlVx/jKT3ncCYQujxwQlzJWDbaSgon5ZhjBazSUiC +eHPbE+bCvcD90pWddUByeS885eMDIOhErJFS+lYYdI+bT3T5rILzK8wR2CupMhkX +a9RYuZkCgYEA9lGoxWyWIFK3ymeT6DOhqK6Cr7MJiYgAvgk+fA3dDVsGuEM6Xy/O +wwt915cZvKzcb018AmeSVwYvy7l3EuYDKXP/YzntV7OLuH9Fu3zuoZ4U3VOHtKLD +VOHeWO/dg/BB96mP2xxltwv64ZT3gPf9MIpDmgVnL4QREUG4K6T/XEsCgYEA7Mjl +8AK/Hu9cIPAwB0NNCU3ptnlznu42c+lj1SHfCtYV9me14nVEIynevyniZ3y8jMi6 +5Ozo/Rt26W+WuxZj6vPH2FBtB3kMgxDPDGunphl6wKJ+3RqvBrErAu9AW6e/H5NP +gxU8V8PVO+Qo3CwIhjnjkobi7nBXe6gU1iqkeWcCgYAubqJD5P4/xZgDvZayFNmK +dKsJ99P6avrI1/FBbVOYKuqPXYzpWJe/SLFGLKObX3KGQLL5uRBq+y2TV7jMhTNf +YxBnYgoNmDjkZIl+mERbjvMb7Z0NPglYPOOvHDhDoMyupPYLNcUuxkFauLwXQagm +uEmaBR64ZErbV+ohwA6rFQKBgQC9P6RnvAo9E1ozCUWZyHSd5yPQsCl08TecVQFx +q2y1IH7VPfblVIxs/l4Fs9g8ljms3BJkPeXJxlW4JXP3e+HIO6eSgFVkD5+scZbK +epC39M1jgXycA2O4mYmjAs4Rc3USK471Wdes3dxjzevKbXcysLnutthRcoC5WJGu +ys5CKQKBgQDpYc/LxUR4K5k55kQyPofkyIlVK/De3VwsD7eCeRDb1jfcF52Xuuxg +Pm6RlIvVRy7RsrG7kKqWCiVAFauQQswW6DDBbjmrFd6CrruEAqwwgbCHZjE5Dy+0 +ZKsKfkm/bymEiq7ATwzvWfuU3T3R0O9+S1RbTNYo+D3N2soTfPnXyw== +-----END RSA PRIVATE KEY----- diff --git a/test/unittest/module_update_test/module_update_binary_test.cpp b/test/unittest/module_update_test/module_update_binary_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..955578c80224c2484329500ef54e6aaa308adf77 --- /dev/null +++ b/test/unittest/module_update_test/module_update_binary_test.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +void module_update_package_test() {} + +int main() +{ + module_update_package_test(); + return 0; +} \ No newline at end of file diff --git a/test/unittest/module_update_test/module_update_library_test.cpp b/test/unittest/module_update_test/module_update_library_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b724d292366b55b239cc031e4c9255b282332ba4 --- /dev/null +++ b/test/unittest/module_update_test/module_update_library_test.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +void module_update_package_test() {} \ No newline at end of file diff --git a/test/unittest/module_update_test/sign_cert/signing_cert.crt b/test/unittest/module_update_test/sign_cert/signing_cert.crt new file mode 100755 index 0000000000000000000000000000000000000000..eca5d72cea8e87bc4b41f4e85570e32fbc23f69e --- /dev/null +++ b/test/unittest/module_update_test/sign_cert/signing_cert.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDazCCAlOgAwIBAgIUDbbfN0ry6xlKrFyylM9asKzjANYwDQYJKoZIhvcNAQEL +BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM +GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMTAyMjUxMjA2MTNaFw0yMjAy +MjUxMjA2MTNaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw +HwYDV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