7139743 license actions without a path can cause a stacktrace s12b06
authorabhinandan.ekande@oracle.com
Tue, 25 Sep 2012 14:57:02 +0530
changeset 2800 0549c80ed717
parent 2799 0358e521cc2d
child 2801 0dd4f708470c
7139743 license actions without a path can cause a stacktrace
src/modules/actions/__init__.py
src/tests/cli/t_pkgsend.py
--- a/src/modules/actions/__init__.py	Fri Sep 14 10:29:11 2012 +0530
+++ b/src/modules/actions/__init__.py	Tue Sep 25 14:57:02 2012 +0530
@@ -346,7 +346,10 @@
                 return None, None
 
         if payload == "NOHASH":
-                filepath = os.path.sep + action.attrs["path"]
+                try:
+                        filepath = os.path.sep + action.attrs["path"]
+                except KeyError:
+                        raise InvalidPathAttributeError(action)
         else:
                 filepath = payload
 
--- a/src/tests/cli/t_pkgsend.py	Fri Sep 14 10:29:11 2012 +0530
+++ b/src/tests/cli/t_pkgsend.py	Tue Sep 25 14:57:02 2012 +0530
@@ -1269,6 +1269,17 @@
                 self.pkgsend("", "-s %s publish %s" %
                     (self.dc.get_repo_url(), mfpath), exit=1)
 
+        def test_25_pkgsend_publish_nohash_license(self):
+                """Verify that publishing a manifest with hash attribute
+                missing for license action doesn't traceback"""
+
+                durl = self.dc.get_depot_url()
+                # Should fail because hash attribute is missing.
+                self.pkgsend_bulk(durl,
+                    """open [email protected]
+                    add license license=copyright
+                    close""", exit=1)
+
 
 class TestPkgsendHardlinks(pkg5unittest.CliTestCase):