def testEnrollingCommunicator(self):
    self.client_communicator = comms.ClientCommunicator(
        certificate="")

    self.client_communicator.LoadServerCertificate(
        self.server_certificate, config_lib.CONFIG["CA.certificate"])

    req = X509.load_request_string(self.client_communicator.GetCSR())

    # Verify that the CN is of the correct form
    public_key = req.get_pubkey().get_rsa().pub()[1]
    cn = rdf_client.ClientURN.FromPublicKey(public_key)

    self.assertEqual(cn, req.get_subject().CN)
Test that the ClientCommunicator generates good keys.
dataset/ETHPy150Open google/grr/grr/lib/communicator_test.py/ClientCommsTest.testEnrollingCommunicator