summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2020-03-25 17:25:29 +0100
committerMarek Vasut <marex@denx.de>2020-05-22 19:46:45 +0200
commit8ec27b01bc8b492a3aacc76a299f4e24b1a44d0c (patch)
treeb6d9fe83d8c82a0bef84170eabb9a1a27e5bb15b /include
parenteb69d8bf3c043f126077e6b0905def8cca5c4723 (diff)
net: ks8851: Checkpatch cleanup
Fix various checkpatch complaints. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Eugen Hristev <eugen.hristev@microchip.com> Cc: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 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 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662
# 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/>.

"""
Service tests
"""

from ipatests.test_webui.crypto_utils import generate_certificate, generate_csr
from ipatests.test_webui.ui_driver import UI_driver
from ipatests.test_webui.ui_driver import screenshot
import pytest

try:
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.action_chains import ActionChains
except ImportError:
    pass

ENTITY = 'service'


@pytest.mark.tier1
class sevice_tasks(UI_driver):

    def prep_data(self):

        host = self.config.get('ipa_server')
        realm = self.config.get('ipa_realm')
        pkey = 'itest'

        return {
            'pkey': '%s/%s@%s' % (pkey, host, realm),
            'add': [
                ('textbox', 'service', pkey),
                ('combobox', 'host', host)
            ],
            'mod': [
                ('checkbox', 'ipakrbokasdelegate', None),
            ],
        }

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

    def get_service_pkey(self, service, host=None):
        if not host:
            host = self.config.get('ipa_server')
        realm = self.config.get('ipa_realm')
        pkey = '{}/{}@{}'.format(service, host, realm)
        return pkey

    def add_host(self, hostname, dns_zone, force=False):
        self.navigate_to_entity('host')
        self.facet_button_click('add')
        self.fill_textbox('hostname', hostname)
        self.fill_textbox('dnszone', dns_zone)
        if force:
            self.check_option('force', 'checked')
        self.dialog_button_click('add')

    def add_service(self, service,
                    host=None,
                    textbox=None,
                    force=False,
                    cancel=False,
                    confirm=True):

        if not host:
            host = self.config.get('ipa_server')
        self.navigate_to_entity(ENTITY)
        self.facet_button_click('add')

        self.select_combobox('service', service, combobox_input=textbox)
        self.select_combobox('host', host)
        if force:
            self.wait(0.5)
            self.check_option('force', 'checked')
        if cancel:
            self.dialog_button_click('cancel')
            return
        if not confirm:
            return
        self.dialog_button_click('add')
        self.wait(0.3)
        self.assert_no_error_dialog()

    def run_keytab_on_host(self, principal, action):
        """
        Run ipa-get/rmkeytab command on UI host in order to test whether
        we have the key un/provisioned.

        Actions:

        'get' for /usr/sbin/ipa-getkeytab
        'rm' for /usr/sbin/ipa-rmkeytab
        """

        kt_path = '/tmp/test.keytab'

        if action == 'get':
            cmd = '/usr/sbin/ipa-getkeytab -p {} -k {}'.format(principal,
                                                               kt_path)
            self.run_cmd_on_ui_host(cmd)
        elif action == 'rm':
            cmd = '/usr/sbin/ipa-rmkeytab -p {} -k {}'.format(principal,
                                                              kt_path)
            kt_rm_cmd = 'rm -f {}'.format(kt_path)
            self.run_cmd_on_ui_host(cmd)
            self.run_cmd_on_ui_host(kt_rm_cmd)
        else:
            raise ValueError("Bad action specified")


