def make_x509_auth_provider_module():
    mock_x509 = X509(fake_x509_cert_file, fake_x509_cert_key_file,
                     fake_pass_phrase)
    return X509AuthenticationProvider(x509=mock_x509,
                                      hostname=fake_hostname,
                                      device_id=fake_device_id,
                                      module_id=fake_module_id)
def create_x509_security_client():
    mock_x509 = X509(fake_x509_cert_file, fake_x509_cert_key_file, fake_pass_phrase)
    return X509SecurityClient(
        provisioning_host=fake_provisioning_host,
        registration_id=fake_registration_id,
        id_scope=fake_id_scope,
        x509=mock_x509,
    )
 def op(self, mocker):
     x509 = X509(cert_file="fake_cert.txt",
                 key_file="fake_key.txt",
                 pass_phrase="alohomora")
     security_client = X509SecurityClient(
         provisioning_host="hogwarts.com",
         registration_id="registered_remembrall",
         id_scope="weasley_wizard_wheezes",
         x509=x509,
     )
     security_client.get_x509_certificate = mocker.MagicMock()
     return pipeline_ops_provisioning.SetX509SecurityClientOperation(
         security_client=security_client, callback=mocker.MagicMock())
    def test_configures_tls_context_with_client_provided_certificate_chain(self, mocker):
        fake_client_cert = X509("fantastic_beasts", "where_to_find_them", "alohomora")
        mock_ssl_context_constructor = mocker.patch.object(ssl, "SSLContext")
        mock_ssl_context = mock_ssl_context_constructor.return_value

        HTTPTransport(hostname=fake_hostname, x509_cert=fake_client_cert)

        assert mock_ssl_context.load_default_certs.call_count == 1
        assert mock_ssl_context.load_cert_chain.call_count == 1
        assert mock_ssl_context.load_cert_chain.call_args == mocker.call(
            fake_client_cert.certificate_file,
            fake_client_cert.key_file,
            fake_client_cert.pass_phrase,
        )
def x509():
    return X509(fake_x509_cert_value, fake_x509_cert_key, fake_pass_phrase)
def fake_x509():
    return X509(fake_x509_cert_file_value, fake_x509_cert_key_file, fake_pass_phrase)