OpFlex Framework 1.7.0
opflex::test::MockOpflexServer Class Reference

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_tpeer_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_tgetPeers () 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.
 

Detailed Description

An opflex server we can use for mocking interactions with a real Opflex server.

Constructor & Destructor Documentation

◆ MockOpflexServer()

opflex::test::MockOpflexServer::MockOpflexServer ( int port,
uint8_t roles,
peer_vec_t peers,
const modb::ModelMetadata & md )

Construct a new mock opflex server.

Parameters
portlisten port for the server
rolesthe opflex roles for this server
peersa list of peers to return in the opflex handshake
mdthe model metadata for the server

Member Function Documentation

◆ enableSSL()

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()

Parameters
caStorePaththe filesystem path to a directory containing CA certificates, or to a file containing a specific CA certificate.
serverKeyPaththe path to the server private key
serverKeyPassthe passphrase for the server private key
verifyPeersset to true to verify that peer certificates properly chain to a trusted root

◆ getPeers()

const peer_vec_t & opflex::test::MockOpflexServer::getPeers ( ) const

Get the peers that this server was configured with.

Returns
a vector of peer pairs

◆ getPort()

int opflex::test::MockOpflexServer::getPort ( ) const

Get the port number that this server was configured with.

Returns
the port number

◆ getRoles()

uint8_t opflex::test::MockOpflexServer::getRoles ( ) const

Get the roles that this server was configured with.

Returns
a bitmask containing the server roles

◆ readPolicy()

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.

Parameters
filethe filename to read in

The documentation for this class was generated from the following file: