コード例 #1
0
    def wrong_format_error(self):
        '''
        Test importing a certificate that is in a wrong format (not DER/PEM). Should fail.
        :param self: MainController object
        :return: None
        '''

        # TEST PLAN 2.1.3.1-5 try to import a non-DER and non-PEM certificate. Should fail.
        self.log('2.1.3.1-5 trying to import a non-DER and non-PEM certificate')

        self.driver.get(self.url)
        self.wait_jquery()

        # Get a text file
        path = self.get_temp_path('INFO')
        temp_path = glob.glob(path)[0]

        # Try to import the text file as a certificate. Should fail.
        self.log('2.1.3.1-5 trying to import a non-PEM/non-DER file. Should fail.')
        import_cert(self, temp_path)
        self.wait_jquery()
        time.sleep(3)

        assert messages.get_error_message(self) == messages.WRONG_FORMAT_CERTIFICATE
        self.log('2.1.3.1-5 got an error, test succeeded.')
コード例 #2
0
def edit_wsdl(self, wsdl_url, clear_field=True):
    '''
    Tries to enter WSDL url to "Edit WSDL Parameters" dialog URL input field and press "OK"
    :param self:
    :param url: str - URL that contains the WSDL
    :param clear_field: Boolean - clear the field before entering anything
    :return:
    '''

    self.log('Setting new WSDL: {0}'.format(wsdl_url))

    # Find the "Edit WSDL Parameters" dialog. Because this function can be called from a state where the dialog is open and
    # a state where it is not, we'll first check if the dialog is open. If it is not, we'll click the "Edit"
    # button to open it.
    wsdl_dialog = self.by_xpath(popups.EDIT_WSDL_POPUP_XPATH)

    # Open the dialog if it is not already open
    if not wsdl_dialog.is_displayed():
        # Find "Edit" button and click it.
        edit_wsdl_button = self.by_id(
            popups.CLIENT_DETAILS_POPUP_EDIT_WSDL_BTN_ID)
        edit_wsdl_button.click()

        # Find the dialog and wait until it is visible.
        self.wait_until_visible(wsdl_dialog)

    # Now an "Edit WSDL Parameters" dialog with a URL prompt should be open. Let's try to set the WSDL URL.

    # Find the URL input element
    wsdl_url_input = self.by_id(popups.EDIT_WSDL_POPUP_URL_ID)

    # Clear the field if told so
    if clear_field:
        wsdl_url_input.clear()

    # Enter the WSDL URL into the input.
    # wsdl_url_input.send_keys(wsdl_url)
    self.input(wsdl_url_input, wsdl_url)

    # Find the "OK" button in "Edit WSDL Parameters" dialog
    wsdl_dialog_ok_button = self.by_xpath(popups.EDIT_WSDL_POPUP_OK_BTN_XPATH)
    wsdl_dialog_ok_button.click()

    # Clicking the button starts an ajax query. Wait until request is complete.
    self.wait_jquery()

    console_output = messages.get_console_output(
        self)  # Console message (displayed if WSDL validator gives a warning)
    warning_message = messages.get_warning_message(self)  # Warning message
    error_message = messages.get_error_message(
        self)  # Error message (anywhere)

    if console_output is not None:
        popups.close_console_output_dialog(self)

    return warning_message, error_message, console_output
