def testServerKeyRotation(self): self._MakeClientRecord() # Now the server should know about the client. decoded_messages = self.ClientServerCommunicate() for i in range(len(decoded_messages)): self.assertEqual(decoded_messages[i].auth_state, rdf_flows.GrrMessage.AuthorizationState.AUTHENTICATED) # Suppress the output. with utils.Stubber(maintenance_utils, "EPrint", lambda msg: None): maintenance_utils.RotateServerKey() server_certificate = config.CONFIG["Frontend.certificate"] server_private_key = config.CONFIG["PrivateKeys.server_key"] self.assertNotEqual(server_certificate, self.server_certificate) self.assertNotEqual(server_private_key, self.server_private_key) self.server_communicator = front_end.ServerCommunicator( certificate=server_certificate, private_key=server_private_key, token=self.token) # Clients can't connect at this point since they use the outdated # session key. with self.assertRaises(communicator.DecryptionError): self.ClientServerCommunicate() # After the client reloads the server cert, this should start # working again. self.client_communicator.LoadServerCertificate( server_certificate=server_certificate, ca_certificate=config.CONFIG["CA.certificate"]) self.assertEqual(len(list(self.ClientServerCommunicate())), 10)
def setUp(self): """Set up communicator tests.""" super(ClientCommsTest, self).setUp() # These tests change the config so we preserve state. self.config_stubber = test_lib.PreserveConfig() self.config_stubber.Start() self.client_private_key = config.CONFIG["Client.private_key"] self.server_serial_number = 0 self.server_certificate = config.CONFIG["Frontend.certificate"] self.server_private_key = config.CONFIG["PrivateKeys.server_key"] self.client_communicator = comms.ClientCommunicator( private_key=self.client_private_key) self.client_communicator.LoadServerCertificate( server_certificate=self.server_certificate, ca_certificate=config.CONFIG["CA.certificate"]) self.server_communicator = front_end.ServerCommunicator( certificate=self.server_certificate, private_key=self.server_private_key, token=self.token) self.last_urlmock_error = None
def CreateNewServerCommunicator(self): self.server_communicator = front_end.ServerCommunicator( certificate=self.server_certificate, private_key=self.server_private_key, token=self.token) self.server_communicator.client_cache.Put(self.client_cn, self.client)
def _SetupCommunicator(self): self.server_communicator = front_end.ServerCommunicator( certificate=self.server_certificate, private_key=self.server_private_key, token=self.token)