t_pkg_depotd.py revision 1895
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen# CDDL HEADER START
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen# The contents of this file are subject to the terms of the
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen# Common Development and Distribution License (the "License").
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen# You may not use this file except in compliance with the License.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen# See the License for the specific language governing permissions
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen# and limitations under the License.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen# When distributing Covered Code, include this CDDL HEADER in each
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen# If applicable, add the following below this CDDL HEADER, with the
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen# fields enclosed by brackets "[]" replaced with your own identifying
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen# information: Portions Copyright [yyyy] [name of copyright owner]
2de709376eddc50ec5fa470358bb57cf0a87bb1fTimo Sirainen# CDDL HEADER END
2de709376eddc50ec5fa470358bb57cf0a87bb1fTimo Sirainen# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainenclass TestPkgDepot(pkg5unittest.SingleDepotTestCase):
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # Only start/stop the depot once (instead of for every test)
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen open foo@1.0,5.11-0
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen add dir path=tmp/foo mode=0755 owner=root group=bin
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen open bar@1.0,5.11-0
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen add dir path=tmp/bar mode=0755 owner=root group=bin
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen open quux@1.0,5.11-0
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen add dir mode=0755 owner=root group=bin path=/bin
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen add file tmp/cat mode=0555 owner=root group=bin path=/bin/cat
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen add file tmp/libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.so.1
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen open info@1.0,5.11-0
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen open update@1.0,5.11-0
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen open update@1.1,5.11-0
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen open system/libc@1.0,5.11-0
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen add set name="description" value="Package to test package names with slashes"
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen add dir path=tmp/foo mode=0755 owner=root group=bin
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen add depend type=require fmri=pkg:/SUNWcsl
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # This suite, for obvious reasons, actually needs a depot.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen pkg5unittest.SingleDepotTestCase.setUp(self, start_depot=True)
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen """ Ping the depot several times """
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen """ Start and stop the depot several times """
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen """ Send package quux@1.0 an action at a time, restarting the
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen depot server after each one is sent, to ensure that
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen transactions work across depot restart. Then verify that
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen the package was successfully added by performing some
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen basic operations. """
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen self.pkgsend(durl, "open foo@1.0,-2.0", exit=1)
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen dir_file = os.path.join(depotpath, "search.dir")
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen pag_file = os.path.join(depotpath, "search.pag")
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen """Publish a package and then verify that the depot /info
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen operation doesn't fail."""
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen plist = self.pkgsend_bulk(depot_url, self.info10)
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen misc.versioned_urlopen(depot_url, "info", [0], plist[0])
2de709376eddc50ec5fa470358bb57cf0a87bb1fTimo Sirainen """Verify that a depot will return a 400 (Bad Request) error
2de709376eddc50ec5fa470358bb57cf0a87bb1fTimo Sirainen whenever it is provided malformed FMRIs."""
2de709376eddc50ec5fa470358bb57cf0a87bb1fTimo Sirainen "BRCMbnx%400.5.11%2C5.11-0.101%3A20081119T231649a"):
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen """Publish a package with slashes in the name, and then verify
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen that the depot manifest and info operations work regardless of
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen the encoding."""
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen plist = self.pkgsend_bulk(depot_url, self.system10)
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # First, try it un-encoded.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen misc.versioned_urlopen(depot_url, "info", [0], plist[0])
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen misc.versioned_urlopen(depot_url, "manifest", [0], plist[0])
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # Second, try it encoded.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen misc.versioned_urlopen(depot_url, "info", [0],
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen misc.versioned_urlopen(depot_url, "manifest", [0],
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen """Testing depotcontroller.refresh()."""
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen depot_file_url = "file://%s" % self.dc.get_repodir()
d290217adc3d17ba82fd81f164da3c2b88489700Timo Sirainen self.pkg("install bar", exit=4) # nothing to do
d290217adc3d17ba82fd81f164da3c2b88489700Timo Sirainen """Verify that files outside of the package content web root
d290217adc3d17ba82fd81f164da3c2b88489700Timo Sirainen cannot be accessed, and that files inside can be."""
d290217adc3d17ba82fd81f164da3c2b88489700Timo Sirainen # Since /usr/share/lib/pkg/web/ is the content web root,
d290217adc3d17ba82fd81f164da3c2b88489700Timo Sirainen # any attempts to go outside that directory should fail
d290217adc3d17ba82fd81f164da3c2b88489700Timo Sirainen # with a 404 error.
d290217adc3d17ba82fd81f164da3c2b88489700Timo Sirainen urllib2.urlopen("%s/../../../../bin/pkg" % depot_url)
d290217adc3d17ba82fd81f164da3c2b88489700Timo Sirainen f = urllib2.urlopen("%s/robots.txt" % depot_url)
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen """Verify that starting a depot server in readonly mode with
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen a non-existent or empty repo_dir fails and that permissions
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen errors are handled correctly during creation. Then verify
d290217adc3d17ba82fd81f164da3c2b88489700Timo Sirainen that starting a depot with the same directory in publishing
d290217adc3d17ba82fd81f164da3c2b88489700Timo Sirainen mode works and then a readonly depot again after that works.
d290217adc3d17ba82fd81f164da3c2b88489700Timo Sirainen dpath = os.path.join(self.test_root, "repo_create")
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # First, test readonly mode with a repo_dir that doesn't exist.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # Next, test readonly mode with a repo_dir that is empty.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # Next, test readwrite (publishing) mode with a non-existent
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # Next, test readwrite (publishing) mode with a non-existent
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # repo_dir for an unprivileged user.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen su_wrap, su_end = self.get_su_wrapper(su_wrap=True)
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # Even if this test fails, this wrapper must be reset.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # Next, test readwrite (publishing) mode with an empty repo_dir.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # Finally, re-test readonly mode now that the repository has
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainen # been created.
a24665de9d5c773115a5918e60ed587aafe67d5cTimo Sirainenclass TestDepotController(pkg5unittest.CliTestCase):
da27cf9a026b1c6708bdc0de1c02b83838e64bd8Timo Sirainen self.__dc.set_property("publisher", "prefix", "test")
da27cf9a026b1c6708bdc0de1c02b83838e64bd8Timo Sirainen self.__dc.set_depotd_path(pkg5unittest.g_proto_area + \
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen self.__dc.set_depotd_content_root(pkg5unittest.g_proto_area + \
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen depotpath = os.path.join(self.test_root, "depot")
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen logpath = os.path.join(self.test_root, self.id())
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen cfg_file = os.path.join(self.test_root, "cfg2")
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen """Tests whether the index and feed cache file are written to
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen the writable root parameter."""
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen index_dir = os.path.join(writable_root, "index")
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen feed = os.path.join(writable_root, "feed.xml")
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen base_dir = os.path.join(self.test_root, "depot")
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen while not found and time.time() - start_time < timeout:
repo_cfg = {
mode_methods = [
pages = [
"en/catalog.shtml",
"en/index.shtml",
"en/search.shtml",
"en/stats.shtml",
if with_packages:
if set_method:
if unset_method:
uris = []
for u in returned:
for p in plist:
for p in plist:
"en/search.shtml?action=Search&token=*")
"en/advanced_search.shtml?action=Search&token=*")
"en/advanced_search.shtml?token=*&show=a&rpp=50&"