コード例 #3
0
    def wrong_cert_type_error(self, client):
        '''
        Test that tries to import a wrong type of certificate to the server. This certificate should not be imported.
        :param self: MainController object
        :param client: client data
        :return: None
        '''

        # TEST PLAN 2.1.3.1-2 certificate is not a signing certificate

        self.log('2.1.3.1-2 test importing a certificate that is not a signing certificate')
        remote_csr_path = 'temp.der'
        cert_path = 'temp.pem'

        # Set local path for certificate
        local_cert_path = self.get_download_path(cert_path)

        server_name = ssh_server_actions.get_server_name(self)

        # Remove temporary files
        for fpath in glob.glob(self.get_download_path('*')):
            os.remove(fpath)

        # Generate CSR for the client
        self.log('2.1.3.1-2 generate CSR for the client')
        generate_csr(self, client['code'], client['class'], ssh_server_actions.get_server_name(self))
        file_path = \
            glob.glob(self.get_download_path('_'.join(['*', server_name, client['class'], client['code']]) + '.der'))[0]

        # Create SSH connection to CA
        sshclient = ssh_client.SSHClient(self.config.get('ca.ssh_host'), self.config.get('ca.ssh_user'),
                                         self.config.get('ca.ssh_pass'))

        # Get an authentication certificate instead of signing certificate.
        self.log('2.1.3.1-2 get the authentication certificate')
        get_cert(sshclient, 'sign-auth', file_path, local_cert_path, cert_path, remote_csr_path)
        time.sleep(6)
        file_cert_path = glob.glob(local_cert_path)[0]

        # Try to import certificate
        self.log('2.1.3.1-2 trying to import authentication certificate as signing certificate. Should fail.')
        import_cert(self, file_cert_path)
        self.wait_jquery()
        time.sleep(3)
        assert messages.get_error_message(
            self) == messages.CERTIFICATE_NOT_SIGNING_KEY
        self.log('2.1.3.1-2 certificate not accepted, test succeeded')

        self.log('2.1.3.1-2 remove test data')
        popups.close_all_open_dialogs(self)
        remove_certificate(self, client)
コード例 #4
0
    def no_key_error(self, client):
        '''
        Try to import certificate that does not have a corresponding key in the server. Should fail.
        :param self: MainController object
        :param client: client data
        :return: None
        '''

        # TEST PLAN 2.1.3.1-3 key used for requesting the certificate is not found
        self.log('2.1.3.1-3 test importing a certificate that does not have a corresponding key')
        remote_csr_path = 'temp.der'
        cert_path = 'temp.pem'

        # Get local certificate path
        local_cert_path = self.get_download_path(cert_path)

        server_name = ssh_server_actions.get_server_name(self)

        # Remove temporary files
        for fpath in glob.glob(self.get_download_path('*')):
            os.remove(fpath)

        # Generate CSR
        self.log('2.1.3.1-3 generate CSR for the client')
        generate_csr(self, client['code'], client['class'], ssh_server_actions.get_server_name(self))
        file_path = \
            glob.glob(self.get_download_path('_'.join(['*', server_name, client['class'], client['code']]) + '.der'))[0]
        sshclient = ssh_client.SSHClient(self.config.get('ca.ssh_host'), self.config.get('ca.ssh_user'),
                                         self.config.get('ca.ssh_pass'))

        # Get the signing certificate from CA
        self.log('2.1.3.1-3 getting signing certificate from the CA')
        get_cert(sshclient, 'sign-sign', file_path, local_cert_path, cert_path, remote_csr_path)
        time.sleep(6)
        file_cert_path = glob.glob(local_cert_path)[0]

        # Remove the certificate and key from the server
        self.log('2.1.3.1-3 remove the key from the server')
        remove_certificate(self, client)

        # Try to import the certificate that does not have a key any more
        self.log('2.1.3.1-3 try to import the certificate. Should fail.')
        import_cert(self, file_cert_path)
        self.wait_jquery()
        time.sleep(3)

        assert messages.get_error_message(self) == messages.NO_KEY_FOR_CERTIFICATE
        self.log('2.1.3.1-3 got an error message, test succeeded')
コード例 #5
0
    def refresh_wsdl():
        # Find the "Refresh" button
        refresh_button = self.by_id(
            popups.CLIENT_DETAILS_POPUP_REFRESH_WSDL_BTN_ID)

        time.sleep(3)
        # Click the "Refresh" button to reload the WSDL. This may take some time as the system does an
        # HTTP(S) request to another server. Then wait until the ajax query finishes.
        refresh_button.click()
        self.wait_jquery()

        console_output = messages.get_console_output(
            self
        )  # Console message (displayed if WSDL validator gives a warning)
        warning_message = messages.get_warning_message(self)  # Warning message
        error_message = messages.get_error_message(
            self)  # Error message (anywhere)

        if console_output is not None:
            popups.close_console_output_dialog(self)

        return warning_message, error_message, console_output
