src/tests/api/t_api.py
author Brock Pytlik <brock.pytlik@oracle.com>
Wed, 27 Apr 2011 20:30:32 -0700
changeset 2310 ce10607d5332
parent 2293 631000734928
child 2319 247375ff5e19
permissions -rw-r--r--
11684 desire option to not propagate certs to non-global zones 17522 system repository should provide basic functionality 17523 Need a functioning sysdepo 17524 system depot should auto generate its configuration based on system image 17525 system depot should respond to versions/0 17526 system depot should provide publisher configuration 17527 caching should be enabled for system depot 17528 system depot should proxy http repositories 17529 system depot should proxy https repositories 17530 pkg client needs to be aware of the system repository 17531 pkg needs to cache system publisher information 17532 pkg should retrieve publisher information from the system repository when configured 17533 pkg needs to use the system repository as a proxy for http repositories 17534 pkg needs to use the system repository as a proxy for https repositories 17535 need an image property to indicate whether to use the system repository 17536 an image shouldn't require any configured publishers 17537 notion of preferred publisher should be removed 17538 pkg should be able to merge system publisher info with locally configured publishers 17539 pkg should notify that users cannot modify system publishers in certain ways 17540 pkg publisher needs to be updated to include information about system publishers 17541 pkg will need a way to specify alternate system repository urls 17547 file repositories need to be proxied by the system repository 17594 pkg set-publisher in GZ should refresh sysdepo service 17604 converting an imageconfig object to a string causes an infinite loop 17847 pkg set-publisher shouldn't allow -P along with --search-* 17911 pkg image-create should allow an image to be created without a publisher 18200 need a manpage for the sysrepo service
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
     1
#!/usr/bin/python
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     2
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     3
# CDDL HEADER START
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     4
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     8
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    12
# and limitations under the License.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    13
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    19
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    20
# CDDL HEADER END
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    21
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    22
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    23
#
2183
21ae45e8dfcf 17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
    24
# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    25
#
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    26
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    27
import testutils
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    28
if __name__ == "__main__":
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    29
	testutils.setup_environment("../../../proto")
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    30
import pkg5unittest
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    31
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    32
import cStringIO
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    33
import os
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    34
import pkg.client.api as api
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    35
import pkg.client.api_errors as api_errors
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    36
import pkg.client.progress as progress
2074
2a5ce81cc326 17033 operations can fail with traceback if no packages are added or removed
Shawn Walker <shawn.walker@oracle.com>
parents: 2073
diff changeset
    37
import pkg.facet as facet
1252
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
    38
import pkg.fmri as fmri
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    39
import sys
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    40
import tempfile
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    41
import time
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    42
import unittest
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    43
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
    44
CLIENT_API_VERSION = 57
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    45
PKG_CLIENT_NAME = "pkg"
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    46
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    47
class TestPkgApi(pkg5unittest.SingleDepotTestCase):
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
    48
        # restart the depot for every test
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    49
        persistent_setup = False
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    50
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    51
        foo10 = """
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    52
            open [email protected],5.11-0
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    53
            close """
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    54
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    55
        foo12 = """
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    56
            open [email protected],5.11-0
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    57
            add file libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.so.1
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    58
            close """
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
    59
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    60
        bar10 = """
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    61
            open [email protected],5.11-0
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    62
            close """
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
    63
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    64
        baz10 = """
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    65
            open [email protected],5.11-0
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    66
            add license copyright.baz license=copyright.baz
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    67
            close """
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    68
1678
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    69
        quux10 = """
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    70
            open [email protected],5.11-0
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    71
            add depend type=require [email protected]
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    72
            close """
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    73
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    74
        # First iteration has just a copyright.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    75
        licensed10 = """
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    76
            open [email protected],5.11-0
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    77
            add depend type=require [email protected]
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    78
            add license copyright.licensed license=copyright.licensed
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    79
            close """
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    80
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    81
        # Second iteration has copyright that must-display and a new license
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    82
        # that doesn't require acceptance.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    83
        licensed12 = """
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    84
            open [email protected],5.11-0
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    85
            add depend type=require [email protected]
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    86
            add file libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.so.1
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    87
            add license copyright.licensed license=copyright.licensed must-display=True
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    88
            add license license.licensed license=license.licensed
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    89
            close """
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    90
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    91
        # Third iteration now requires acceptance of license.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    92
        licensed13 = """
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    93
            open [email protected],5.11-0
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    94
            add depend type=require [email protected]
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    95
            add file libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.so.1
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    96
            add license copyright.licensed license=copyright.licensed must-display=True
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
    97
            add license license.licensed license=license.licensed must-accept=True
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    98
            close """
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
    99
