Requests
Authentication
Send basic auth credentials, bearer tokens and API keys.
Basic auth
BasicAuth sets the Authorization header with the encoded username and password:
apitest.Handler(handler).
Get("/admin").
BasicAuth("username", "password").
Expect(t).
Status(http.StatusOK).
End()Bearer tokens and API keys
Tokens are ordinary headers:
apitest.Handler(handler).
Get("/me").
Header("Authorization", "Bearer "+token).
Expect(t).
Status(http.StatusOK).
End()If every test needs the same credentials, put them in a helper that configures the test. When the handler expects a signature computed from the final request, compute it in an interceptor.
Asserting on tokens in the response
The JSONPath module can decode a JWT returned by a login endpoint and assert on its header and claims.