コード例 #6
0
    def already_existing_error(self, client):
        '''
        Test importing a certificate that already exists. Should not be added as a duplicate.
        :param self: MainController object
        :param client: client data
        :return: None
        '''

        # TEST PLAN 2.1.3.1-6 try to import a certificate that has already been added.
        self.log('2.1.3.1-6 try to import a certificate that has already been added.')

        self.driver.get(self.url)
        self.wait_jquery()

        remote_csr_path = 'temp.der'
        cert_path = 'temp.pem'

        # Get local certificate path
        local_cert_path = self.get_download_path(cert_path)

        server_name = ssh_server_actions.get_server_name(self)

        for fpath in glob.glob(self.get_download_path('*')):
            os.remove(fpath)

        # Generate CSR for the client
        self.log('2.1.3.1-6 generate CSR for the client')
        generate_csr(self, client['code'], client['class'], ssh_server_actions.get_server_name(self))
        file_path = \
            glob.glob(self.get_download_path('_'.join(['*', server_name, client['class'], client['code']]) + '.der'))[0]

        # Open an SSH connection to CA
        sshclient = ssh_client.SSHClient(self.config.get('ca.ssh_host'), self.config.get('ca.ssh_user'),
                                         self.config.get('ca.ssh_pass'))

        # Get the signing certificate from CA
        self.log('2.1.3.1-6 get signing certificate from CA')
        get_cert(sshclient, 'sign-sign', file_path, local_cert_path, cert_path, remote_csr_path)
        time.sleep(6)
        file_cert_path = glob.glob(local_cert_path)[0]

        # Import the signing certificate. Should succeed.
        self.log('2.1.3.1-6 import the signing certificate.')
        import_cert(self, file_cert_path)
        self.wait_jquery()
        time.sleep(3)

        # Import the same signing certificate. Should fail.
        self.log('2.1.3.1-6 import the same signing certificate. Should fail.')
        import_cert(self, file_cert_path)
        self.wait_jquery()
        time.sleep(3)

        assert messages.CERTIFICATE_ALREADY_EXISTS in messages.get_error_message(self)
        self.log('2.1.3.1-6 got an error for duplicate certificate, test succeeded')

        popups.close_all_open_dialogs(self)

        # Remove the certificate
        self.log('2.1.3.1-6 removing the test certificate')
        remove_certificate(self, client)
コード例 #7
0
    def no_client_for_certificate_error(self, client):
        '''
        Try to import a certificate that is issued to a non-existing client. Should fail.
        :param self: MainController object
        :param client: client data
        :return: None
        '''

        # TEST PLAN 2.1.3.1-4 client set in the certificate is not in the system
        self.log('2.1.3.1-4 import a certificate that is issued to a non-existing client.')

        self.driver.get(self.url)
        self.wait_jquery()

        remote_csr_path = 'temp.der'
        cert_path = 'temp.pem'

        # Get the local path of the certificate
        local_cert_path = self.get_download_path(cert_path)

        server_name = ssh_server_actions.get_server_name(self)

        # Remove temporary files
        for fpath in glob.glob(self.get_download_path('*')):
            os.remove(fpath)

        # Generate CSR for the client
        self.log('2.1.3.1-4 generate CSR for the client')
        generate_csr(self, client['code'], client['class'], ssh_server_actions.get_server_name(self))
        file_path = \
            glob.glob(self.get_download_path('_'.join(['*', server_name, client['class'], client['code']]) + '.der'))[0]

        # Create an SSH connection to CA
        sshclient = ssh_client.SSHClient(self.config.get('ca.ssh_host'), self.config.get('ca.ssh_user'),
                                         self.config.get('ca.ssh_pass'))

        # Get the signing certificate from CA
        self.log('2.1.3.1-4 get the signing certificate from CA')
        get_cert(sshclient, 'sign-sign', file_path, local_cert_path, cert_path, remote_csr_path)
        time.sleep(6)
        file_cert_path = glob.glob(local_cert_path)[0]

        # Remove the test client.
        self.log('2.1.3.1-4 removing test client.')
        remove_client(self, client)

        # Try to import the certificate. Should fail.
        self.log('2.1.3.1-4 import a certificate that is issued to the client that was just removed. Should fail.')
        import_cert(self, file_cert_path)
        self.wait_jquery()
        time.sleep(3)

        assert messages.NO_CLIENT_FOR_CERTIFICATE in messages.get_error_message(self)
        self.log('2.1.3.1-4 got an error, test succeeded.')

        popups.close_all_open_dialogs(self)

        # Remove the certificate from the server
        self.log('2.1.3.1-4 removing the certificate.')
        remove_certificate(self, client)

        self.driver.get(self.url)
        self.wait_jquery()

        # Restore the client
        self.log('2.1.3.1-4 restoring the client.')
        add_client(self, client)

        # Wait until data updated
        time.sleep(60)
