def test_xroad_audit_log(self):
        '''
        audit.log checking test. Checks if audit.log of a specified server contains specified (in configuration or
        command-line parameters) entries. Test succeeds if all of the entries are found; fails otherwise.
        :return: None
        '''
        main = MainController(self)

        # Set test name and number
        main.test_number = 'LOGCHECK'
        main.test_name = self.__class__.__name__

        # Get parameters from the configuration file.

        # We can supply a "server" name to this test. This means that it uses this name as a category name and
        # fetches ssh_host, ssh_user and ssh_pass of this category. For example, you can set audit.server=ss1 and
        # the values that are used are ss1.ssh_host, ss1.ssh_user, and ss1.ssh_pass respectively.
        audit_server = main.config.get('audit.server')
        if audit_server is not None:
            # audit.server was supplied so we're reading data from the sections
            xroad_server = main.config.get('{0}.ssh_host'.format(audit_server))
            ssh_username = main.config.get('{0}.ssh_user'.format(audit_server))
            ssh_password = main.config.get('{0}.ssh_pass'.format(audit_server))
        else:
            # If audit.server was not supplied, we read each parameter separately
            xroad_server = main.config.get('audit.ssh_host')
            ssh_username = main.config.get('audit.ssh_user')
            ssh_password = main.config.get('audit.ssh_pass')

        # Get logfile
        logfile = main.config.get('audit.logfile')

        # Get data to be checked
        check_json = main.config.get('audit.check-logs')

        # Read data from this line
        from_line = main.config.get_int('audit.from-line', 0)

        # Because the supplied parameter may also be a string, use try-except
        try:
            check_entries = json.loads(check_json)
        except (ValueError, TypeError):
            check_entries = [check_json]
            sys.exc_clear()

        # Configure the service
        test_audit_log = audit_log.test_audit_log(case=main, xroad_server=xroad_server, ssh_username=ssh_username,
                                                  ssh_password=ssh_password, logfile=logfile)

        try:
            # Run audit.log checking
            test_audit_log(check_lines=check_entries, from_line=from_line)
        except:
            main.log('XroadAuditLog: audit.log check failed for: {0}'.format(check_json))
            main.save_exception_data()
            raise
        finally:
            # Test teardown
            main.tearDown()
    def test_deactivate_wsdl(self):
        main = MainController(self)

        # Set test name and number
        main.test_number = '2.2.6'
        main.test_name = self.__class__.__name__

        ss_host = main.config.get('ss2.host')
        ss_user = main.config.get('ss2.user')
        ss_pass = main.config.get('ss2.pass')

        client = xroad.split_xroad_id(main.config.get('ss2.client_id'))
        requester = xroad.split_xroad_id(main.config.get('ss1.client_id'))

        wsdl_url = main.config.get('wsdl.remote_path').format(
            main.config.get('wsdl.service_wsdl'))

        # Configure the service
        test_deactivate_wsdl = deactivate_wsdl_2_2_6.test_disable_wsdl(
            main, client=client, wsdl_url=wsdl_url, requester=requester)

        test_reactivate_wsdl = deactivate_wsdl_2_2_6.test_enable_wsdl(
            main, client=client, wsdl_url=wsdl_url, requester=requester)

        try:
            main.reload_webdriver(url=ss_host,
                                  username=ss_user,
                                  password=ss_pass)
            test_deactivate_wsdl()
        except:
            main.log('XroadDeactivateWsdl: Failed to deactivate WSDL')
            main.save_exception_data()
            assert False
        finally:
            try:
                main.reload_webdriver(url=ss_host,
                                      username=ss_user,
                                      password=ss_pass)
                test_reactivate_wsdl()
            except:
                main.log('XroadDeactivateWsdl: Failed to reactivate WSDL')
                main.save_exception_data()
                assert False
            finally:
                # Test teardown
                main.tearDown(save_exception=False)
