We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 49aadad commit 76fce30Copy full SHA for 76fce30
README.md
@@ -115,3 +115,23 @@ apitest.New().
115
Assert(Matches(`$.a`, `^[abc]{1,3}$`)).
116
End()
117
```
118
+
119
+### JWT matchers
120
121
+`JWTHeaderEqual` and `JWTPayloadEqual` can be used to assert on the contents of the JWT in the response (it does not verify a JWT).
122
123
+```go
124
+func TestX(t *testing.T) {
125
+ apitest.New().
126
+ HandlerFunc(myHandler).
127
+ Post("/login").
128
+ Expect(t).
129
+ Assert(jsonpath.JWTPayloadEqual(fromAuthHeader, `$.sub`, "1234567890")).
130
+ Assert(jsonpath.JWTHeaderEqual(fromAuthHeader, `$.alg`, "HS256")).
131
+ End()
132
+}
133
134
+func fromAuthHeader(res *http.Response) (string, error) {
135
+ return res.Header.Get("Authorization"), nil
136
137
+```
0 commit comments