581
|
1 |
#!/usr/bin/python2.4
|
|
2 |
#
|
|
3 |
# CDDL HEADER START
|
|
4 |
#
|
|
5 |
# The contents of this file are subject to the terms of the
|
|
6 |
# Common Development and Distribution License (the "License").
|
|
7 |
# You may not use this file except in compliance with the License.
|
|
8 |
#
|
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
10 |
# or http://www.opensolaris.org/os/licensing.
|
|
11 |
# See the License for the specific language governing permissions
|
|
12 |
# and limitations under the License.
|
|
13 |
#
|
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each
|
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
16 |
# If applicable, add the following below this CDDL HEADER, with the
|
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying
|
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner]
|
|
19 |
#
|
|
20 |
# CDDL HEADER END
|
|
21 |
#
|
|
22 |
|
|
23 |
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
|
24 |
# Use is subject to license terms.
|
|
25 |
|
|
26 |
import testutils
|
|
27 |
if __name__ == "__main__":
|
|
28 |
testutils.setup_environment("../../../proto")
|
|
29 |
|
|
30 |
import unittest
|
|
31 |
import os
|
|
32 |
|
|
33 |
class TestPkgImageCreateBasics(testutils.SingleDepotTestCase):
|
|
34 |
# Only start/stop the depot once (instead of for every test)
|
|
35 |
persistent_depot = True
|
|
36 |
|
|
37 |
def test_basic(self):
|
|
38 |
""" Create an image, verify it. """
|
|
39 |
|
|
40 |
durl = self.dc.get_depot_url()
|
|
41 |
self.image_create(durl)
|
|
42 |
self.pkg("verify")
|
|
43 |
|
|
44 |
def test_image_create_bad_opts(self):
|
|
45 |
"""Test some bad cli options."""
|
|
46 |
|
|
47 |
self.pkg("image-create -@", exit=2)
|
|
48 |
self.pkg("image-create --bozo", exit=2)
|
|
49 |
self.pkg("image-create", exit=2)
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
def test_766(self):
|
|
54 |
"""Bug 766: image-create without authority prefix specified."""
|
|
55 |
|
|
56 |
durl = self.dc.get_depot_url()
|
|
57 |
|
|
58 |
pkgsend_data = """
|
|
59 |
open [email protected]
|
|
60 |
close
|
|
61 |
"""
|
|
62 |
self.pkgsend_bulk(durl, pkgsend_data)
|
|
63 |
|
|
64 |
self.assertRaises(testutils.UnexpectedExitCodeException,
|
|
65 |
self.image_create, durl, "")
|
|
66 |
|
|
67 |
|
|
68 |
class TestPkgImageCreateNoDepot(testutils.CliTestCase):
|
|
69 |
persistent_depot = True
|
|
70 |
def test_bad_image_create(self):
|
|
71 |
""" Create image from non-existent server """
|
|
72 |
|
|
73 |
#
|
|
74 |
# Currently port 4 is unassigned by IANA and we
|
|
75 |
# Can just hope that it never gets assigned.
|
|
76 |
# We choose localhost because, well, we think
|
|
77 |
# it will be universally able to be looked up.
|
|
78 |
#
|
|
79 |
durl = "http://localhost:4"
|
|
80 |
self.assertRaises(testutils.UnexpectedExitCodeException, \
|
|
81 |
self.image_create, durl)
|
|
82 |
|
|
83 |
def test_765(self):
|
|
84 |
"""Bug 765: malformed authority URL."""
|
|
85 |
|
|
86 |
durl = "bar=baz"
|
|
87 |
self.assertRaises(testutils.UnexpectedExitCodeException, \
|
|
88 |
self.image_create, durl)
|
|
89 |
|
|
90 |
def test_763a(self):
|
|
91 |
"""Bug 763, traceback 1: no -a option given to image-create."""
|
|
92 |
|
|
93 |
self.assertRaises(testutils.UnexpectedExitCodeException, \
|
|
94 |
self.pkg, "image-create foo")
|
|
95 |
|
|
96 |
def test_763c(self):
|
|
97 |
"""Bug 763, traceback 3: -a given to image-create, but no
|
|
98 |
authority specified."""
|
|
99 |
|
|
100 |
self.assertRaises(testutils.UnexpectedExitCodeException, \
|
|
101 |
self.pkg, "image-create -a foo")
|
|
102 |
|
|
103 |
def test_bad_authority_options(self):
|
|
104 |
"""More tests that abuse the authority prefix and URL."""
|
|
105 |
|
|
106 |
self.assertRaises(testutils.UnexpectedExitCodeException, \
|
|
107 |
self.pkg, "image-create -a $%^8=http://test1")
|
|
108 |
|
|
109 |
self.assertRaises(testutils.UnexpectedExitCodeException, \
|
|
110 |
self.pkg, "image-create -a test1=http://$%^8")
|
|
111 |
|
|
112 |
self.assertRaises(testutils.UnexpectedExitCodeException, \
|
|
113 |
self.pkg, "image-create -a test1=http://test1:abcde")
|
|
114 |
|
|
115 |
self.assertRaises(testutils.UnexpectedExitCodeException, \
|
|
116 |
self.pkg, "image-create -a test1=ftp://test1")
|
|
117 |
|
|
118 |
if __name__ == "__main__":
|
|
119 |
unittest.main()
|