summaryrefslogtreecommitdiffstats
path: root/generator.py
diff options
context:
space:
mode:
Diffstat (limited to 'generator.py')
-rwxr-xr-xgenerator.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/generator.py b/generator.py
index cf5ceb5..2c8fd69 100755
--- a/generator.py
+++ b/generator.py
@@ -655,9 +655,11 @@ def buildStubs():
print "Generated %d wrapper functions" % nb_wrap
- print "Missing type converters: "
- for type in unknown_types.keys():
- print "%s:%d " % (type, len(unknown_types[type])),
+ if unknown_types:
+ print "Missing type converters: "
+ for type in unknown_types.keys():
+ print "%s:%d " % (type, len(unknown_types[type])),
+
print
for f in functions_failed:
/a> 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
# Authors:
#   Petr Vobornik <pvoborni@redhat.com>
#
# Copyright (C) 2013  Red Hat
# see file 'COPYING' for use and warranty information
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""
Host tests
"""

from ipatests.test_webui.ui_driver import UI_driver
from ipatests.test_webui.ui_driver import screenshot
import ipatests.test_webui.data_hostgroup as hostgroup
import ipatests.test_webui.data_netgroup as netgroup
import ipatests.test_webui.data_hbac as hbac
import ipatests.test_webui.test_rbac as rbac
import ipatests.test_webui.data_sudo as sudo

ENTITY = 'host'


class host_tasks(UI_driver):

    def __init__(self, *args, **kwargs):
        super(host_tasks, self).__init__(args, kwargs)
        self.prep_data()
        self.prep_data2()

    def prep_data(self):
        host = 'itest'
        domain = self.config.get('ipa_domain')
        ip = self.get_ip()
        self.data = self.get_data(host, domain, ip)
        self.pkey = self.data['pkey']
        return self.data

    def prep_data2(self):
        host = 'itest2'
        domain = self.config.get('ipa_domain')
        self.data2 = self.get_data(host, domain)
        self.pkey2 = self.data2['pkey']
        return self.data2

    def get_data(self, host, domain, ip=None):
        if self.has_dns():
            add_data = [
                ('textbox', 'hostname', host),
                ('combobox', 'dnszone', domain),
            ]
            if ip:
                add_data.append(('textbox', 'ip_address', ip))
            add_data.append(('checkbox', 'force', None))
            del_data = [
                ('checkbox', 'updatedns', None)
            ]
        else:
            add_data = [
                ('textbox', 'fqdn', '%s.%s' % (host, domain)),
                ('checkbox', 'force', None),
            ]
            del_data = None

        data = {
            'pkey': '%s.%s' % (host, domain),
            'add': add_data,
            'mod': [
                ('textarea', 'description', 'Desc'),
            ],
            'del': del_data,
        }

        return data

    def get_ip(self):
        """
        Get next IP
        """
        ip = self.config.get('ipa_ip')
        if not ip:
            self.skip('FreeIPA Server IP address not configured')
        ip = ip.split('.')
        last = int(ip.pop())
        ip.append(str(last + 1))
        return '.'.join(ip)

    def load_csr(self, path):
        # ENHANCEMENT: generate csr dynamically
        with open(path, 'r') as csr_file:
            csr = csr_file.read()
        return csr


class test_host(host_tasks):

    @screenshot
    def test_crud(self):
        """
        Basic CRUD: host
        """
        self.init_app()
        self.basic_crud(ENTITY, self.data)

    @screenshot
    def test_certificates(self):
        """
        Test host certificate actions

        Requires to have CA installed and 'host_csr_path' configuration option
        set.
        """

        if not self.has_ca():
            self.skip('CA is not configured')

        csr_path = self.config.get('host_csr_path')
        if not csr_path:
            self.skip('CSR file is not configured')

        self.init_app()
        csr = self.load_csr(csr_path)
        panel = 'cert_actions'
        realm = self.config.get('ipa_realm')

        self.add_record(ENTITY, self.data)
        self.navigate_to_record(self.pkey)

        self.assert_visible("div[name='certificate-missing']")

        # cert request
        self.action_list_action('request_cert', confirm=False)
        self.fill_text('textarea.certificate', csr)
        self.dialog_button_click('issue')
        self.wait_for_request(n=2, d=0.5)
        self.assert_visible("div[name='certificate-valid']")

        # cert view
        self.action_list_action('view_cert', confirm=False)
        self.wait()
        self.assert_text("tbody tr:nth-child(2) td:nth-child(2)", self.pkey)