コード例 #8
0
    def not_valid_ca_error(self, client):
        '''
        Test for trying to add a certificate that was not issued by a valid certification authority (2.1.3.1-1)
        Expectation: certificate not added.
        :param self: MainController object
        :param client: client data
        :return: None
        '''

        # TEST PLAN 2.1.3.1-1 certificate is issued by a certification authority that is not in the allow list
        self.log('2.1.3.1-1 certificate is issued by a certification authority that is not in the allow list')
        error = False
        try:
            remote_csr_path = 'temp.der'
            cert_path = 'temp.pem'

            # Get local certificate path
            local_cert_path = self.get_download_path(cert_path)

            server_name = ssh_server_actions.get_server_name(self)

            # Remove temporary files
            for fpath in glob.glob(self.get_download_path('*')):
                os.remove(fpath)

            # Generate CSR for the client
            self.log('2.1.3.1-1 Generate CSR for the client')
            generate_csr(self, client['code'], client['class'], ssh_server_actions.get_server_name(self))
            file_path = \
                glob.glob(
                    self.get_download_path('_'.join(['*', server_name, client['class'], client['code']]) + '.der'))[0]

            # Create a new SSH connection to CA
            sshclient = ssh_client.SSHClient(self.config.get('ca.ssh_host'), self.config.get('ca.ssh_user'),
                                             self.config.get('ca.ssh_pass'))

            # Get the signing certificate from our CSR
            self.log('2.1.3.1-1 Get the signing certificate from the certificate request')
            get_cert(sshclient, 'sign-sign', file_path, local_cert_path, cert_path, remote_csr_path)
            time.sleep(6)
            file_cert_path = glob.glob(local_cert_path)[0]

            # Remove CA from central server
            self.log('2.1.3.1-1 Removing ca from central server')

            # Relogin
            self.logout(self.config.get('cs.host'))
            self.login(self.config.get('cs.user'), self.config.get('cs.pass'))

            # Go to certification services in the UI
            self.wait_until_visible(type=By.CSS_SELECTOR, element=sidebar_constants.CERTIFICATION_SERVICES_CSS).click()

            table = self.wait_until_visible(type=By.ID, element=certification_services.CERTIFICATION_SERVICES_TABLE_ID)
            rows = table.find_element_by_tag_name('tbody').find_elements_by_tag_name('tr')

            # Find our CA and remove it
            for row in rows:
                if self.config.get('ca.ssh_host') in row.text:
                    row.click()
                    self.wait_until_visible(type=By.ID, element=certification_services.DELETE_BTN_ID).click()
                    popups.confirm_dialog_click(self)

            self.log('Wait 240 seconds for changes')
            time.sleep(240)
            self.log('Reloading page after changes')

            # Reload page and wait until additional data is loaded using jQuery
            self.driver.refresh()
            self.wait_jquery()

            # Try to import the certificate
            self.log('2.1.3.1-1 Trying to import certificate')
            import_cert(self, file_cert_path)
            self.wait_jquery()
            time.sleep(2)

            # Check if we got an error message
            assert messages.get_error_message(self) == messages.CA_NOT_VALID_AS_SERVICE
            self.log('2.1.3.1-1 got correct error message')
        except:
            # Test failed

            self.log('2.1.3.1-1 failed')
            # Print traceback
            traceback.print_exc()
            error = True
        finally:
            # After testing, re-add the CA and restore the state the server was in
            self.log('2.1.3.1-1-del restoring previous state')

            # Login to Central Server
            self.driver.get(self.config.get('cs.host'))

            if not login.check_login(self, self.config.get('cs.user')):
                self.login(self.config.get('cs.user'), self.config.get('cs.pass'))

            # Create SSH connection to CA
            sshclient = ssh_client.SSHClient(self.config.get('ca.ssh_host'),
                                             self.config.get('ca.ssh_user'),
                                             self.config.get('ca.ssh_pass'))

            target_ca_cert_path = self.get_download_path("ca.pem")
            target_ocsp_cert_path = self.get_download_path("ocsp.pem")

            # Get CA certificates using SSH
            self.log('2.1.3.1-1-del Getting CA certificates')
            get_ca_certificate(sshclient, 'ca.cert.pem', target_ca_cert_path)
            get_ca_certificate(sshclient, 'ocsp.cert.pem', target_ocsp_cert_path)
            sshclient.close()

            # Go to Central Server UI main page
            self.driver.get(self.config.get('cs.host'))

            self.wait_until_visible(type=By.CSS_SELECTOR, element=sidebar_constants.CERTIFICATION_SERVICES_CSS).click()
            self.wait_jquery()
            time.sleep(3)

            table = self.wait_until_visible(type=By.ID, element=certification_services.CERTIFICATION_SERVICES_TABLE_ID)
            rows = table.find_element_by_tag_name('tbody').find_elements_by_tag_name('tr')

            # If CA server is not listed, re-add it
            if self.config.get('ca.ssh_host') not in map(lambda x: x.text, rows):
                self.log('2.1.3.1-1-del CA not found, re-adding')
                self.wait_until_visible(type=By.ID, element=certification_services.ADD_BTN_ID).click()
                import_cert_btn = self.wait_until_visible(type=By.ID,
                                                          element=certification_services.IMPORT_CA_CERT_BTN_ID)

                # Upload CA certificate and submit the form
                xroad.fill_upload_input(self, import_cert_btn, target_ca_cert_path)

                self.wait_until_visible(type=By.ID, element=certification_services.SUBMIT_CA_CERT_BTN_ID).click()

                # Set CA additional information
                profile_info_area = self.wait_until_visible(type=By.CSS_SELECTOR,
                                                            element=certification_services.CETIFICATE_PROFILE_INFO_AREA_CSS)

                self.input(profile_info_area,
                           'ee.ria.xroad.common.certificateprofile.impl.EjbcaCertificateProfileInfoProvider')

                # Save the settings
                self.wait_until_visible(type=By.ID, element=certification_services.SUBMIT_CA_SETTINGS_BTN_ID).click()
                self.wait_jquery()

                # Open OCSP tab
                self.wait_until_visible(type=By.XPATH, element=certification_services.OCSP_RESPONSE_TAB).click()

                self.log('2.1.3.1-1-del Add OCSP responder')
                self.wait_until_visible(type=By.ID, element=certification_services.OCSP_RESONDER_ADD_BTN_ID).click()

                # Import OCSP certificate
                import_cert_btn = self.wait_until_visible(type=By.ID,
                                                          element=certification_services.IMPORT_OCSP_CERT_BTN_ID)

                xroad.fill_upload_input(self, import_cert_btn, target_ocsp_cert_path)

                url_area = self.wait_until_visible(type=By.ID, element=certification_services.OCS_RESPONSE_URL_AREA_ID)

                self.input(url_area, self.config.get('ca.ocs_host'))

                # Save OCSP information
                self.wait_until_visible(type=By.ID,
                                        element=certification_services.SUBMIT_OCSP_CERT_AND_URL_BTN_ID).click()

            # Reload CS main page
            self.driver.get(self.url)

            # Open keys and certificates
            self.wait_until_visible(type=By.CSS_SELECTOR, element=sidebar_constants.KEYSANDCERTIFICATES_BTN_CSS).click()

            # Remove the testing certificate
            remove_certificate(self, client)

            self.log('Wait 120 seconds for changes')
            time.sleep(120)
            if error:
                # If, at some point, we got an error, fail the test now
                assert False, '2.1.3.1-1 test failed'
