Skip to main content

MockPeer

Struct MockPeer 

Source
pub struct MockPeer(/* private fields */);
Available on crate features 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

Source

pub fn new(base: Url, party: PartyRef, role: Role) -> Self

A peer filling role, publishing its endpoints under base.

Source

pub fn cpo(base: Url) -> Self

A CPO at test_cpo.

Source

pub fn msp(base: Url) -> Self

An eMSP at test_msp.

Source

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.

Source

pub fn party(&self) -> &PartyRef

The party this peer speaks as.

Source

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.

Source

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

Source

pub fn credentials(&self) -> Credentials

This peer’s own credentials object, as the credentials endpoint returns it.

Trait Implementations§

Source§

impl CdrsReceiver for MockPeer

Source§

async fn cdr(&self, cdr_id: String, _c: RequestContext) -> Handled<Cdr>

Available on crate feature server only.
GET {cdrs}/{cdr_id} — a CDR previously POSTed here.
Source§

async fn post_cdr(&self, cdr: Cdr, _c: RequestContext) -> Handled<Url>

Available on crate feature server only.
POST {cdrs} — stores a CDR and returns the URL it can be fetched from.
Source§

impl CdrsSender for MockPeer

Source§

async fn list(&self, query: PageQuery, _c: RequestContext) -> Handled<Page<Cdr>>

Available on crate feature server only.
GET {cdrs} — one page of CDRs.
Source§

impl Clone for MockPeer

Source§

fn clone(&self) -> MockPeer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CredentialsHandler for MockPeer

Source§

async fn get(&self, _c: RequestContext) -> Handled<Credentials>

Available on crate feature server only.
GET {credentials} — this party’s own credentials object.
Source§

async fn post( &self, _credentials: Credentials, _c: RequestContext, ) -> Handled<Credentials>

Available on crate feature server only.
POST {credentials} — register. Read more
Source§

async fn put( &self, _credentials: Credentials, _c: RequestContext, ) -> Handled<Credentials>

Available on crate feature server only.
PUT {credentials} — update, rotate the token, or switch version. Read more
Source§

async fn delete(&self, _c: RequestContext) -> Handled<()>

Available on crate feature server only.
DELETE {credentials} — unregister. Read more
Source§

impl Debug for MockPeer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for MockPeer

Source§

type Target = MockPeerStores

The resulting type after dereferencing.
Source§

fn deref(&self) -> &MockPeerStores

Dereferences the value.
Source§

impl LocationsReceiver for MockPeer

Source§

async fn location( &self, _o: PartyRef, location_id: String, _c: RequestContext, ) -> Handled<Location>

Available on crate feature 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>

Available on crate feature server only.
PUT {locations}/{cc}/{party}/{location_id}. Read more
Source§

async fn put_evse( &self, _o: PartyRef, location_id: String, evse: Evse, _c: RequestContext, ) -> Handled<Created>

Available on crate feature 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>

Available on crate feature server only.
PUT {locations}/{cc}/{party}/{location_id}/{evse_uid}/{connector_id}.
Source§

async fn patch( &self, _o: PartyRef, location_id: String, evse_uid: Option<String>, connector_id: Option<String>, patch: Patch<Value>, _c: RequestContext, ) -> Handled<()>

Available on crate feature server only.
PATCH on any of the three levels. Read more
Source§

impl LocationsSender for MockPeer

Source§

async fn list( &self, query: PageQuery, _c: RequestContext, ) -> Handled<Page<Location>>

Available on crate feature server only.
GET {locations} — one page of Locations. Read more
Source§

async fn location( &self, location_id: String, _c: RequestContext, ) -> Handled<Location>

Available on crate feature server only.
GET {locations}/{location_id}.
Source§

async fn evse( &self, location_id: String, evse_uid: String, _c: RequestContext, ) -> Handled<Evse>

Available on crate feature server only.
GET {locations}/{location_id}/{evse_uid}.
Source§

async fn connector( &self, location_id: String, evse_uid: String, connector_id: String, _c: RequestContext, ) -> Handled<Connector>

Available on crate feature server only.
GET {locations}/{location_id}/{evse_uid}/{connector_id}.
Source§

impl SessionsReceiver for MockPeer

Source§

async fn session( &self, _o: PartyRef, session_id: String, _c: RequestContext, ) -> Handled<Session>

Available on crate feature server only.
GET {sessions}/{cc}/{party}/{session_id}.
Source§

async fn put_session( &self, _o: PartyRef, session: Session, _c: RequestContext, ) -> Handled<Created>

Available on crate feature 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<()>

Available on crate feature server only.
PATCH {sessions}/{cc}/{party}/{session_id}.
Source§

impl SessionsSender for MockPeer

Source§

async fn list( &self, query: PageQuery, _c: RequestContext, ) -> Handled<Page<Session>>

Available on crate feature server only.
GET {sessions} — one page of Sessions.
Source§

async fn set_charging_preferences( &self, session_id: String, _preferences: ChargingPreferences, _c: RequestContext, ) -> Handled<ChargingPreferencesResponse>

Available on crate feature server only.
PUT {sessions}/{session_id}/charging_preferences. Read more
Source§

impl TariffsReceiver for MockPeer

Source§

async fn tariff( &self, _o: PartyRef, tariff_id: String, _c: RequestContext, ) -> Handled<Tariff>

Available on crate feature server only.
GET {tariffs}/{cc}/{party}/{tariff_id}.
Source§

async fn put_tariff( &self, _o: PartyRef, tariff: Tariff, _c: RequestContext, ) -> Handled<Created>

Available on crate feature server only.
PUT {tariffs}/{cc}/{party}/{tariff_id}.
Source§

async fn delete_tariff( &self, _o: PartyRef, tariff_id: String, _c: RequestContext, ) -> Handled<()>

Available on crate feature server only.
DELETE {tariffs}/{cc}/{party}/{tariff_id}.
Source§

impl TariffsSender for MockPeer

Source§

async fn list( &self, query: PageQuery, _c: RequestContext, ) -> Handled<Page<Tariff>>

Available on crate feature server only.
GET {tariffs} — one page of Tariffs.
Source§

impl TokensReceiver for MockPeer

Source§

async fn token( &self, _o: PartyRef, token_uid: String, _token_type: Option<TokenType>, _c: RequestContext, ) -> Handled<Token>

Available on crate feature server only.
GET {tokens}/{cc}/{party}/{token_uid}[?type=].
Source§

async fn put_token( &self, _o: PartyRef, token: Token, _c: RequestContext, ) -> Handled<Created>

Available on crate feature server only.
PUT {tokens}/{cc}/{party}/{token_uid}[?type=].
Source§

async fn patch_token( &self, _o: PartyRef, token_uid: String, _token_type: Option<TokenType>, patch: Patch<Token>, _c: RequestContext, ) -> Handled<()>

Available on crate feature server only.
PATCH {tokens}/{cc}/{party}/{token_uid}[?type=].
Source§

impl TokensSender for MockPeer

Source§

async fn list( &self, query: PageQuery, _c: RequestContext, ) -> Handled<Page<Token>>

Available on crate feature server only.
GET {tokens} — one page of Tokens.
Source§

async fn authorize( &self, token_uid: String, _token_type: Option<TokenType>, location: Option<LocationReferences>, _c: RequestContext, ) -> Handled<AuthorizationInfo>

Available on crate feature server only.
POST {tokens}/{token_uid}/authorize[?type=] — a real-time authorization. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more