Esempio n. 1
0
def test_security_server_address_from_url():
    security_server_config = {'url': 'https://somehost:64000/api/v1'}
    assert 'somehost' == BaseController.security_server_address(
        security_server_config)
    security_server_config['url'] = 'http://otherhost/api/v1'
    assert 'otherhost' == BaseController.security_server_address(
        security_server_config)
    security_server_config['url'] = 'http://192.168.1.33:4000/api/v1'
    assert '192.168.1.33' == BaseController.security_server_address(
        security_server_config)
    def remote_register_certificate(ss_api_config, security_server):
        registrable_cert = CertController.find_actionable_auth_certificate(
            ss_api_config, security_server, 'REGISTER')
        if not registrable_cert:
            return None

        token_cert_api = TokenCertificatesApi(ApiClient(ss_api_config))
        ss_address = SecurityServerAddress(
            BaseController.security_server_address(security_server))
        try:
            response = token_cert_api.register_certificate(
                registrable_cert.certificate_details.hash, body=ss_address)
            BaseController.log_info("Registered certificate " +
                                    registrable_cert.certificate_details.hash +
                                    " for address '" + str(ss_address) + "'")
            return response
        except ApiException as err:
            BaseController.log_api_error(
                'TokenCertificatesApi->import_certificate', err)