aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--setup.py1
-rw-r--r--tests/vnfreq/test_pkg_reqs.py33
-rw-r--r--vnfsdk_pkgtools/vnfreq/pkg_reqs.py18
3 files changed, 48 insertions, 4 deletions
diff --git a/setup.py b/setup.py
index cba146a..395931e 100644
--- a/setup.py
+++ b/setup.py
@@ -88,6 +88,7 @@ setup(
],
'vnfsdk.pkgtools.vnfreq': [
'R-66070 = vnfsdk_pkgtools.vnfreq.pkg_reqs:R66070',
+ 'R-77707 = vnfsdk_pkgtools.vnfreq.pkg_reqs:R77707',
],
},
diff --git a/tests/vnfreq/test_pkg_reqs.py b/tests/vnfreq/test_pkg_reqs.py
index b712212..b83a860 100644
--- a/tests/vnfreq/test_pkg_reqs.py
+++ b/tests/vnfreq/test_pkg_reqs.py
@@ -17,11 +17,36 @@ import pytest
from vnfsdk_pkgtools import vnfreq
-def test_R66070_fail(mocker):
+
+def check_result(reqid, reader, tosca, expected_fail_msg):
+ tester = vnfreq.get_vnfreq_tester(reqid)
+ tester.check(reader, tosca)
+ if expected_fail_msg:
+ assert isinstance(tester.err, vnfreq.VnfRequirementError)
+ assert expected_fail_msg in str(tester.err)
+ else:
+ assert tester.err == 0
+
+
+def test_R66070(mocker):
reader = mocker.Mock()
reader.manifest = None
+ check_result('R-66070', reader, None, 'No manifest file found')
+
+
+def test_R77707(mocker, tmpdir):
+ # check only manifest file - success
+ p1 = tmpdir.join("manifest.mf")
+ p1.write("manifest")
+ reader = mocker.Mock()
+ reader.destination = str(tmpdir)
+ reader.entry_manifest_file = "manifest.mf"
+ reader.manifest.digests = {}
+ check_result('R-77707', reader, None, None)
- tester = vnfreq.get_vnfreq_tester("R-66070")
- tester.check(reader, None)
- assert isinstance(tester.err, vnfreq.VnfRequirementError)
+ # check additional file - fail
+ p2 = tmpdir.mkdir('sub').join("non-existing")
+ p2.write("non existing")
+ check_result('R-77707', reader, None,
+ 'Package component sub/non-existing not found in manifest file')
diff --git a/vnfsdk_pkgtools/vnfreq/pkg_reqs.py b/vnfsdk_pkgtools/vnfreq/pkg_reqs.py
index c5b20f7..5bc5c6b 100644
--- a/vnfsdk_pkgtools/vnfreq/pkg_reqs.py
+++ b/vnfsdk_pkgtools/vnfreq/pkg_reqs.py
@@ -14,10 +14,12 @@
#
import abc
+import os
import six
from stevedore import driver
+from vnfsdk_pkgtools.packager import csar
from vnfsdk_pkgtools import vnfreq
@@ -35,3 +37,19 @@ class R66070(vnfreq.TesterBase):
# Existing reader.manifest already means a valid manifest file
# no futher check needed.
return 0
+
+
+class R77707(vnfreq.TesterBase):
+ ID = "R-77707"
+ DESC = ("The VNF provider MUST include a Manifest File that contains "
+ "a list of all the components in the VNF package.")
+
+ def _do_check(self, reader, tosca):
+ for root, dirs, files in os.walk(reader.destination):
+ for file in files:
+ full_path = os.path.join(root, file)
+ rel_path = os.path.relpath(full_path, reader.destination)
+ if rel_path not in (reader.entry_manifest_file, csar.META_FILE):
+ if rel_path not in reader.manifest.digests:
+ raise vnfreq.VnfRequirementError("Package component %s not found in manifest file" % rel_path)
+ return 0