@pytest.mark.tier1
class test_service(sevice_tasks):

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

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

        Requires to have CA installed.
        """

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

        self.init_app()
        data = self.prep_data()
        pkey = data.get('pkey')
        hostname = self.config.get('ipa_server')
        csr = generate_csr(hostname)
        cert_widget_sel = "div.certificate-widget"

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

        # cert request
        self.action_list_action('request_cert', confirm=False)
        # testing if cancel button works
        self.dialog_button_click('cancel')
        self.action_list_action('request_cert', confirm=False)
        self.assert_dialog()
        self.fill_text("textarea[name='csr'", csr)
        self.dialog_button_click('issue')
        self.wait_for_request(n=2, d=3)
        self.assert_visible(cert_widget_sel)

        widget = self.find(cert_widget_sel, By.CSS_SELECTOR)

        # cert view
        self.action_list_action('view', confirm=False,
                                parents_css_sel=cert_widget_sel)
        self.assert_dialog()
        self.dialog_button_click('close')

        # cert get
        self.action_list_action('get', confirm=False,
                                parents_css_sel=cert_widget_sel)
        self.assert_dialog()
        # check that text area is not empty
        self.assert_empty_value('textarea.certificate', negative=True)
        self.dialog_button_click('close')

        # cert download - we can only try to click the download action
        self.action_list_action('download', confirm=False,
                                parents_css_sel=cert_widget_sel)
        # check that revoke action is enabled
        self.assert_action_list_action('revoke',
                                       parents_css_sel=cert_widget_sel,
                                       facet_actions=False)

        # check that remove_hold action is not enabled
        self.assert_action_list_action('remove_hold', enabled=False,
                                       parents_css_sel=cert_widget_sel,
                                       facet_actions=False)

        # cert revoke/hold cancel
        self.action_list_action('revoke', confirm=False,
                                parents_css_sel=cert_widget_sel)
        self.wait()
        self.select('select', '6')
        self.dialog_button_click('cancel')

        # cert revoke/hold
        self.action_list_action('revoke', confirm=False,
                                parents_css_sel=cert_widget_sel)
        self.wait()
        self.select('select', '6')
        self.dialog_button_click('ok')
        self.wait_while_working(widget)

        self.assert_visible(cert_widget_sel + " div.watermark")

        # check that revoke action is not enabled
        self.assert_action_list_action('revoke', enabled=False,
                                       parents_css_sel=cert_widget_sel,
                                       facet_actions=False)

        # check that remove_hold action is enabled
        self.assert_action_list_action('remove_hold',
                                       parents_css_sel=cert_widget_sel,
                                       facet_actions=False)

        # cert remove hold cancel
        self.action_list_action('remove_hold', confirm=False,
                                parents_css_sel=cert_widget_sel)
        self.dialog_button_click('cancel')

        # cert remove hold
        self.action_list_action('remove_hold', confirm=False,
                                parents_css_sel=cert_widget_sel)
        self.wait()
        self.dialog_button_click('ok')
        self.wait_while_working(widget)

        # check that revoke action is enabled
        self.assert_action_list_action('revoke',
                                       parents_css_sel=cert_widget_sel,
                                       facet_actions=False)

        # check that remove_hold action is not enabled
        self.assert_action_list_action('remove_hold', enabled=False,
                                       parents_css_sel=cert_widget_sel,
                                       facet_actions=False)

        # cert revoke cancel
        self.action_list_action('revoke', confirm=False,
                                parents_css_sel=cert_widget_sel)
        self.wait()
        self.select('select', '1')
        self.dialog_button_click('cancel')

        # cert revoke
        self.action_list_action('revoke', confirm=False,
                                parents_css_sel=cert_widget_sel)
        self.wait()
        self.select('select', '1')
        self.dialog_button_click('ok')
        self.close_notifications()
        self.wait_while_working(widget)

        # check that revoke action is not enabled
        self.assert_action_list_action('revoke', enabled=False,
                                       parents_css_sel=cert_widget_sel,
                                       facet_actions=False)

        # check that remove_hold action not is enabled
        self.assert_action_list_action('remove_hold', enabled=False,
                                       parents_css_sel=cert_widget_sel,
                                       facet_actions=False)

        # cleanup
        self.navigate_to_entity(ENTITY, 'search')
        self.delete_record(pkey, data.get('del'))

    @screenshot
    def test_arbitrary_certificates(self):
        """
        Test managing service arbitrary certificate.
        """
        self.init_app()
        data = self.prep_data()
        pkey = data.get('pkey')
        hostname = self.config.get('ipa_server')
        cert = generate_certificate(hostname)
        cert_widget_sel = "div.certificate-widget"

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

        # check whether certificate section is present
        self.assert_visible("div[name='certificate']")

        # add certificate
        self.button_click('add', parents_css_sel="div[name='certificate']")
        self.assert_dialog('cert-add-dialog')
        self.fill_textarea('new_cert', cert)
        self.dialog_button_click('ok')

        self.assert_visible(cert_widget_sel)

        # cert view
        self.action_list_action('view', confirm=False,
                                parents_css_sel=cert_widget_sel)
        self.assert_dialog()
        self.dialog_button_click('close')

        # cert get
        self.action_list_action('get', confirm=False,
                                parents_css_sel=cert_widget_sel)
        self.assert_dialog()

        # check that the textarea is not empty
        self.assert_empty_value('textarea.certificate', negative=True)
        self.dialog_button_click('close')

        # cert download - we can only try to click the download action
        self.action_list_action('download', confirm=False,
                                parents_css_sel=cert_widget_sel)

        # check that revoke action is not enabled
        self.assert_action_list_action('revoke', enabled=False,
                                       parents_css_sel=cert_widget_sel,
                                       facet_actions=False)

        # check that remove_hold action is not enabled
        self.assert_action_list_action('remove_hold', enabled=False,
                                       parents_css_sel=cert_widget_sel,
                                       facet_actions=False)

        # cleanup
        self.navigate_to_entity(ENTITY, 'search')
        self.delete_record(pkey, data.get('del'))

    @screenshot
    def test_ca_less(self):
        """
        Test service certificate actions in CA-less install
        http://www.freeipa.org/page/V3/CA-less_install