1516N/A#!/usr/bin/python
581N/A#
581N/A# CDDL HEADER START
581N/A#
581N/A# The contents of this file are subject to the terms of the
581N/A# Common Development and Distribution License (the "License").
581N/A# You may not use this file except in compliance with the License.
581N/A#
581N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
581N/A# or http://www.opensolaris.org/os/licensing.
581N/A# See the License for the specific language governing permissions
581N/A# and limitations under the License.
581N/A#
581N/A# When distributing Covered Code, include this CDDL HEADER in each
581N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
581N/A# If applicable, add the following below this CDDL HEADER, with the
581N/A# fields enclosed by brackets "[]" replaced with your own identifying
581N/A# information: Portions Copyright [yyyy] [name of copyright owner]
581N/A#
581N/A# CDDL HEADER END
581N/A#
581N/A
926N/A#
3339N/A# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
926N/A#
581N/A
3339N/Afrom . import testutils
581N/Aif __name__ == "__main__":
581N/A testutils.setup_environment("../../../proto")
1715N/Aimport pkg5unittest
581N/A
1895N/Aimport os
581N/Aimport unittest
1895N/A
581N/A
2055N/Aclass TestPkgPropertyBasics(pkg5unittest.SingleDepotTestCase):
581N/A # Only start/stop the depot once (instead of for every test)
1715N/A persistent_setup = True
581N/A
581N/A def test_pkg_properties(self):
792N/A """pkg: set, unset, and display properties"""
581N/A
1895N/A self.image_create(self.rurl)
581N/A
3339N/A self.pkg("set-property -@", exit=2)
581N/A self.pkg("get-property -@", exit=2)
581N/A self.pkg("property -@", exit=2)
581N/A
581N/A self.pkg("set-property title sample")
581N/A self.pkg('set-property description "more than one word"')
581N/A self.pkg("property")
611N/A self.pkg("property | grep title")
611N/A self.pkg("property | grep description")
611N/A self.pkg("property | grep 'sample'")
611N/A self.pkg("property | grep 'more than one word'")
581N/A self.pkg("unset-property description")
581N/A self.pkg("property -H")
581N/A self.pkg("property title")
581N/A self.pkg("property -H title")
581N/A self.pkg("property description", exit=1)
581N/A self.pkg("unset-property description", exit=1)
581N/A self.pkg("unset-property", exit=2)
581N/A
2026N/A self.pkg("set-property signature-policy verify")
2097N/A self.pkg("set-property signature-policy verify foo", exit=2)
2026N/A self.pkg("set-property signature-policy vrify", exit=1)
2026N/A self.pkg("set-property signature-policy require-names", exit=1)
2026N/A self.pkg("set-property signature-policy require-names foo")
2026N/A
2026N/A self.pkg("add-property-value signature-policy verify", exit=1)
2026N/A self.pkg("add-property-value signature-required-names foo")
2026N/A self.pkg("add-property-value signature-required-names bar")
2026N/A self.pkg("remove-property-value signature-required-names foo")
2026N/A self.pkg("remove-property-value signature-required-names baz",
2026N/A exit=1)
2026N/A self.pkg("add-property-value foo", exit=2)
2026N/A self.pkg("remove-property-value foo", exit=2)
2026N/A self.pkg("set-property foo", exit=2)
2026N/A self.pkg("set-property foo bar")
2026N/A self.pkg("remove-property-value foo bar", exit=1)
2026N/A self.pkg("set-property", exit=2)
2026N/A
3158N/A self.pkg("set-property trust-anchor-directory {0} {1}".format(
3158N/A self.test_root, self.test_root), exit=1)
2026N/A
2055N/A # Verify that properties with single values can be set and
2055N/A # retrieved as expected.
2055N/A self.pkg("set-property flush-content-cache-on-success False")
2055N/A self.pkg("property -H flush-content-cache-on-success |"
2055N/A "grep -i flush-content-cache-on-success.*false$")
2055N/A
2258N/A def test_missing_permissions(self):
709N/A """Bug 2393"""
1895N/A
1895N/A self.image_create(self.rurl)
709N/A
709N/A self.pkg("property")
1895N/A self.pkg("set-property require-optional True", su_wrap=True,
1895N/A exit=1)
709N/A self.pkg("set-property require-optional True")
1895N/A self.pkg("unset-property require-optional", su_wrap=True,
1895N/A exit=1)
709N/A self.pkg("unset-property require-optional")
709N/A
1895N/A
581N/Aif __name__ == "__main__":
581N/A unittest.main()