t_pkg_depotd.py revision 817
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
import testutils
if __name__ == "__main__":
import httplib
import unittest
import os
import shutil
import tempfile
import urllib
import urllib2
quux10 = """
open quux@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/bin
close """
info10 = """
open info@1.0,5.11-0
close """
system10 = """
add set name="description" value="Package to test package names with slashes"
add depend type=require fmri=pkg:/SUNWcsl
close """
for p in self.misc_files:
f = open(p, "w")
# write the name of the file into the file, so that
# all files have differing contents
f.write(p)
f.close
for p in self.misc_files:
def test_depot_ping(self):
""" Ping the depot several times """
def testStartStop(self):
""" Start and stop the depot several times """
def test_bug_1876(self):
""" Send package quux@1.0 an action at a time, restarting the
depot server after each one is sent, to ensure that
transactions work across depot restart. Then verify that
the package was successfully added by performing some
basic operations. """
if line == "":
continue
try:
except:
raise
if not line == "close":
def test_bad_fmris(self):
def test_bug_3365(self):
f.close()
f.close()
def test_bug_4489(self):
"""Publish a package and then verify that the depot /info
operation doesn't fail."""
def test_bug_5366(self):
"""Publish a package with slashes in the name, and then verify
that the depot manifest and info operations work regardless of
the encoding."""
# First, try it un-encoded.
# Second, try it encoded.
def test_face_root(self):
"""Verify that files outside of the package content web root
cannot be accessed, and that files inside can be."""
# any attempts to go outside that directory should fail
# with a 404 error.
try:
raise
f.close()
"/usr/lib/pkg.depotd")
try:
except:
pass
def testStartStop(self):
def test_cfg_file(self):
def testBadArgs(self):
quux10 = """
open quux@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/bin
close """
info10 = """
open info@1.0,5.11-0
close """
system10 = """
add set name="description" value="Package to test package names with slashes"
add depend type=require fmri=pkg:/SUNWcsl
close """
"/usr/lib/pkg.depotd")
try:
except OSError, e:
raise e
def test_0_depot_bui_output(self):
"""Verify that a non-error response and valid HTML is returned
for each known BUI page in every available depot mode."""
# A list of tuples containing the name of the method used to set
# the mode, and then the method needed to unset that mode.
mode_methods = [
("set_readwrite", None),
("set_mirror", "unset_mirror"),
("set_readonly", "set_readwrite"),
]
pages = [
"index.shtml",
"en/catalog.shtml",
"en/index.shtml",
"en/search.shtml",
"en/stats.shtml",
]
if with_packages:
if set_method:
# Any error responses will cause an
# exception.
if unset_method:
if __name__ == "__main__":