pub struct Jwt {
pub claims: HashMap<String, String>,
pub issuer: Option<String>,
pub audience: Option<String>,
pub algorithm: Option<String>,
pub header: Option<String>,
pub scheme: Option<String>,
}Expand description
JWT request matcher — matches a JSON Web Token carried on the request.
Serialised under the request’s "jwt" key. Each entry in claims
is a claim name mapped to an exact-or-regex string; a leading ! negates the
match. The optional issuer, audience,
algorithm, header and
scheme fields are omitted from the wire form when unset.
§Example
use mockserver_client::Jwt;
let jwt = Jwt::new()
.claim("sub", "user-123")
.claim("role", "!admin")
.claim("email", "^.+@example.com$")
.issuer("https://issuer.example.com")
.audience("my-api")
.algorithm("RS256")
.header("authorization")
.scheme("Bearer");Fields§
§claims: HashMap<String, String>Claim name → exact-or-regex value (leading ! negates).
issuer: Option<String>§audience: Option<String>§algorithm: Option<String>§header: Option<String>§scheme: Option<String>Implementations§
Source§impl Jwt
impl Jwt
Sourcepub fn claim(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn claim(self, name: impl Into<String>, value: impl Into<String>) -> Self
Add a claim constraint. The value is an exact-or-regex string; a leading
! negates the match.
Sourcepub fn issuer(self, issuer: impl Into<String>) -> Self
pub fn issuer(self, issuer: impl Into<String>) -> Self
Require the iss (issuer) claim to equal the given value.
Sourcepub fn audience(self, audience: impl Into<String>) -> Self
pub fn audience(self, audience: impl Into<String>) -> Self
Require the aud (audience) claim to equal the given value.
Sourcepub fn algorithm(self, algorithm: impl Into<String>) -> Self
pub fn algorithm(self, algorithm: impl Into<String>) -> Self
Require the token to be signed with the given algorithm (e.g. “RS256”).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Jwt
impl<'de> Deserialize<'de> for Jwt
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Jwt
Auto Trait Implementations§
impl Freeze for Jwt
impl RefUnwindSafe for Jwt
impl Send for Jwt
impl Sync for Jwt
impl Unpin for Jwt
impl UnsafeUnpin for Jwt
impl UnwindSafe for Jwt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more