diff options
author | Lianhao Lu <lianhao.lu@intel.com> | 2018-03-24 22:36:08 +0800 |
---|---|---|
committer | Lianhao Lu <lianhao.lu@intel.com> | 2018-03-26 13:37:13 +0800 |
commit | 432bca4baa6d704301b0c6e24026018212ecc368 (patch) | |
tree | c63856b57c3ef65fd4ebb5304cc437e4aa0cc895 /tests/packager/test_utils.py | |
parent | eebc0c50203156aafbbb3cf79469f1701c7f8f7f (diff) |
Support of file digest in manifest file
Per sol-004, section 4.3.2, the csar manifest file should include the
digest of individual files contained in the package. This patch lays the
foundation of that support.
- Added content check of manifest file
- Added support of generating local file digest in manifest file
Change-Id: If575012d319e6f6aa0e2259e7405d8a2b6f8f338
Issue-ID: VNFSDK-174
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
Diffstat (limited to 'tests/packager/test_utils.py')
-rw-r--r-- | tests/packager/test_utils.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/packager/test_utils.py b/tests/packager/test_utils.py new file mode 100644 index 0000000..03b3f24 --- /dev/null +++ b/tests/packager/test_utils.py @@ -0,0 +1,28 @@ +# Copyright (c) 2018 Intel Corp. All rights reserved. +# +# 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 os + +from vnfsdk_pkgtools.packager import utils + +CONTENT = "needToBeHashed" +SHA256 = "20a480339aa4371099f9503511dcc5a8051ce3884846678ced5611ec64bbfc9c" +SHA512 = "dbed8672e752d51d0c7ca42050f67faf1534e58470bba96e787df5c4cf6a4f8ecf7ad45fb9307adbc5b9dec8432627d86b3eb1d3d43ee9c5e93f754ff2825320" + +def test_cal_file_hash(tmpdir): + p = tmpdir.join("file_to_hash.txt") + p.write(CONTENT) + assert SHA512 == utils.cal_file_hash("", str(p), 'SHA512') + assert SHA256 == utils.cal_file_hash(p.dirname, p.basename, 'sha256') |