Documentation
¶
Overview ¶
Package authtest is a fake GitHub OAuth server for device-flow and refresh tests. It listens on loopback only and issues obviously fake tokens (ghu_test_access_N, ghr_test_refresh_N). Like GitHub, it answers OAuth errors with HTTP 200 and an "error" field, and it rotates the refresh token on every refresh, so a second refresh with the old one fails the way it does at GitHub.
Index ¶
Constants ¶
View Source
const ( ClientID = "Iv1.test-client" DeviceCode = "dc_test_1" UserCode = "WDJB-MJHT" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Pending int // polls answered authorization_pending before the approval
SlowDown bool // the first poll answers slow_down (with interval 10)
Deny bool // polls answer access_denied
ExpiredCode bool // polls answer expired_token
CodeExpiresIn int // the device code's lifetime in seconds; 0 means 900
RefreshToken string // a valid refresh token to start with, for refresh-only tests
RefreshBad bool // every refresh answers bad_refresh_token
EchoSecrets bool // error replies repeat the posted form (tokens included) in error_description
Fail500 bool // every request fails with HTTP 500, its body repeating the posted form
RefreshGate func() // runs inside each refresh before it answers (the race test blocks here)
}
Options script the server. They are fixed when it starts, so tests never race the handler.
type Server ¶
func (*Server) AccessToken ¶
AccessToken and RefreshToken are the n-th pair the server issues (from 1).
func (*Server) RefreshToken ¶
Click to show internal directories.
Click to hide internal directories.