#
# 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
#
#
#
from . import testutils
if __name__ == "__main__":
import pkg5unittest
import os
import jsonschema
foo1 = """
open foo@1,5.11-0
close """
foo10 = """
open foo@1.0,5.11-0
close """
foo11 = """
open foo@1.1,5.11-0
close """
foo12 = """
open foo@1.2,5.11-0
close """
foo121 = """
open foo@1.2.1,5.11-0
close """
food12 = """
open food@1.2,5.11-0
close """
newpkg10 = """
open newpkg@1.0
close """
newpkg210 = """
open newpkg2@1.0
close """
hierfoo10 = """
close """
verifypkg10 = """
open verifypkg@1.0,5.11-0:20160302T054916Z
add dir mode=0755 owner=root group=sys path=/etc
add dir mode=0755 owner=root group=sys path=/usr
add file bobcat path=/etc/preserved mode=644 owner=root group=sys preserve=true timestamp="20080731T024051Z"
add file dricon_maj path=/etc/name_to_major mode=644 owner=root group=sys preserve=true
add file dricon_da path=/etc/driver_aliases mode=644 owner=root group=sys preserve=true
add file dricon_cls path=/etc/driver_classes mode=644 owner=root group=sys preserve=true
add file dricon_mp path=/etc/minor_perm mode=644 owner=root group=sys preserve=true
add file dricon_dp path=/etc/security/device_policy mode=644 owner=root group=sys preserve=true
add file dricon_ep path=/etc/security/extra_privs mode=644 owner=root group=sys preserve=true
add file permission mode=0600 owner=root group=bin path=/etc/permission preserve=true
add driver name=zigit alias=pci8086,1234
close
"""
misc_files = {
"bobcat": "",
"dricon_da": """zigit "pci8086,1234"\n""",
"dricon_maj": """zigit 103\n""",
"dricon_cls": """\n""",
"dricon_mp": """\n""",
"dricon_dp": """\n""",
"dricon_ep": """\n""",
"permission": ""
}
"test2"])
# Ensure that the second repo's packages have exactly the same
# timestamps as those in the first ... by copying the repo over.
# If the repos need to have some contents which are different,
# send those changes after restarting depot 2.
# The new repository won't have a catalog, so rebuild it.
# The third repository should remain empty and not be
# published to.
# Next, create the image and configure publishers.
return retjson
"""Test invalid pkg_invoke args is handled correctly."""
pkgs = ["foo"]
invalidpargs = "+1+1random"
invalidopts = "+1+1random"
"""Test valid arguments for pkg json."""
pkgs = ["foo"]
opts_json=None)
"""Test if the input is valid against the schema."""
try:
return True
except Exception as e:
return False
"""Test json args or opts for list command."""
pkgs = [None]
pkgs = []
# Test args and opts directly against schema.
pargs = "pargs_json"
list_input = {pargs: [],
"opts_json": {"list_upgradable": "string"}}
False}}
"""Test json args or opts for install command."""
# Test invalid pkg name.
pkgs = [None]
# Test unknown option was reported.
pkgs = ["newpkg@1.0"]
# Test without pkg specified.
pkgs = []
# Run through pkg install.
pkgs = ["newpkg@1.0"]
# Test input directly against schema.
pargs = "pargs_json"
{"parsable_version": "string"}}
{"parsable_version": 3}}
{"parsable_version": None}}
False}}
[]}}
{"act_timeout": 1.2}}
{"act_timeout": -1}}
{"li_erecurse_list": [None, None]}}
{"li_erecurse_list": []}}
"""Test json args or opts for update command."""
# Test invalid pkg name.
pkgs = [None]
# Test unknown option was reported.
pkgs = ["newpkg@1.0"]
# Test without pkg specified.
pkgs = []
# Run through pkg update.
pkgs = ["foo@1.1"]
pkgs=[]
# Test input directly against schema.
pargs = "pargs_json"
True}}
"""Test json args or opts for update command."""
# Test invalid pkg name.
opts = {}
pkgs = [None]
opts = {}
# Test unknown option was reported.
pkgs = ["newpkg@1.0"]
# Test without pkg specified.
pkgs = []
# Run through pkg uninstall.
pkgs = ["foo"]
# Test input directly against schema.
pargs = "pargs_json"
True}}
"""Test json args or opts for update command."""
# Test invalid pkg name.
pubs = ["test1"]
pkgs = ["newpkg@1.0"]
pkgs = ["newpkg"]
subcommand="unset-publisher",
opts_json=None)
"prop2=there"]}
"prop2"]}
"search_after": "b"}
# Test input directly against schema.
pargs = "pargs_json"
schema))
schema))
schema))
schema))
# Test unset pub name.
pubs = ["no_pub"]
opts = {}
pubs = []
pubs = []
pubs = []
pubs = []
pubs = []
opts = {"output_format": None}
pubs = []
pubs = []
pubs = ["test1"]
opts = {}
pkgs = ["foo"]
pkgs = []
pkgs = []
opts = {"origins": [None]}
pkgs = []
opts = {"origins": None}
pkgs = ["foo"]
pkgs = ["foo"]
pkgs = []
pkgs = ["foo"]
opts = {}
== "Installed")
pkgs = []
pkgs = []
# Test with wrong value type.
pkgs = []
"""Test json args or opts for exact-install command."""
# Test invalid pkg name.
pkgs = [None]
# Test unknown option was reported.
pkgs = ["newpkg@1.0"]
# Test without pkg specified.
pkgs = []
# Run through pkg install.
pkgs = ["newpkg@1.0"]
# Test input directly against schema.
pargs = "pargs_json"
{"parsable_version": "string"}}
{"parsable_version": 3}}
{"parsable_version": None}}
False}}
[]}}
"str"}}
False}}
{"reject_pats": [None, None]}}
{"reject_pats": []}}
"""Test json args or opts for verify command."""
pkgs = ["verifypkg@1.0"]
# Test invalid options.
pkgs = ["verifypkg"]
pkgs = ["verifypkg"]
pkgs = ["verifypkg"]
pkgs = ["verifypkg"]
pkgs = ["verifypkg"]
pkgs = ["verifypkg"]
# Run through verify.
pkgs = ["verifypkg"]
["messages"][0]["msg_level"] == "info")
pkgs = []
["item-messages"])
== "info")
# Also check if the packaged content is still there.
["messages"][0]["msg_level"] == "info")
pkgs = []
["item-messages"])
== "info")
# Also check if the packaged content is gone.
not in reslist)
# Test input directly against schema.
pargs = "pargs_json"
"wrongValueType"}}
"""Test json args or opts for fix command."""
pkgs = ["verifypkg@1.0"]
# Test invalid options.
pkgs = ["verifypkg"]
pkgs = ["verifypkg"]
pkgs = ["verifypkg"]
pkgs = []
pkgs = []
# Run through fix.
pkgs = ["verifypkg"]
["messages"][0]["msg_level"] == "info")
# Test input directly against schema.
pargs = "pargs_json"
pargs = "pargs_json"
"""Test the clientInterface class."""
"set-publisher")
"set-publisher")
# Test uninstalling an not installed pkg.
opts = {}
args = ["no_install"]
# Test input schema was replaced by an mapped option name.
# Test be related exception does not crash the system.
args = ["no_install"]
args = ["newpkg2@1.0"]