OpFlex Framework 1.7.0
|
An opflex server we can use for mocking interactions with a real Opflex server. More...
#include <opflex/test/MockOpflexServer.h>
Public Types | |
typedef std::pair< uint8_t, std::string > | peer_t |
a pair of a role bitmask and connectivity string | |
typedef std::vector< peer_t > | peer_vec_t |
A vector of peers. | |
Public Member Functions | |
MockOpflexServer (int port, uint8_t roles, peer_vec_t peers, const modb::ModelMetadata &md) | |
Construct a new mock opflex server. | |
~MockOpflexServer () | |
Destroy the opflex server. | |
void | start () |
Start the server. | |
void | stop () |
Stop the server. | |
void | readPolicy (const std::string &file) |
Read policy into the server from the specified file. | |
void | enableSSL (const std::string &caStorePath, const std::string &serverKeyPath, const std::string &serverKeyPass, bool verifyPeers=true) |
Enable SSL for connections to opflex peers. | |
const peer_vec_t & | getPeers () const |
Get the peers that this server was configured with. | |
int | getPort () const |
Get the port number that this server was configured with. | |
uint8_t | getRoles () const |
Get the roles that this server was configured with. | |
An opflex server we can use for mocking interactions with a real Opflex server.
opflex::test::MockOpflexServer::MockOpflexServer | ( | int | port, |
uint8_t | roles, | ||
peer_vec_t | peers, | ||
const modb::ModelMetadata & | md ) |
Construct a new mock opflex server.
port | listen port for the server |
roles | the opflex roles for this server |
peers | a list of peers to return in the opflex handshake |
md | the model metadata for the server |
void opflex::test::MockOpflexServer::enableSSL | ( | const std::string & | caStorePath, |
const std::string & | serverKeyPath, | ||
const std::string & | serverKeyPass, | ||
bool | verifyPeers = true ) |
Enable SSL for connections to opflex peers.
Call before start()
caStorePath | the filesystem path to a directory containing CA certificates, or to a file containing a specific CA certificate. |
serverKeyPath | the path to the server private key |
serverKeyPass | the passphrase for the server private key |
verifyPeers | set to true to verify that peer certificates properly chain to a trusted root |
const peer_vec_t & opflex::test::MockOpflexServer::getPeers | ( | ) | const |
Get the peers that this server was configured with.
int opflex::test::MockOpflexServer::getPort | ( | ) | const |
Get the port number that this server was configured with.
uint8_t opflex::test::MockOpflexServer::getRoles | ( | ) | const |
Get the roles that this server was configured with.
void opflex::test::MockOpflexServer::readPolicy | ( | const std::string & | file | ) |
Read policy into the server from the specified file.
Note that this will not automatically cause updates to be sent to connected clients.
file | the filename to read in |