Class: MockServer::Jwt
- Inherits:
-
Object
- Object
- MockServer::Jwt
- Defined in:
- lib/mockserver/models.rb
Overview
JWT (bearer-token) request matcher. Matches a request whose JWT — carried by
default in the Authorization: Bearer <token> header — satisfies every
constraint below.
claims is a { claim-name => value } map where each value is an exact string
or a regular expression; a leading ! negates the match (the NottableString
convention shared across MockServer matchers). issuer, audience,
algorithm, header and scheme are optional; unset keys are omitted.
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
Returns the value of attribute algorithm.
-
#audience ⇒ Object
Returns the value of attribute audience.
-
#claims ⇒ Object
Returns the value of attribute claims.
-
#header ⇒ Object
Returns the value of attribute header.
-
#issuer ⇒ Object
Returns the value of attribute issuer.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(claims: nil, issuer: nil, audience: nil, algorithm: nil, header: nil, scheme: nil) ⇒ Jwt
constructor
A new instance of Jwt.
- #to_h ⇒ Object
- #with_claim(name, value) ⇒ Object
Constructor Details
#initialize(claims: nil, issuer: nil, audience: nil, algorithm: nil, header: nil, scheme: nil) ⇒ Jwt
Returns a new instance of Jwt.
740 741 742 743 744 745 746 747 |
# File 'lib/mockserver/models.rb', line 740 def initialize(claims: nil, issuer: nil, audience: nil, algorithm: nil, header: nil, scheme: nil) @claims = claims @issuer = issuer @audience = audience @algorithm = algorithm @header = header @scheme = scheme end |
Instance Attribute Details
#algorithm ⇒ Object
Returns the value of attribute algorithm.
738 739 740 |
# File 'lib/mockserver/models.rb', line 738 def algorithm @algorithm end |
#audience ⇒ Object
Returns the value of attribute audience.
738 739 740 |
# File 'lib/mockserver/models.rb', line 738 def audience @audience end |
#claims ⇒ Object
Returns the value of attribute claims.
738 739 740 |
# File 'lib/mockserver/models.rb', line 738 def claims @claims end |
#header ⇒ Object
Returns the value of attribute header.
738 739 740 |
# File 'lib/mockserver/models.rb', line 738 def header @header end |
#issuer ⇒ Object
Returns the value of attribute issuer.
738 739 740 |
# File 'lib/mockserver/models.rb', line 738 def issuer @issuer end |
#scheme ⇒ Object
Returns the value of attribute scheme.
738 739 740 |
# File 'lib/mockserver/models.rb', line 738 def scheme @scheme end |
Class Method Details
.from_hash(data) ⇒ Object
760 761 762 763 764 765 766 767 768 769 770 771 |
# File 'lib/mockserver/models.rb', line 760 def self.from_hash(data) return nil if data.nil? new( claims: data['claims'], issuer: data['issuer'], audience: data['audience'], algorithm: data['algorithm'], header: data['header'], scheme: data['scheme'] ) end |
Instance Method Details
#to_h ⇒ Object
749 750 751 752 753 754 755 756 757 758 |
# File 'lib/mockserver/models.rb', line 749 def to_h result = {} result['claims'] = @claims unless @claims.nil? result['issuer'] = @issuer unless @issuer.nil? result['audience'] = @audience unless @audience.nil? result['algorithm'] = @algorithm unless @algorithm.nil? result['header'] = @header unless @header.nil? result['scheme'] = @scheme unless @scheme.nil? result end |
#with_claim(name, value) ⇒ Object
773 774 775 776 777 |
# File 'lib/mockserver/models.rb', line 773 def with_claim(name, value) @claims ||= {} @claims[name] = value self end |