7139743 license actions without a path can cause a stacktrace s11u1-sru s11u1sru01
authorabhinandan.ekande@oracle.com
Fri, 19 Oct 2012 10:27:26 +0530
branchs11u1-sru
changeset 2824 907fe02baa47
parent 2822 14b76dbcd59c
child 2846 bc3654acb507
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	Mon Oct 15 14:08:04 2012 +0530
+++ b/src/modules/actions/__init__.py	Fri Oct 19 10:27:26 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	Mon Oct 15 14:08:04 2012 +0530
+++ b/src/tests/cli/t_pkgsend.py	Fri Oct 19 10:27:26 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):