コード例 #9
0
def edit_service(self, service_url, service_timeout=None, verify_tls=None):
    '''
    Tries to enter WSDL url to "Edit WSDL Parameters" dialog URL input field and press "OK"
    :param self:
    :param url: str - URL that contains the WSDL
    :param clear_field: Boolean - clear the field before entering anything
    :return:
    '''

    self.log('Setting new service URL with timeout {1}: {0}'.format(
        service_timeout, service_url))

    # Find the "Edit Service Parameters" dialog. Because this function can be called from a state where the dialog is open and
    # a state where it is not, we'll first check if the dialog is open. If it is not, we'll click the "Edit"
    # button to open it.
    wsdl_dialog = self.by_xpath(popups.EDIT_SERVICE_POPUP_XPATH)

    # Open the dialog if it is not already open
    if not wsdl_dialog.is_displayed():
        # Find "Edit" button and click it.
        edit_wsdl_button = self.by_id(
            popups.CLIENT_DETAILS_POPUP_EDIT_WSDL_BTN_ID)
        edit_wsdl_button.click()

        # Find the dialog and wait until it is visible.
        self.wait_until_visible(wsdl_dialog)

    # Now an "Edit Service Parameters" dialog with a URL prompt should be open. Let's try to set the service URL.

    # Find the URL input element
    service_url_input = self.by_id(popups.EDIT_SERVICE_POPUP_URL_ID)
    service_timeout_input = self.by_id(popups.EDIT_SERVICE_POPUP_TIMEOUT_ID)

    # Enter the service URL.
    self.input(service_url_input, service_url)

    # Set service timeout if specified
    if service_timeout is not None:
        # service_timeout_input.clear()
        # service_timeout_input.send_keys(service_timeout)
        self.input(service_timeout_input, service_timeout)

    # Set "Verify TLS" if specified
    if verify_tls is not None:
        service_tls_checkbox = self.wait_until_visible(
            popups.EDIT_SERVICE_POPUP_TLS_ENABLED_XPATH, By.XPATH)
        checked = service_tls_checkbox.get_attribute('checked')

        if (checked != '' and not verify_tls) or (checked is None
                                                  and verify_tls):
            service_tls_checkbox.click()

    # Find the "OK" button in "Edit WSDL Parameters" dialog
    wsdl_dialog_ok_button = self.by_xpath(
        popups.EDIT_SERVICE_POPUP_OK_BTN_XPATH)
    wsdl_dialog_ok_button.click()

    # Clicking the button starts an ajax query. Wait until request is complete.
    self.wait_jquery()

    warning_message = messages.get_warning_message(self)  # Warning message
    error_message = messages.get_error_message(
        self)  # Error message (anywhere)

    return warning_message, error_message
