3714 cannot uninstall package after authority removal
authorDanek Duvall <danek.duvall@sun.com>
Tue, 07 Oct 2008 10:20:20 -0700
changeset 568 52eea0be5030
parent 567 ea1d96e269a4
child 569 48f7e9d2b1ac
3714 cannot uninstall package after authority removal
src/modules/actions/depend.py
src/modules/client/image.py
src/tests/baseline.txt
src/tests/cli/t_twodepot.py
--- a/src/modules/actions/depend.py	Mon Oct 06 16:41:21 2008 -0700
+++ b/src/modules/actions/depend.py	Tue Oct 07 10:20:20 2008 -0700
@@ -189,7 +189,7 @@
 
                 if not installed_version:
                         if type == "require":
-                                return ["Required dependency %s is not installed" % fm]
+                                return ["Required dependency %s is not installed" % f]
                         installed_version = image.older_version_installed(f)
                         if installed_version:
                                 return ["%s dependency %s is downrev (%s)" %
--- a/src/modules/client/image.py	Mon Oct 06 16:41:21 2008 -0700
+++ b/src/modules/client/image.py	Tue Oct 07 10:20:20 2008 -0700
@@ -1091,9 +1091,8 @@
         def get_version_installed(self, pfmri):
                 """Returns an fmri of the installed package matching the
                 package stem of the given fmri or None if no match is found."""
-                target = pfmri.get_pkg_stem()
                 for f in self.gen_installed_pkgs():
-                        if f.get_pkg_stem() == target:
+                        if self.fmri_is_same_pkg(f, pfmri):
                                 return f
                 return None
 
--- a/src/tests/baseline.txt	Mon Oct 06 16:41:21 2008 -0700
+++ b/src/tests/baseline.txt	Tue Oct 07 10:20:20 2008 -0700
@@ -335,10 +335,13 @@
 cli.t_twodepot.py TestTwoDepots.test_basics_1|pass
 cli.t_twodepot.py TestTwoDepots.test_basics_2|pass
 cli.t_twodepot.py TestTwoDepots.test_basics_3|pass
+cli.t_twodepot.py TestTwoDepots.test_uninstall_from_wrong_authority|pass
 cli.t_twodepot.py TestTwoDepots.test_upgrade_non_preferred_to_preferred|pass
 cli.t_twodepot.py TestTwoDepots.test_upgrade_non_preferred_to_preferred_incorporated|pass
 cli.t_twodepot.py TestTwoDepots.test_upgrade_preferred_to_non_preferred|pass
 cli.t_twodepot.py TestTwoDepots.test_upgrade_preferred_to_non_preferred_incorporated|pass
+cli.t_twodepot.py TestTwoDepots.test_zzz_uninstall_after_preferred_authority_change|pass
+cli.t_twodepot.py TestTwoDepots.test_zzz_uninstall_after_preferred_authority_removal|pass
 cli.t_upgrade.py TestUpgrade.test_upgrade1|pass
 cli.t_upgrade.py TestUpgrade.test_upgrade2|pass
 cli.t_upgrade.py TestUpgrade.test_upgrade3|pass
--- a/src/tests/cli/t_twodepot.py	Mon Oct 06 16:41:21 2008 -0700
+++ b/src/tests/cli/t_twodepot.py	Tue Oct 07 10:20:20 2008 -0700
@@ -191,6 +191,33 @@
                 self.pkg("install [email protected]")
                 self.pkg("list [email protected]")
 
+        def test_uninstall_from_wrong_authority(self):
+                """Install a package from an authority and try to remove it
+                using a different authority name; this should fail."""
+                self.pkg("install foo")
+                self.pkg("uninstall pkg://test2/foo", exit=1)
+                # Check to make sure that uninstalling using the explicit
+                # authority works
+                self.pkg("uninstall pkg://test1/foo")
+
+        def test_zzz_uninstall_after_preferred_authority_change(self):
+                """Install a package from the preferred authority, change the
+                preferred authority, and attempt to remove the package."""
+                self.pkg("install [email protected]")
+                self.pkg("set-authority -P test2")
+                self.pkg("uninstall foo")
+                # Change the image metadata back to where it was, in preparation
+                # for the next test.
+                self.pkg("set-authority -P test1")
+
+        def test_zzz_uninstall_after_preferred_authority_removal(self):
+                """Install a package from the preferred authority, remove the
+                preferred authority, and attempt to remove the package."""
+                self.pkg("install [email protected]")
+                self.pkg("set-authority -P test2")
+                self.pkg("unset-authority test1")
+                self.pkg("uninstall foo")
+
 if __name__ == "__main__":
         unittest.main()