Esempio n. 3
0
    def test_xroad_member_access(self):
        main = MainController(self)

        # Set test name and number
        main.test_number = '2.2.9'
        main.test_name = self.__class__.__name__

        ss2_host = main.config.get('ss2.host')
        ss2_user = main.config.get('ss2.user')
        ss2_pass = main.config.get('ss2.pass')

        wsdl_url = main.config.get('wsdl.remote_path').format(
            main.config.get('wsdl.service_wsdl'))
        service_name = main.config.get('services.test_service')

        client = xroad.split_xroad_id(main.config.get('ss2.client_id'))
        requester = xroad.split_xroad_id(main.config.get('ss2.client2_id'))

        # Configure the test
        test_xroad_member_access = xroad_member_access_2_2_9.test_xroad_member_access(
            main,
            client=client,
            requester=requester,
            wsdl_url=wsdl_url,
            service_name=service_name)
        # Set Security Server 2
        main.reload_webdriver(url=ss2_host,
                              username=ss2_user,
                              password=ss2_pass)

        try:
            # Test local TLS
            test_xroad_member_access()
        except:
            main.save_exception_data()
            assert False
        finally:
            # Test teardown
            main.tearDown(save_exception=False)
    def test_tls_227(self):
        main = MainController(self)

        # Set test name and number
        main.test_number = '2.2.7'
        main.test_name = self.__class__.__name__

        client = xroad.split_xroad_id(main.config.get('ss1.client_id'))
        provider = xroad.split_xroad_id(main.config.get('ss2.client_id'))

        # Configure the tests
        test_local_tls = local_tls_2_2_7.test_tls(case=main,
                                                  client=client,
                                                  provider=provider)
        delete_local_tls = local_tls_2_2_7.test_delete_tls(case=main,
                                                           client=client,
                                                           provider=provider)

        try:
            # Test local TLS
            test_local_tls()
        except:
            main.log(
                'XroadLocalTls: Failed to configure TLS for local service')
            main.save_exception_data()
            # Delete internal certificates from the servers
            try:
                delete_local_tls()
            except:
                main.save_exception_data()
                main.log(
                    'XroadLocalTls: failed to remove TLS from local service')
            assert False
        finally:
            # Test teardown
            main.tearDown(save_exception=False)
    def test_xroad_configure_service(self):
        main = MainController(self)

        # Set test name and number
        main.test_number = '2.2.2'
        main.test_name = self.__class__.__name__

        ss_host = main.config.get('ss2.host')
        ss_user = main.config.get('ss2.user')
        ss_pass = main.config.get('ss2.pass')

        client = xroad.split_xroad_id(main.config.get('ss2.client_id'))
        requester = xroad.split_xroad_id(main.config.get('ss1.client_id'))

        wsdl_url = main.config.get('wsdl.remote_path').format(main.config.get('wsdl.service_wsdl'))

        service_name = main.config.get('services.test_service')  # xroadGetRandom
        service_2_name = main.config.get('services.test_service_2')  # bodyMassIndex

        subject_list = [xroad.get_xroad_subsystem(requester)]

        # Configure the service
        test_configure_service = configure_service_2_2_2.test_configure_service(case=main, client=client,
                                                                                check_add_errors=False,
                                                                                check_edit_errors=False,
                                                                                check_parameter_errors=False,
                                                                                service_name=service_name)

        # Add the subject to ACL
        test_configure_service_acl = add_to_acl_2_1_8.test_add_subjects(case=main, client=client,
                                                                        wsdl_url=wsdl_url,
                                                                        service_name=service_name,
                                                                        service_subjects=subject_list,
                                                                        remove_data=False,
                                                                        allow_remove_all=False)
        test_configure_service_acl_2 = add_to_acl_2_1_8.test_add_subjects(case=main, client=client,
                                                                          wsdl_url=wsdl_url,
                                                                          service_name=service_2_name,
                                                                          service_subjects=subject_list,
                                                                          remove_data=False,
                                                                          allow_remove_all=False)
        # Enable the service
        test_enable_service = configure_service_2_2_2.test_enable_service(case=main, client=client, wsdl_url=wsdl_url)

        # Delete the added service
        test_delete_service = configure_service_2_2_2.test_delete_service(case=main, client=client, wsdl_url=wsdl_url)

        try:
            # Open webdriver
            main.reload_webdriver(url=ss_host, username=ss_user, password=ss_pass)

            # TEST PLAN 2.2.2-1, 2.2.2-2 add WSDL and configure service
            test_configure_service()

            # TEST PLAN 2.2.2-3 configure service ACL
            main.log('2.2.2-3 configure service ACL')
            main.reload_webdriver(url=ss_host, username=ss_user, password=ss_pass)
            test_configure_service_acl()

            # TEST PLAN 2.2.2-3 configure second service ACL
            main.log('2.2.2-3 configure second service ACL')
            main.reload_webdriver(url=ss_host, username=ss_user, password=ss_pass)
            test_configure_service_acl_2()

            # TEST PLAN 2.2.2-4 enable service
            main.reload_webdriver(url=ss_host, username=ss_user, password=ss_pass)
            test_enable_service()
        except:
            main.log('XroadConfigureService: Failed to configure service')
            main.save_exception_data()
            try:
                # Delete service
                main.reload_webdriver(url=ss_host, username=ss_user, password=ss_pass)
                test_delete_service()
            except:
                main.log('XroadConfigureService: Failed to delete added data.')
                main.save_exception_data()
            assert False
        finally:
            # Test teardown
            main.tearDown()
    def test_add_central_service_2_2_8(self):
        main = MainController(self)

        # Set test name and number
        main.test_number = '2.2.8'
        main.test_name = self.__class__.__name__

        cs_host = main.config.get('cs.host')
        cs_user = main.config.get('cs.user')
        cs_pass = main.config.get('cs.pass')

        ss2_host = main.config.get('ss2.host')
        ss2_user = main.config.get('ss2.user')
        ss2_pass = main.config.get('ss2.pass')

        requester = xroad.split_xroad_id(main.config.get('ss1.client_id'))
        provider = xroad.split_xroad_id(main.config.get('services.central_service_provider_id'))
        provider_2 = xroad.split_xroad_id(main.config.get('services.central_service_provider_2_id'))

        service_name = main.config.get('services.test_service')
        central_service_name = main.config.get('services.central_service')

        wsdl_url = main.config.get('wsdl.remote_path').format(main.config.get('wsdl.service_wsdl'))

        wait_sync_retry_delay = main.config.get('services.request_sync_delay')
        sync_max_seconds = main.config.get('services.request_sync_timeout')

        requester_id = xroad.get_xroad_subsystem(requester)

        # Configure the service (2.2.8-1 to 2.2.8-3)
        add_central_service = add_central_service_2_2_8.test_add_central_service(main, provider=provider,
                                                                                 requester=requester,
                                                                                 central_service_name=central_service_name,
                                                                                 sync_max_seconds=sync_max_seconds,
                                                                                 wait_sync_retry_delay=wait_sync_retry_delay)

        # Configure a new service (2.2.8-4)
        configure_service = configure_service_2_2_2.test_configure_service(main, client=provider_2,
                                                                           service_name=service_name,
                                                                           check_add_errors=False,
                                                                           check_edit_errors=False,
                                                                           check_parameter_errors=False)

        # Add subject to ACL (2.2.8-4)
        configure_service_acl = add_to_acl_2_1_8.test_add_subjects(main, client=provider_2, wsdl_url=wsdl_url,
                                                                   service_name=service_name,
                                                                   service_subjects=[requester_id],
                                                                   remove_data=False, allow_remove_all=False)
        # Enable new service (2.2.8-4)
        enable_service = configure_service_2_2_2.test_enable_service(main, client=provider_2, wsdl_url=wsdl_url)

        # Delete new service (undo the changes we made for 2.2.8-4)
        delete_service = configure_service_2_2_2.test_delete_service(main, client=provider_2, wsdl_url=wsdl_url)

        # Configure central service (2.2.8-5 to 2.2.8-6)
        edit_central_service = add_central_service_2_2_8.test_edit_central_service(main,
                                                                                   provider=provider_2,
                                                                                   requester=requester,
                                                                                   central_service_name=central_service_name,
                                                                                   sync_max_seconds=sync_max_seconds,
                                                                                   wait_sync_retry_delay=wait_sync_retry_delay)

        # Delete central service (undo changes we made for 2.2.8)
        delete_central_service = add_central_service_2_2_8.test_delete_central_service(main,
                                                                                       central_service_name=central_service_name,
                                                                                       provider=provider_2,
                                                                                       requester=requester,
                                                                                       sync_max_seconds=sync_max_seconds,
                                                                                       wait_sync_retry_delay=wait_sync_retry_delay)

        try:
            # TEST PLAN 2.2.8-1, 2.2.8-2, 2.2.8-3 add central service
            main.log('XroadAddCentralService: Add central service')
            # Set Central Server UI
            main.reload_webdriver(url=cs_host, username=cs_user, password=cs_pass)
            add_central_service()

            # TEST PLAN 2.2.8-4 configure new provider for central service
            main.log('XroadAddCentralService: Configure service parameters (using 2.2.2)')
            # Set Security Server 2 and configure service parameters
            main.reload_webdriver(url=ss2_host, username=ss2_user, password=ss2_pass)
            configure_service()

            # TEST PLAN 2.2.8-4 configure new provider for central service (set access using ACL)
            main.log('XroadAddCentralService: Configure service ACL (using 2.1.8)')
            # Go to SS2 main page (no need to login again) and configure ACL
            main.reload_webdriver(url=ss2_host)
            configure_service_acl()

            # TEST PLAN 2.2.8-4 enable the new provider service
            main.log('XroadAddCentralService: Enable service (using 2.2.2)')
            # Go to SS2 main page (no need to login again) and enable service
            main.reload_webdriver(url=ss2_host)
            enable_service()

            # TEST PLAN 2.2.8-5, 2.2.8-6 edit and test the central service with the new provider
            main.log('XroadAddCentralService: Edit central service')
            # Go to CS main page (login again if necessary) and edit the central service
            main.reload_webdriver(url=cs_host, username=cs_user, password=cs_pass)
            edit_central_service()

        except Exception, e:
            main.log('XroadAddCentralService: Error, undoing changes')
            main.save_exception_data()
            try:
                # Go to CS main page (login again if necessary) and edit the central service
                main.reload_webdriver(url=cs_host, username=cs_user, password=cs_pass)

                try:
                    # Delete central service
                    delete_central_service()
                except:
                    main.log('XroadAddCentralService: Error deleting central service')
                    main.save_exception_data()
                    raise
                finally:
                    try:
                        # Go to SS2 main page (re-login if necessary) and delete the newly created service
                        main.reload_webdriver(url=ss2_host, username=ss2_user, password=ss2_pass)
                        delete_service()
                    except:
                        main.log('XroadAddCentralService: Error deleting security server service')
                        main.save_exception_data()
                        assert False
            except:
                assert False