コード例 #10
0
    def edit_central_service():
        # TEST PLAN 2.2.8-5 update central service and set a new provider
        self.log('2.2.8-5 update central service')

        self.log('Starting mock service')
        self.mock_service = self.start_mock_service()

        # Find "Central Services" menu item, click on it.
        central_services_menu = self.by_css(sidebar.CENTRAL_SERVICES_CSS)
        central_services_menu.click()

        # Wait until central services table appears (page has been loaded and table initialized)
        self.wait_until_visible(central_services.SERVICES_TABLE_ID, type=By.ID)

        # Wait until jquery has finished loading the list
        self.wait_jquery()

        # Find the service we're looking for. If nothing is found, cancel everything with assertion - no need to waste time.
        service_row = get_central_service_row(self, central_service_name)
        self.is_not_none(service_row,
                         msg='2.2.8-5 Central service not found: {0}'.format(
                             central_service_name))
        #
        # Click the row to select it
        service_row.click()

        # Find and click the "Delete" button to delete the service
        edit_button = self.by_id(central_services.SERVICE_EDIT_BUTTON_ID)
        edit_button.click()

        # Wait until ajax query finishes.
        self.wait_jquery()

        # Find and click the "Clear" button (after the Edit dialog opens) to clear fields.
        clear_button = self.wait_until_visible(
            central_services.SERVICE_EDIT_DIALOG_CLEAR_BUTTON_ID, type=By.ID)
        clear_button.click()

        # Set the new provider data
        set_central_service_provider_fields(self, provider=provider)

        add_service_ok_button = self.by_id(
            popups.CENTRAL_SERVICE_POPUP_OK_BUTTON_ID)
        add_service_ok_button.click()

        # Wait until the service is added.
        self.wait_jquery()

        # Test that we didn't get an error. If we did, no need to continue.
        error_message = messages.get_error_message(
            self)  # Error message (anywhere)
        self.is_none(
            error_message,
            msg=
            '2.2.8-5 Got error message when trying to update central service: {0}'
            .format(error_message))

        # TEST PLAN 2.2.8-6 test query from TS1 client CLIENT1:sub to service bodyMassIndex. Query should succeed.
        self.log(
            '2.2.8-6 test query {0} to bodyMassIndex. Query should succeed, served by {1}:{2}.'
            .format(query_filename, provider['code'], provider['subsystem']))

        verify_service = {
            'class': provider['class'],
            'code': provider['code'],
            'subsystem': provider['subsystem']
        }

        testclient_central.verify_service_data = verify_service

        case.is_true(
            testclient_central.check_success(),
            msg='2.2.8-6 Test query after updating central service failed')