2117
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   100
        # Fourth iteration is completely unchanged, so shouldn't require
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   101
        # acceptance.
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   102
        licensed14 = """
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   103
            open [email protected],5.11-0
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   104
            add depend type=require [email protected]
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   105
            add file libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.so.1
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   106
            add license copyright.licensed license=copyright.licensed must-display=True
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   107
            add license license.licensed license=license.licensed must-accept=True
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   108
            close """
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   109
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   110
        p5i_bobcat = """{
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   111
  "packages": [
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   112
    "pkg:/[email protected],5.11-0", 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   113
    "baz"
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   114
  ], 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   115
  "publishers": [
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   116
    {
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   117
      "alias": "cat", 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   118
      "name": "bobcat", 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   119
      "packages": [
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   120
        "pkg:/[email protected],5.11-0"
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   121
      ], 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   122
      "repositories": [
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   123
        {
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   124
          "collection_type": "core", 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   125
          "description": "xkcd.net/325", 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   126
          "legal_uris": [
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   127
            "http://xkcd.com/license.html"
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   128
          ], 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   129
          "mirrors": [], 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   130
          "name": "source", 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   131
          "origins": [
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   132
            "%REAL_ORIGIN%/"
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   133
          ], 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   134
          "refresh_seconds": 43200, 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   135
          "registration_uri": "", 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   136
          "related_uris": []
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   137
        }
2286
938fbb350ad2 16867 pkgsign should handle existing signatures better
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2219
diff changeset
   138
      ]
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   139
    }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   140
  ], 
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   141
  "version": 1
1257
d911e4542c41 9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents: 1255
diff changeset
   142
}
d911e4542c41 9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents: 1255
diff changeset
   143
"""
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   144
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   145
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   146
        misc_files = ["copyright.baz", "copyright.licensed", "libc.so.1",
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   147
            "license.licensed", "license.licensed.addendum"]
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   148
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   149
        def setUp(self):
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
   150
                pkg5unittest.SingleDepotTestCase.setUp(self, publisher="bobcat")
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
   151
                self.make_misc_files(self.misc_files)
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   152
                self.p5i_bobcat = self.p5i_bobcat.replace("%REAL_ORIGIN%",
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   153
                    self.rurl)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   154
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   155
        def __try_bad_installs(self, api_obj):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   156
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   157
                self.assertRaises(api_errors.PlanExistsException,
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1461
diff changeset
   158
                    api_obj.plan_install,["foo"])
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   159
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   160
                self.assertRaises(api_errors.PlanExistsException,
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   161
                    api_obj.plan_uninstall,["foo"], False)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   162
                self.assertRaises(api_errors.PlanExistsException,
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   163
                    api_obj.plan_update_all, sys.argv[0])
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   164
                try:
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   165
                        api_obj.plan_update_all(sys.argv[0])
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   166
                except api_errors.PlanExistsException:
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   167
                        pass
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   168
                else:
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   169
                        assert 0
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   170
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   171
        def __try_bad_combinations_and_complete(self, api_obj):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   172
                self.__try_bad_installs(api_obj)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   173
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   174
                self.assertRaises(api_errors.PrematureExecutionException,
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   175
                    api_obj.execute_plan)
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   176
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   177
                api_obj.prepare()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   178
                self.__try_bad_installs(api_obj)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   179
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   180
                self.assertRaises(api_errors.AlreadyPreparedException,
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   181
                    api_obj.prepare)
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   182
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   183
                api_obj.execute_plan()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   184
                self.__try_bad_installs(api_obj)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   185
                self.assertRaises(api_errors.AlreadyPreparedException,
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   186
                    api_obj.prepare)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   187
                self.assertRaises(api_errors.AlreadyExecutedException,
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   188
                    api_obj.execute_plan)
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   189
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   190
        def test_bad_orderings(self):
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   191
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   192
                self.pkgsend_bulk(self.rurl, self.foo10)
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   193
                api_obj = self.image_create(self.rurl, prefix="bobcat")
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   194
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   195
                self.assert_(api_obj.describe() is None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   196
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   197
                self.assertRaises(api_errors.PlanMissingException,
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   198
                    api_obj.prepare)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   199
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1461
diff changeset
   200
                api_obj.plan_install(["foo"])
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   201
                self.__try_bad_combinations_and_complete(api_obj)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   202
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   203
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   204
                self.assertRaises(api_errors.PlanMissingException,
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   205
                    api_obj.prepare)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   206
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   207
                self.assert_(api_obj.describe() is None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   208
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   209
                self.pkgsend_bulk(self.rurl, self.foo12)
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   210
                api_obj.refresh(immediate=True)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   211
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   212
                api_obj.plan_update_all(sys.argv[0])
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   213
                self.__try_bad_combinations_and_complete(api_obj)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   214
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   215
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   216
                self.assertRaises(api_errors.PlanMissingException,
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   217
                    api_obj.prepare)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   218
                self.assert_(api_obj.describe() is None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   219
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   220
                api_obj.plan_uninstall(["foo"], False)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   221
                self.__try_bad_combinations_and_complete(api_obj)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   222
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   223
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   224
                self.assertRaises(api_errors.PlanMissingException,
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   225
                    api_obj.prepare)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   226
                self.assert_(api_obj.describe() is None)
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   227
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   228
        def test_reset(self):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   229
                """ Send empty package [email protected], install and uninstall """
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   230
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   231
                self.pkgsend_bulk(self.rurl, self.foo10)
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   232
                api_obj = self.image_create(self.rurl, prefix="bobcat")
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   233
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   234
                recursive_removal = False
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   235
2074
2a5ce81cc326 17033 operations can fail with traceback if no packages are added or removed
Shawn Walker <shawn.walker@oracle.com>
parents: 2073
diff changeset
   236
                facets = facet.Facets({ "facet.devel": True })
2a5ce81cc326 17033 operations can fail with traceback if no packages are added or removed
Shawn Walker <shawn.walker@oracle.com>
parents: 2073
diff changeset
   237
                api_obj.plan_change_varcets(facets=facets)
2a5ce81cc326 17033 operations can fail with traceback if no packages are added or removed
Shawn Walker <shawn.walker@oracle.com>
parents: 2073
diff changeset
   238
                self._api_finish(api_obj)
2a5ce81cc326 17033 operations can fail with traceback if no packages are added or removed
Shawn Walker <shawn.walker@oracle.com>
parents: 2073
diff changeset
   239
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1461
diff changeset
   240
                api_obj.plan_install(["foo"])
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   241
                self.assert_(api_obj.describe() is not None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   242
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   243
                self.assert_(api_obj.describe() is None)
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1461
diff changeset
   244
                api_obj.plan_install(["foo"])
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   245
                self.assert_(api_obj.describe() is not None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   246
                api_obj.prepare()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   247
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   248
                self.assert_(api_obj.describe() is None)
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1461
diff changeset
   249
                api_obj.plan_install(["foo"])
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   250
                self.assert_(api_obj.describe() is not None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   251
                api_obj.prepare()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   252
                api_obj.execute_plan()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   253
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   254
                self.assert_(api_obj.describe() is None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   255
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   256
                self.pkg("list")
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   257
                self.pkg("verify")
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   258
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   259
                self.pkgsend_bulk(self.rurl, self.foo12)
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   260
                api_obj.refresh(immediate=True)
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   261
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   262
                api_obj.plan_update_all(sys.argv[0])
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   263
                self.assert_(api_obj.describe() is not None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   264
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   265
                self.assert_(api_obj.describe() is None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   266
                api_obj.plan_update_all(sys.argv[0])
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   267
                self.assert_(api_obj.describe() is not None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   268
                api_obj.prepare()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   269
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   270
                self.assert_(api_obj.describe() is None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   271
                api_obj.plan_update_all(sys.argv[0])
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   272
                self.assert_(api_obj.describe() is not None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   273
                api_obj.prepare()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   274
                api_obj.execute_plan()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   275
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   276
                self.assert_(api_obj.describe() is None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   277
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   278
                self.pkg("list")
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   279
                self.pkg("verify")
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   280
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   281
                api_obj.plan_uninstall(["foo"], recursive_removal)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   282
                self.assert_(api_obj.describe() is not None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   283
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   284
                self.assert_(api_obj.describe() is None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   285
                api_obj.plan_uninstall(["foo"], recursive_removal)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   286
                self.assert_(api_obj.describe() is not None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   287
                api_obj.prepare()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   288
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   289
                self.assert_(api_obj.describe() is None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   290
                api_obj.plan_uninstall(["foo"], recursive_removal)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   291
                self.assert_(api_obj.describe() is not None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   292
                api_obj.prepare()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   293
                api_obj.execute_plan()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   294
                api_obj.reset()
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   295
                self.assert_(api_obj.describe() is None)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   296
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   297
                self.pkg("verify")
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   298
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   299
        def test_refresh_transition(self):
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   300
                """Verify that refresh works for a v0 catalog source and that
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   301
                if the client transitions from v0 to v1 or back that the correct
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   302
                state information is recorded in the image catalog."""
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   303
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   304
                # This test requires an actual depot due to v0 operation usage.
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   305
                # First create the image and get v1 catalog.
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   306
                self.dc.start()
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   307
                self.pkgsend_bulk(self.durl, (self.foo10, self.quux10))
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   308
                try:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   309
                        api_obj = self.image_create(self.durl, prefix="bobcat")
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   310
                except api_errors.CatalogRefreshException, e:
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   311
                        self.debug("\n".join(str(x[-1]) for x in e.failed))
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
   312
                        raise
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   313
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   314
                self.pkg("publisher")
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   315
                img = api_obj.img
1678
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   316
                kcat = img.get_catalog(img.IMG_CATALOG_KNOWN)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   317
                entry = [e for f, e in kcat.entries()][0]
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   318
                states = entry["metadata"]["states"]
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   319
                self.assert_(img.PKG_STATE_V1 in states)
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   320
                self.assert_(img.PKG_STATE_V0 not in states)
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   321
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   322
                # Next, disable v1 catalog for the depot and force a client
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   323
                # refresh.  Only v0 state should be present.
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   324
                self.dc.stop()
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   325
                self.dc.set_disable_ops(["catalog/1"])
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   326
                self.dc.start()
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   327
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   328
                # Since the depot state changed while the API object was
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   329
                # still active, it needs to be reset to clear the internal
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   330
                # transport state cache.
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   331
                api_obj.reset()
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   332
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   333
                api_obj.refresh(immediate=True)
1678
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   334
                api_obj.reset()
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   335
                img = api_obj.img
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   336
1678
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   337
                kcat = img.get_catalog(img.IMG_CATALOG_KNOWN)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   338
                entry = [e for f, e in kcat.entries()][0]
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   339
                states = entry["metadata"]["states"]
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   340
                self.assert_(img.PKG_STATE_V1 not in states)
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   341
                self.assert_(img.PKG_STATE_V0 in states)
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   342
1678
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   343
                # Verify that there is no dependency information present
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   344
                # in the known or installed catalog.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   345
                icat = img.get_catalog(img.IMG_CATALOG_INSTALLED)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   346
                for cat in kcat, icat:
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   347
                        dpart = cat.get_part("catalog.dependency.C")
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   348
                        dep_acts = [
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   349
                            acts
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   350
                            for t, entry in dpart.tuple_entries()
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   351
                            for acts in entry.get("actions", [])
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   352
                        ]
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   353
                        self.assertEqual(dep_acts, [])
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   354
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   355
                # Now install a package, and verify that the entries in the
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   356
                # known catalog for installed packages exist in the installed
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   357
                # catalog and are identical.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   358
                progresstracker = progress.NullProgressTracker()
2183
21ae45e8dfcf 17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
   359
                api_obj = api.ImageInterface(self.get_img_path(), 
21ae45e8dfcf 17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
   360
                    CLIENT_API_VERSION, progresstracker, lambda x: False, 
21ae45e8dfcf 17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
   361
                    PKG_CLIENT_NAME)
1678
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   362
                img = api_obj.img
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   363
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   364
                # Get image catalogs.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   365
                kcat = img.get_catalog(img.IMG_CATALOG_KNOWN)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   366
                icat = img.get_catalog(img.IMG_CATALOG_INSTALLED)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   367
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   368
                # Verify quux package is only in known catalog.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   369
                self.assertTrue("quux" in kcat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   370
                self.assertTrue("foo" in kcat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   371
                self.assertTrue("quux" not in icat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   372
                self.assertTrue("foo" not in icat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   373
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   374
                # Install the packages.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   375
                api_obj.plan_install(["[email protected]"])
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   376
                api_obj.prepare()
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   377
                api_obj.execute_plan()
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   378
                api_obj.reset()
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   379
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   380
                # Get image catalogs.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   381
                kcat = img.get_catalog(img.IMG_CATALOG_KNOWN)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   382
                icat = img.get_catalog(img.IMG_CATALOG_INSTALLED)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   383
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   384
                # Verify quux package is in both catalogs.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   385
                self.assertTrue("quux" in kcat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   386
                self.assertTrue("foo" in kcat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   387
                self.assertTrue("quux" in icat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   388
                self.assertTrue("foo" in icat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   389
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   390
                # Verify state info.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   391
                for cat in kcat, icat:
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   392
                        entry = [e for f, e in cat.entries()][0]
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   393
                        states = entry["metadata"]["states"]
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   394
                        self.assert_(img.PKG_STATE_INSTALLED in states)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   395
                        self.assert_(img.PKG_STATE_V0 in states)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   396
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   397
                # Finally, transition back to v1 catalog.  This requires
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   398
                # creating a new api object since transport will think that
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   399
                # v1 catalogs are still unsupported.
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   400
                self.dc.unset_disable_ops()
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   401
                self.dc.stop()
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   402
                self.dc.start()
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   403
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   404
                progresstracker = progress.NullProgressTracker()
2183
21ae45e8dfcf 17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
   405
                api_obj = api.ImageInterface(self.get_img_path(), 
21ae45e8dfcf 17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
   406
                    CLIENT_API_VERSION, progresstracker, 
21ae45e8dfcf 17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
   407
                    lambda x: False, PKG_CLIENT_NAME)
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   408
                api_obj.refresh(immediate=True)
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   409
                img = api_obj.img
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   410
1678
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   411
                # Get image catalogs.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   412
                kcat = img.get_catalog(img.IMG_CATALOG_KNOWN)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   413
                icat = img.get_catalog(img.IMG_CATALOG_INSTALLED)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   414
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   415
                # Verify quux package is in both catalogs.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   416
                self.assertTrue("quux" in kcat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   417
                self.assertTrue("foo" in kcat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   418
                self.assertTrue("quux" in icat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   419
                self.assertTrue("foo" in icat.names())
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   420
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   421
                # Verify state info.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   422
                for f, entry in kcat.entries():
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   423
                        states = entry["metadata"]["states"]
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   424
                        self.assert_(img.PKG_STATE_V1 in states)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   425
                        self.assert_(img.PKG_STATE_V0 not in states)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   426
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   427
                # Verify that there is dependency information present
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   428
                # in the known and installed catalog.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   429
                for cat in kcat, icat:
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   430
                        dpart = cat.get_part("catalog.dependency.C")
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   431
                        entries = [(t, entry) for t, entry in dpart.tuple_entries()]
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   432
                        dep_acts = [
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   433
                            acts
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   434
                            for t, entry in dpart.tuple_entries()
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   435
                            for acts in entry.get("actions", [])
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   436
                            if t[1] == "quux"
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   437
                        ]
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   438
                        self.assertNotEqual(dep_acts, [])
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   439
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   440
                # Verify that every installed package is in known and has
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   441
                # identical entries and that every installed package in
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   442
                # the installed catalog is in the known catalog and has
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   443
                # entries.
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   444
                for src, dest in ((kcat, icat), (icat, kcat)):
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   445
                        src_base = src.get_part("catalog.base.C",
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   446
                            must_exist=True)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   447
                        self.assertNotEqual(src_base, None)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   448
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   449
                        for f, bentry in src_base.entries():
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   450
                                states = bentry["metadata"]["states"]
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   451
                                if img.PKG_STATE_INSTALLED not in states:
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   452
                                        continue
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   453
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   454
                                for name in src.parts:
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   455
                                        spart = src.get_part(name,
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   456
                                            must_exist=True)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   457
                                        self.assertNotEqual(spart, None)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   458
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   459
                                        dpart = dest.get_part(name,
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   460
                                            must_exist=True)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   461
                                        self.assertNotEqual(dpart, None)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   462
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   463
                                        sentry = spart.get_entry(pfmri=f)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   464
                                        dentry = dpart.get_entry(pfmri=f)
825ec1d3702e 14013 image catalog rebuild can stumble on v0 to v1 repo transition
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   465
                                        self.assertEqual(sentry, dentry)
1449
a721d9b0aad2 12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents: 1431
diff changeset
   466
1255
13914487fd06 8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents: 1252
diff changeset
   467
        def test_properties(self):
13914487fd06 8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents: 1252
diff changeset
   468
                """Verify that properties of the ImageInterface api object are
13914487fd06 8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents: 1252
diff changeset
   469
                accessible and return expected values."""
13914487fd06 8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents: 1252
diff changeset
   470
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   471
                api_obj = self.image_create(self.rurl, prefix="bobcat")
1255
13914487fd06 8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents: 1252
diff changeset
   472
                self.assertEqual(api_obj.root, self.img_path)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   473
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   474
        def test_publisher_apis(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   475
                """Verify that the publisher api methods work as expected.
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   476
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   477
                Note that not all methods are tested here as this would be
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   478
                redundant since other tests for the client will use those
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   479
                methods indirectly."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   480
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   481
                plist = self.pkgsend_bulk(self.rurl, (self.foo10, self.bar10))
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   482
                api_obj = self.image_create(self.rurl, prefix="bobcat")
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   483
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   484
                # Verify that existence tests succeed.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   485
                self.assertTrue(api_obj.has_publisher("bobcat"))
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   486
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   487
                # Verify preferred publisher prefix is returned correctly.
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   488
                self.assertEqual(api_obj.get_highest_ranked_publisher(),
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   489
                    "bobcat")
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   490
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   491
                # Verify that get_publisher returned the correct publisher
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   492
                # object.
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   493
                pub = api_obj.get_publisher(prefix="bobcat")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   494
                self.assertEqual(pub.prefix, "bobcat")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   495
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   496
                # Verify that not specifying matching criteria for get_publisher
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   497
                # raises a UnknownPublisher exception.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   498
                self.assertRaises(api_errors.UnknownPublisher,
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   499
                    api_obj.get_publisher, "zuul")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   500
                self.assertRaises(api_errors.UnknownPublisher,
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   501
                    api_obj.get_publisher)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   502
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   503
                # Verify that publisher objects returned from get_publishers
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   504
                # match those returned by get_publisher.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   505
                pubs = api_obj.get_publishers()
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   506
                self.assertEqual(pub.prefix, pubs[0].prefix)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   507
                self.assertEqual(id(pub), id(pubs[0]))
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   508
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   509
                # Verify that duplicate actually creates duplicates.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   510
                cpub = api_obj.get_publisher(prefix="bobcat", duplicate=True)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   511
                self.assertNotEqual(id(pub), id(cpub))
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   512
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   513
                # Now modify publisher information and update.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   514
                cpub.alias = "cat"
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   515
                repo = cpub.repository
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   516
                repo.name = "source"
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   517
                repo.description = "xkcd.net/325"
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   518
                repo.legal_uris = ["http://xkcd.com/license.html"]
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   519
                repo.refresh_seconds = 43200
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   520
                repo.registered = False
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   521
                api_obj.update_publisher(cpub)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   522
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   523
                # Verify that the update happened.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   524
                pub = api_obj.get_publisher(prefix="bobcat")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   525
                self.assertEqual(pub.alias, "cat")
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   526
                repo = pub.repository
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   527
                self.assertEqual(repo.name, "source")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   528
                self.assertEqual(repo.description, "xkcd.net/325")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   529
                self.assertEqual(repo.legal_uris[0],
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   530
                    "http://xkcd.com/license.html")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   531
                self.assertEqual(repo.refresh_seconds, 43200)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   532
                self.assertEqual(repo.registered, False)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   533
1252
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   534
                # Verify that duplicates match their original.
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   535
                cpub = api_obj.get_publisher(alias=pub.alias, duplicate=True)
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   536
                for p in ("alias", "prefix", "meta_root"):
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   537
                        self.assertEqual(getattr(pub, p), getattr(cpub, p))
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   538
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   539
                for p in ("collection_type", "description", "legal_uris",
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   540
                    "mirrors", "name", "origins", "refresh_seconds",
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   541
                    "registered", "registration_uri", "related_uris",
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   542
                    "sort_policy"):
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   543
                        srepo = pub.repository
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   544
                        crepo = cpub.repository
1252
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   545
                        self.assertEqual(getattr(srepo, p), getattr(crepo, p))
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   546
                cpub = None
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   547
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   548
                cpubs = api_obj.get_publishers(duplicate=True)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   549
                self.assertNotEqual(id(pub), id(cpubs[0]))
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   550
                cpubs = None
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   551
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   552
                # Verify that publisher_last_update_time returns a value.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   553
                self.assertTrue(
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   554
                    api_obj.get_publisher_last_update_time("bobcat"))
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   555
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   556
                # Verify that p5i export and parse works as expected.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   557
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   558
                # Ensure that PackageInfo, PkgFmri, and strings are all
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   559
                # supported properly.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   560
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   561
                # Strip timestamp information so that comparison with
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   562
                # pre-generated test data will succeed.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   563
                ffoo = fmri.PkgFmri(plist[0])
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   564
                sfoo = str(ffoo).replace(":%s" % ffoo.version.timestr, "")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   565
                ffoo = fmri.PkgFmri(sfoo)
1431
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1369
diff changeset
   566
                sfoo = ffoo.get_fmri(anarchy=True)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   567
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   568
                fbar = fmri.PkgFmri(plist[1])
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   569
                sbar = str(fbar).replace(":%s" % fbar.version.timestr, "")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   570
                fbar = fmri.PkgFmri(sbar)
1431
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1369
diff changeset
   571
                sbar = fbar.get_fmri(anarchy=True)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   572
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   573
                # Build a simple list of packages.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   574
                pnames = {
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   575
                    "bobcat": (api.PackageInfo(ffoo),),
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   576
                    "": [fbar, "baz"],
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   577
                }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   578
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   579
                # Dump the p5i data.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   580
                fobj = cStringIO.StringIO()
1117
667aecade0ab 7862 install links using p5i for search results desired
Shawn Walker <srw@sun.com>
parents: 1087
diff changeset
   581
                api_obj.write_p5i(fobj, pkg_names=pnames, pubs=[pub])
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   582
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   583
                # Verify that output matches expected output.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   584
                fobj.seek(0)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   585
                output = fobj.read()
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   586
                self.assertEqualDiff(output, self.p5i_bobcat)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   587
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   588
                def validate_results(results):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   589
                        # First result should be 'bobcat' publisher and its
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   590
                        # pkg_names.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   591
                        pub, pkg_names = results[0]
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   592
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   593
                        self.assertEqual(pub.prefix, "bobcat")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   594
                        self.assertEqual(pub.alias, "cat")
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   595
                        repo = pub.repository
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   596
                        self.assertEqual(repo.name, "source")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   597
                        self.assertEqual(repo.description, "xkcd.net/325")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   598
                        self.assertEqual(repo.legal_uris[0],
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   599
                            "http://xkcd.com/license.html")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   600
                        self.assertEqual(repo.refresh_seconds, 43200)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   601
                        self.assertEqual(pkg_names, [sfoo])
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   602
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   603
                        # Last result should be no publisher and a list of
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   604
                        # pkg_names.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   605
                        pub, pkg_names = results[1]
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   606
                        self.assertEqual(pub, None)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   607
                        self.assertEqual(pkg_names, [sbar, "baz"])
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   608
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   609
                # Verify that parse returns the expected object and information
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   610
                # when provided a fileobj.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   611
                fobj.seek(0)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   612
                validate_results(api_obj.parse_p5i(fileobj=fobj))
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   613
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   614
                # Verify that an add of the parsed object works (the name has to
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   615
                # be changed to prevent a duplicate error here).
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   616
                fobj.seek(0)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   617
                results = api_obj.parse_p5i(fileobj=fobj)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   618
                pub, pkg_names = results[0]
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   619
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   620
                pub.prefix = "p5icat"
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   621
                pub.alias = "copycat"
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   622
                api_obj.add_publisher(pub, refresh_allowed=False)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   623
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   624
                # Now verify that we can retrieve the added publisher.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   625
                api_obj.get_publisher(prefix=pub.prefix)
1252
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   626
                cpub = api_obj.get_publisher(alias=pub.alias, duplicate=True)
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   627
1733
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   628
                # Now verify that the DuplicatePublisher exception is raised
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   629
                # as expected when adding or updating publishers if the prefix
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   630
                # is the same as another publisher's prefix or alias.  This is
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   631
                # because alias and prefix are intended to be interchangeable
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   632
                # (although the API allows clients to make a distinction
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   633
                # internally).
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   634
                dpub = api_obj.get_publisher(alias=pub.alias, duplicate=True)
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   635
                dpub.alias = None
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   636
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   637
                # Should fail since a publisher exists with this prefix.
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   638
                self.assertRaises(api_errors.DuplicatePublisher,
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   639
                        api_obj.add_publisher, dpub, refresh_allowed=False)
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   640
                dpub.prefix = "bobcat"
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   641
                self.assertRaises(api_errors.DuplicatePublisher,
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   642
                        api_obj.update_publisher, dpub, refresh_allowed=False)
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   643
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   644
                # Should fail since a publisher exists with an alias the same
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   645
                # as this prefix.
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   646
                dpub.prefix = "copycat"
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   647
                self.assertRaises(api_errors.DuplicatePublisher,
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   648
                        api_obj.add_publisher, dpub, refresh_allowed=False)
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   649
                dpub.prefix = "cat"
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   650
                self.assertRaises(api_errors.DuplicatePublisher,
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   651
                        api_obj.update_publisher, dpub, refresh_allowed=False)
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   652
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   653
                # Should fail since a publisher exists with an alias the same
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   654
                # as this alias.
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   655
                dpub.prefix = "uniquecat"
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   656
                dpub.alias = "copycat"
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   657
                self.assertRaises(api_errors.DuplicatePublisher,
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   658
                        api_obj.add_publisher, dpub, refresh_allowed=False)
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   659
                dpub.alias = "cat"
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   660
                self.assertRaises(api_errors.DuplicatePublisher,
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   661
                        api_obj.update_publisher, dpub, refresh_allowed=False)
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   662
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   663
                # Should fail since a publisher exists with a prefix the same
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   664
                # as this alias.
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   665
                dpub.prefix = "uniquecat"
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   666
                dpub.alias = "p5icat"
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   667
                self.assertRaises(api_errors.DuplicatePublisher,
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   668
                        api_obj.add_publisher, dpub, refresh_allowed=False)
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   669
                dpub.alias = "bobcat"
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   670
                self.assertRaises(api_errors.DuplicatePublisher,
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   671
                        api_obj.update_publisher, dpub, refresh_allowed=False)
7ffa6f902aa0 9218 pkg.client.api should check for cross-alias/prefix duplicates
Shawn Walker <srw@sun.com>
parents: 1715
diff changeset
   672
1252
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   673
                # Now update the publisher and set it to disabled, to verify
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   674
                # that api functions still work as expected.
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   675
                cpub.disabled = True
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   676
                api_obj.update_publisher(cpub)
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   677
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   678
                cpub = api_obj.get_publisher(alias=cpub.alias, duplicate=True)
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   679
                self.assertTrue(cpub.disabled)
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   680
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   681
                self.assertTrue(api_obj.has_publisher(prefix=cpub.prefix))
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   682
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   683
                # Now attempt to update the disabled publisher.
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   684
                cpub = api_obj.get_publisher(alias=cpub.alias, duplicate=True)
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   685
                cpub.alias = "copycopycat"
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   686
                api_obj.update_publisher(cpub)
3b1b69011fcf 8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents: 1141
diff changeset
   687
                cpub = None
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   688
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   689
                # Verify that parse returns the expected object and information
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   690
                # when provided a file path.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   691
                fobj.seek(0)
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
   692
                (fd1, path1) = tempfile.mkstemp(dir=self.test_root)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   693
                os.write(fd1, fobj.read())
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   694
                validate_results(api_obj.parse_p5i(location=path1))
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   695
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   696
                # Verify that parse returns the expected object and information
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   697
                # when provided a file URI.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   698
                validate_results(api_obj.parse_p5i(location="file://" + path1))
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   699
                fobj.close()
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   700
                fobj = None
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   701
935
83e6020403cb 7262 tests/cli/t_api.py should use test prefix for temporary files
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 926
diff changeset
   702
                # Verify that appropriate exceptions are raised for p5i
83e6020403cb 7262 tests/cli/t_api.py should use test prefix for temporary files
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 926
diff changeset
   703
                # information that can't be retrieved (doesn't exist).
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
   704
                nefpath = os.path.join(self.test_root, "non-existent")
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   705
                self.assertRaises(api_errors.RetrievalError,
935
83e6020403cb 7262 tests/cli/t_api.py should use test prefix for temporary files
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 926
diff changeset
   706
                    api_obj.parse_p5i, location="file://%s" % nefpath)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   707
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   708
                self.assertRaises(api_errors.RetrievalError,
935
83e6020403cb 7262 tests/cli/t_api.py should use test prefix for temporary files
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 926
diff changeset
   709
                    api_obj.parse_p5i, location=nefpath)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   710
935
83e6020403cb 7262 tests/cli/t_api.py should use test prefix for temporary files
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 926
diff changeset
   711
                # Verify that appropriate exceptions are raised for invalid
83e6020403cb 7262 tests/cli/t_api.py should use test prefix for temporary files
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 926
diff changeset
   712
                # p5i information.
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
   713
                lcpath = os.path.join(self.test_root, "libc.so.1")
935
83e6020403cb 7262 tests/cli/t_api.py should use test prefix for temporary files
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 926
diff changeset
   714
                self.assertRaises(api_errors.InvalidP5IFile, api_obj.parse_p5i,
83e6020403cb 7262 tests/cli/t_api.py should use test prefix for temporary files
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 926
diff changeset
   715
                    location="file://%s" % lcpath)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 917
diff changeset
   716
935
83e6020403cb 7262 tests/cli/t_api.py should use test prefix for temporary files
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 926
diff changeset
   717
                self.assertRaises(api_errors.InvalidP5IFile, api_obj.parse_p5i,
83e6020403cb 7262 tests/cli/t_api.py should use test prefix for temporary files
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 926
diff changeset
   718
                    location=lcpath)
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   719
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   720
        def test_license(self):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   721
                """ Send various packages and then verify that install and
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   722
                update operations will raise the correct exceptions or
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   723
                enforce the requirements of the license actions within. """
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   724
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   725
                plist = self.pkgsend_bulk(self.rurl, (self.licensed10,
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   726
                    self.licensed12, self.licensed13, self.bar10, self.baz10))
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   727
                api_obj = self.image_create(self.rurl, prefix="bobcat")
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   728
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   729
                # First, test the basic install case to see if expected license
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   730
                # data is returned.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   731
                api_obj.plan_install(["[email protected]"])
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   732
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   733
                def lic_sort(a, b):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   734
                        adest = a[2]
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   735
                        bdest = b[2]
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   736
                        return cmp(adest.license, bdest.license)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   737
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   738
                plan = api_obj.describe()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   739
                lics = sorted(plan.get_licenses(), cmp=lic_sort)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   740
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   741
                # Expect one license action for each package: "licensed", and
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   742
                # its dependency "baz".
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   743
                self.assertEqual(len(lics), 2)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   744
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   745
                # Now verify license entry for "[email protected]" and "[email protected]".
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   746
                for i, p in enumerate([plist[4], plist[0]]):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   747
                        pfmri = fmri.PkgFmri(p)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   748
                        dest_fmri, src, dest, accepted, displayed = lics[i]
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   749
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   750
                        # Expect license information to be for this package.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   751
                        self.assertEqual(pfmri, dest_fmri)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   752
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   753
                        # This is an install, not an update, so there should be
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   754
                        # no src.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   755
                        self.assertEqual(src, None)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   756
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   757
                        # dest should be a LicenseInfo object.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   758
                        self.assertEqual(type(dest), api.LicenseInfo)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   759
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   760
                        # Verify the identity of the LicenseInfo objects.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   761
                        self.assertEqual(dest.license,
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   762
                            "copyright.%s" % pfmri.pkg_name)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   763
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   764
                        # The license hasn't been accepted yet.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   765
                        self.assertEqual(accepted, False)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   766
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   767
                        # The license hasn't beend displayed yet.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   768
                        self.assertEqual(displayed, False)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   769
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   770
                        # The license action doesn't require acceptance.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   771
                        self.assertEqual(dest.must_accept, False)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   772
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   773
                        # The license action doesn't require display.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   774
                        self.assertEqual(dest.must_display, False)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   775
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   776
                        # Verify license text.
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
   777
                        text = dest.license
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   778
                        self.assertEqual(dest.get_text(), text)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   779
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   780
                # Install the packages.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   781
                api_obj.prepare()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   782
                api_obj.execute_plan()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   783
                api_obj.reset()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   784
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   785
                # Next, check that an upgrade produces expected license data.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   786
                api_obj.plan_install(["[email protected]"])
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   787
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   788
                plan = api_obj.describe()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   789
                lics = sorted(plan.get_licenses(), cmp=lic_sort)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   790
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   791
                # Expect two license actions, both of which should be for the
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   792
                # [email protected] package.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   793
                self.assertEqual(len(lics), 2)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   794
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   795
                # Now verify license entries for "[email protected]".
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   796
                pfmri = fmri.PkgFmri(plist[1])
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   797
                for dest_fmri, src, dest, accepted, displayed in lics:
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   798
                        # License information should only be for "[email protected]".
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   799
                        self.assertEqual(pfmri, dest_fmri)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   800
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   801
                        must_accept = False
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   802
                        must_display = False
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   803
                        if dest.license.startswith("copyright"):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   804
                                # This is an an update, so src should be a
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   805
                                # LicenseInfo object.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   806
                                self.assertEqual(type(src), api.LicenseInfo)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   807
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   808
                                # In this version, copyright must be displayed
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   809
                                # for dest.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   810
                                must_display = True
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   811
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   812
                        # dest should be a LicenseInfo object.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   813
                        self.assertEqual(type(dest), api.LicenseInfo)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   814
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   815
                        # Verify LicenseInfo attributes.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   816
                        self.assertEqual(accepted, False)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   817
                        self.assertEqual(displayed, False)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   818
                        self.assertEqual(dest.must_accept, must_accept)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   819
                        self.assertEqual(dest.must_display, must_display)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   820
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   821
                        # Verify license text.
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
   822
                        text = dest.license
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   823
                        self.assertEqual(dest.get_text(), text)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   824
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   825
                # Attempt to prepare plan; this should raise a license
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   826
                # exception.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   827
                self.assertRaises(api_errors.PlanLicenseErrors,
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   828
                    api_obj.prepare)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   829
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   830
                # Plan will have to be re-created first before continuing.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   831
                api_obj.reset()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   832
                api_obj.plan_install(["[email protected]"])
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   833
                plan = api_obj.describe()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   834
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   835
                # Set the copyright as having been displayed.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   836
                api_obj.set_plan_license_status(pfmri, "copyright.licensed",
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   837
                    displayed=True)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   838
                lics = sorted(plan.get_licenses(pfmri=pfmri), cmp=lic_sort)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   839
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   840
                # Verify displayed was updated and accepted remains False.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   841
                dest_fmri, src, dest, accepted, displayed = lics[0]
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   842
                self.assertEqual(src.license, "copyright.licensed")
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   843
                self.assertEqual(accepted, False)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   844
                self.assertEqual(displayed, True)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   845
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   846
                # Prepare should succeed this time; so execute afterwards.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   847
                api_obj.prepare()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   848
                api_obj.execute_plan()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   849
                api_obj.reset()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   850
2089
c8b9d6341530 2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents: 2074
diff changeset
   851
                # Next, check that an update produces expected license
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   852
                # data.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   853
                api_obj.plan_update_all(sys.argv[0])
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   854
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   855
                plan = api_obj.describe()
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   856
                lics = [l for l in plan.get_licenses()]
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   857
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   858
                # Expect one license action which should be for the [email protected]
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   859
                # package.  (Only one is expected since only one of the license
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   860
                # actions changed since [email protected].)
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   861
                self.assertEqual(len(lics), 1)
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   862
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   863
                # Now verify license entries for "[email protected]".
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   864
                pfmri = fmri.PkgFmri(plist[2])
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   865
                dest_fmri, src, dest, accepted, displayed = lics[0]
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   866
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   867
                # License information should only be for "[email protected]".
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   868
                self.assertEqual(pfmri, dest_fmri)
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   869
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   870
                must_accept = False
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   871
                must_display = False
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   872
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   873
                # This is an an update, so src should be a LicenseInfo
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   874
                # object.
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   875
                self.assertEqual(type(src), api.LicenseInfo)
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   876
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   877
                assert dest.license.startswith("license.")
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   878
                # license must be accepted for dest.
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   879
                must_accept = True
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   880
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   881
                # dest should be a LicenseInfo object.
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   882
                self.assertEqual(type(dest), api.LicenseInfo)
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   883
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   884
                # Verify LicenseInfo attributes.
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   885
                self.assertEqual(accepted, False)
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   886
                self.assertEqual(displayed, False)
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   887
                self.assertEqual(dest.must_accept, must_accept)
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   888
                self.assertEqual(dest.must_display, must_display)
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   889
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   890
                # Verify license text.
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   891
                text = dest.license
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   892
                self.assertEqual(dest.get_text(), text)
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   893
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   894
                # Attempt to prepare plan; this should raise a license
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   895
                # exception.
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   896
                self.assertRaises(api_errors.PlanLicenseErrors, api_obj.prepare)
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   897
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   898
                # Plan will have to be re-created first before continuing.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   899
                api_obj.reset()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   900
                api_obj.plan_update_all(sys.argv[0])
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   901
                plan = api_obj.describe()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   902
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   903
                # Set the license status of only one license.
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   904
                api_obj.set_plan_license_status(pfmri, "license.licensed",
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   905
                    accepted=True)
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   906
                lics = [l for l in plan.get_licenses(pfmri=pfmri)]
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   907
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   908
                # Verify only license.licensed was updated and exists.
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   909
                dest_fmri, src, dest, accepted, displayed = lics[0]
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   910
                self.assertEqual(src.license, "license.licensed")
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   911
                self.assertEqual(accepted, True)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   912
                self.assertEqual(displayed, False)
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2117
diff changeset
   913
                self.assertEqual(len(lics), 1)
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   914
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   915
                # Prepare should succeed this time; so execute afterwards.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   916
                api_obj.prepare()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   917
                api_obj.execute_plan()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   918
                api_obj.reset()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   919
2117
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   920
                plist.extend(self.pkgsend_bulk(self.rurl, self.licensed14))
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   921
                api_obj.refresh()
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   922
                api_obj.reset()
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   923
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   924
                # Next, verify that an update to a newer version of a package
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   925
                # where the license hasn't changed and it previously required
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   926
                # acceptance is treated as already having been accepted.
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   927
                api_obj.plan_update_all(sys.argv[0])
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   928
                plan = api_obj.describe()
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   929
                pfmri = fmri.PkgFmri(plist[5])
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   930
                lics = sorted(plan.get_licenses(), cmp=lic_sort)
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   931
                for dest_fmri, src, dest, accepted, displayed in lics:
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   932
                        # License information should only be for "[email protected]".
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   933
                        self.assertEqual(pfmri, dest_fmri)
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   934
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   935
                        if dest.must_accept:
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   936
                                # Since the license hasn't changed and was
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   937
                                # previously accepted, then acceptance shouldn't
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   938
                                # be required here.
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   939
                                self.assertTrue(accepted)
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   940
                api_obj.reset()
83afe4aabe78 17282 license attribute change shouldn't always require acceptance on package update
Shawn Walker <shawn.walker@oracle.com>
parents: 2092
diff changeset
   941
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   942
                # Finally, verify that an uninstall won't trigger license
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   943
                # errors as acceptance should never be applied to it.
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   944
                api_obj.plan_uninstall(["*"], False)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   945
                api_obj.prepare()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   946
                api_obj.execute_plan()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   947
                api_obj.reset()
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   948
2310
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   949
        def test_syspub_version_error(self):
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   950
                api_obj = self.image_create()
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   951
                try:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   952
                        api_obj.write_syspub("", [], 999)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   953
                except api_errors.UnsupportedP5SVersion, e:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   954
                        str(e)
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   955
                else:
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   956
                        raise RuntimeError("Expected write_syspub to raise "
ce10607d5332 11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents: 2293
diff changeset
   957
                            "an exception.")
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   958
1715
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
   959
if __name__ == "__main__":
8f305f0a6864 8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents: 1710
diff changeset
   960
        unittest.main()