pub struct MockPeer(/* private fields */);server and testkit only.Expand description
A conformant OCPI party, held in memory.
Cheap to clone: the stores are shared, so a handle handed to the router and a handle kept for the test see the same objects.
Implementations§
Source§impl MockPeer
impl MockPeer
Sourcepub fn new(base: Url, party: PartyRef, role: Role) -> Self
pub fn new(base: Url, party: PartyRef, role: Role) -> Self
A peer filling role, publishing its endpoints under base.
Sourcepub fn seeded(self) -> Self
pub fn seeded(self) -> Self
Fills every store with one conformant object, so a partner’s first pull is not empty.
§Panics
Panics if the crate’s own sample objects are not constructible, which would be a bug here.
Sourcepub fn token_store(&self) -> Arc<InMemoryTokenStore> ⓘ
pub fn token_store(&self) -> Arc<InMemoryTokenStore> ⓘ
A token store that accepts test_token("c") as this peer’s partner.
The partner is given the opposite role’s party, so the router’s ownership check behaves the way it would in a real deployment: a partner may write under its own party and no other.
Sourcepub fn mount(&self, router: OcpiRouter) -> OcpiRouter
pub fn mount(&self, router: OcpiRouter) -> OcpiRouter
Mounts every module this peer serves onto router.
Both interfaces of every object module, so one process can stand in for either side of a
roaming relationship. That is only mountable because the router publishes the Receiver
interfaces one segment deeper by default; see
ServerConfig::receiver_path_prefix.
Source§impl MockPeer
impl MockPeer
Sourcepub fn credentials(&self) -> Credentials
pub fn credentials(&self) -> Credentials
This peer’s own credentials object, as the credentials endpoint returns it.
Trait Implementations§
Source§impl CdrsReceiver for MockPeer
impl CdrsReceiver for MockPeer
Source§impl CdrsSender for MockPeer
impl CdrsSender for MockPeer
Source§impl CredentialsHandler for MockPeer
impl CredentialsHandler for MockPeer
Source§async fn get(&self, _c: RequestContext) -> Handled<Credentials>
async fn get(&self, _c: RequestContext) -> Handled<Credentials>
server only.GET {credentials} — this party’s own credentials object.Source§async fn post(
&self,
_credentials: Credentials,
_c: RequestContext,
) -> Handled<Credentials>
async fn post( &self, _credentials: Credentials, _c: RequestContext, ) -> Handled<Credentials>
server only.POST {credentials} — register. Read moreSource§async fn put(
&self,
_credentials: Credentials,
_c: RequestContext,
) -> Handled<Credentials>
async fn put( &self, _credentials: Credentials, _c: RequestContext, ) -> Handled<Credentials>
server only.PUT {credentials} — update, rotate the token, or switch version. Read moreSource§impl Deref for MockPeer
impl Deref for MockPeer
Source§type Target = MockPeerStores
type Target = MockPeerStores
Source§fn deref(&self) -> &MockPeerStores
fn deref(&self) -> &MockPeerStores
Source§impl LocationsReceiver for MockPeer
impl LocationsReceiver for MockPeer
Source§async fn location(
&self,
_o: PartyRef,
location_id: String,
_c: RequestContext,
) -> Handled<Location>
async fn location( &self, _o: PartyRef, location_id: String, _c: RequestContext, ) -> Handled<Location>
server only.GET {locations}/{cc}/{party}/{location_id} — what this party has stored.Source§async fn put_location(
&self,
_o: PartyRef,
location: Location,
_c: RequestContext,
) -> Handled<Created>
async fn put_location( &self, _o: PartyRef, location: Location, _c: RequestContext, ) -> Handled<Created>
server only.PUT {locations}/{cc}/{party}/{location_id}. Read moreSource§async fn put_evse(
&self,
_o: PartyRef,
location_id: String,
evse: Evse,
_c: RequestContext,
) -> Handled<Created>
async fn put_evse( &self, _o: PartyRef, location_id: String, evse: Evse, _c: RequestContext, ) -> Handled<Created>
server only.PUT {locations}/{cc}/{party}/{location_id}/{evse_uid}.Source§async fn put_connector(
&self,
_o: PartyRef,
location_id: String,
evse_uid: String,
connector: Connector,
_c: RequestContext,
) -> Handled<Created>
async fn put_connector( &self, _o: PartyRef, location_id: String, evse_uid: String, connector: Connector, _c: RequestContext, ) -> Handled<Created>
server only.PUT {locations}/{cc}/{party}/{location_id}/{evse_uid}/{connector_id}.Source§impl LocationsSender for MockPeer
impl LocationsSender for MockPeer
Source§async fn list(
&self,
query: PageQuery,
_c: RequestContext,
) -> Handled<Page<Location>>
async fn list( &self, query: PageQuery, _c: RequestContext, ) -> Handled<Page<Location>>
server only.GET {locations} — one page of Locations. Read moreSource§async fn location(
&self,
location_id: String,
_c: RequestContext,
) -> Handled<Location>
async fn location( &self, location_id: String, _c: RequestContext, ) -> Handled<Location>
server only.GET {locations}/{location_id}.Source§impl SessionsReceiver for MockPeer
impl SessionsReceiver for MockPeer
Source§async fn session(
&self,
_o: PartyRef,
session_id: String,
_c: RequestContext,
) -> Handled<Session>
async fn session( &self, _o: PartyRef, session_id: String, _c: RequestContext, ) -> Handled<Session>
server only.GET {sessions}/{cc}/{party}/{session_id}.Source§async fn put_session(
&self,
_o: PartyRef,
session: Session,
_c: RequestContext,
) -> Handled<Created>
async fn put_session( &self, _o: PartyRef, session: Session, _c: RequestContext, ) -> Handled<Created>
server only.PUT {sessions}/{cc}/{party}/{session_id}.Source§async fn patch_session(
&self,
_o: PartyRef,
session_id: String,
patch: Patch<Session>,
_c: RequestContext,
) -> Handled<()>
async fn patch_session( &self, _o: PartyRef, session_id: String, patch: Patch<Session>, _c: RequestContext, ) -> Handled<()>
server only.PATCH {sessions}/{cc}/{party}/{session_id}.Source§impl SessionsSender for MockPeer
impl SessionsSender for MockPeer
Source§async fn list(
&self,
query: PageQuery,
_c: RequestContext,
) -> Handled<Page<Session>>
async fn list( &self, query: PageQuery, _c: RequestContext, ) -> Handled<Page<Session>>
server only.GET {sessions} — one page of Sessions.Source§async fn set_charging_preferences(
&self,
session_id: String,
_preferences: ChargingPreferences,
_c: RequestContext,
) -> Handled<ChargingPreferencesResponse>
async fn set_charging_preferences( &self, session_id: String, _preferences: ChargingPreferences, _c: RequestContext, ) -> Handled<ChargingPreferencesResponse>
server only.PUT {sessions}/{session_id}/charging_preferences. Read moreSource§impl TariffsReceiver for MockPeer
impl TariffsReceiver for MockPeer
Source§async fn tariff(
&self,
_o: PartyRef,
tariff_id: String,
_c: RequestContext,
) -> Handled<Tariff>
async fn tariff( &self, _o: PartyRef, tariff_id: String, _c: RequestContext, ) -> Handled<Tariff>
server only.GET {tariffs}/{cc}/{party}/{tariff_id}.Source§async fn put_tariff(
&self,
_o: PartyRef,
tariff: Tariff,
_c: RequestContext,
) -> Handled<Created>
async fn put_tariff( &self, _o: PartyRef, tariff: Tariff, _c: RequestContext, ) -> Handled<Created>
server only.PUT {tariffs}/{cc}/{party}/{tariff_id}.Source§async fn delete_tariff(
&self,
_o: PartyRef,
tariff_id: String,
_c: RequestContext,
) -> Handled<()>
async fn delete_tariff( &self, _o: PartyRef, tariff_id: String, _c: RequestContext, ) -> Handled<()>
server only.DELETE {tariffs}/{cc}/{party}/{tariff_id}.Source§impl TariffsSender for MockPeer
impl TariffsSender for MockPeer
Source§impl TokensReceiver for MockPeer
impl TokensReceiver for MockPeer
Source§async fn token(
&self,
_o: PartyRef,
token_uid: String,
_token_type: Option<TokenType>,
_c: RequestContext,
) -> Handled<Token>
async fn token( &self, _o: PartyRef, token_uid: String, _token_type: Option<TokenType>, _c: RequestContext, ) -> Handled<Token>
server only.GET {tokens}/{cc}/{party}/{token_uid}[?type=].