Esempio n. 7
0
    def test_refresh_wsdl(self):
        main = MainController(self)

        # Set test name and number
        main.test_number = '2.2.5'
        main.test_name = self.__class__.__name__

        ss_host = main.config.get('ss2.host')
        ss_user = main.config.get('ss2.user')
        ss_pass = main.config.get('ss2.pass')

        ssh_host = main.config.get('wsdl.ssh_host')
        ssh_username = main.config.get('wsdl.ssh_user')
        ssh_password = main.config.get('wsdl.ssh_pass')

        client = xroad.split_xroad_id(main.config.get('ss2.client_id'))
        requester = xroad.split_xroad_id(main.config.get('ss1.client_id'))

        wsdl_remote_path = main.config.get('wsdl.remote_path')
        wsdl_local_path = main.config.get('wsdl.local_path')

        wsdl_filename = main.config.get('wsdl.service_wsdl')
        wsdl_url = wsdl_remote_path.format(wsdl_filename)

        wsdl_correct = main.config.get('wsdl.service_correct_filename')
        wsdl_missing_service = main.config.get(
            'wsdl.service_single_service_filename')
        wsdl_error = main.config.get('wsdl.service_wsdl_error_filename')
        wsdl_warning = main.config.get('wsdl.service_wsdl_warning_filename')

        service_name = main.config.get('services.test_service_2')
        service_2_name = main.config.get('services.test_service')

        # Configure the service
        test_refresh_wsdl = refresh_wsdl_2_2_5.test_refresh_wsdl(
            main,
            client=client,
            wsdl_url=wsdl_url,
            service_name=service_name,
            service_name_2=service_2_name,
            requester=requester,
            wsdl_path=wsdl_remote_path,
            wsdl_local_path=wsdl_local_path,
            wsdl_filename=wsdl_filename,
            wsdl_correct=wsdl_correct,
            wsdl_missing_service=wsdl_missing_service,
            wsdl_error=wsdl_error,
            wsdl_warning=wsdl_warning,
            ssh_host=ssh_host,
            ssh_username=ssh_username,
            ssh_password=ssh_password)

        # Reset the service
        test_reset_wsdl = refresh_wsdl_2_2_5.test_reset_wsdl(
            main,
            wsdl_local_path=wsdl_local_path,
            wsdl_filename=wsdl_filename,
            wsdl_correct=wsdl_correct,
            ssh_host=ssh_host,
            ssh_username=ssh_username,
            ssh_password=ssh_password)

        try:
            main.reload_webdriver(url=ss_host,
                                  username=ss_user,
                                  password=ss_pass)
            test_refresh_wsdl()
        except:
            main.log('XroadRefreshWsdl: Failed to refresh WSDL')
            main.save_exception_data()
            try:
                test_reset_wsdl()
            except:
                main.log(
                    'XroadRefreshWsdl: Failed to reset WSDL to original file')
                main.save_exception_data()
            assert False
        finally:
            # Test teardown
            main.tearDown(save_exception=False)