コード例 #11
0
    def add_central_service():
        # TEST PLAN 2.2.8 add central service
        self.log('*** 2.2.8 / XT-472')

        self.log('Starting mock service')
        self.start_mock_service()

        # Find "Central Services" menu item, click on it.
        central_services_menu = self.by_css(sidebar.CENTRAL_SERVICES_CSS)
        central_services_menu.click()

        # TEST PLAN 2.2.8-1 define central service "random": code=xroadGetRandom; version=v1;
        #                                                   provider=SUBSYSTEM:KS1:COM:CLIENT1:testservice
        self.log('2.2.8-1 define central service')

        # Wait until central services table appears (page has been loaded and table initialized)
        self.wait_until_visible(central_services.SERVICES_TABLE_ID, type=By.ID)

        # Wait until jquery has finished loading the list
        self.wait_jquery()

        # Click the "Add" button in the top right corner.
        add_button = self.by_id(central_services.SERVICE_ADD_BUTTON_ID)
        add_button.click()

        # Wait until popup opens
        self.wait_until_visible(element=popups.CENTRAL_SERVICE_POPUP,
                                type=By.XPATH)

        # Find "service code" input field, clear it and enter the service name there
        central_service_code_input = self.by_id(
            popups.CENTRAL_SERVICE_POPUP_CENTRAL_SERVICE_CODE_ID)
        central_service_code_input.clear()
        # central_service_code_input.send_keys(central_service_name)
        self.input(central_service_code_input, central_service_name)

        # Set other fields
        set_central_service_provider_fields(self, provider=provider)

        add_service_ok_button = self.by_id(
            popups.CENTRAL_SERVICE_POPUP_OK_BUTTON_ID)
        add_service_ok_button.click()

        # Wait until the service is added.
        self.wait_jquery()

        # Test that we didn't get an error. If we did, no need to continue.
        error_message = messages.get_error_message(
            self)  # Error message (anywhere)
        self.is_none(
            error_message,
            msg=
            '2.2.8-1 Got error message when trying to add central service: {0}'
            .format(error_message))

        # TEST PLAN 2.2.8-2 test query from TS1 client CLIENT1:sub to service bodyMassIndex. Query should succeed.
        self.log(
            '2.2.8-2 test query {0} to bodyMassIndex. Query should succeed.'.
            format(body_filename))

        self.is_true(testclient.check_success(),
                     msg='2.2.8-2 Test query failed')

        # TEST PLAN 2.2.8-3 test query from TS1 client CLIENT1:sub to CENTRAL service. Query should succeed.
        self.log(
            '2.2.8-3 test query {0} to central service {1}. Query should succeed.'
            .format(body_central_filename, central_service_name))

        self.is_true(testclient_central.check_success(),
                     msg='2.2.8-3 Test query to central service failed')