blob: 9d79fd61a797e94c114815060e81940da88a419c [file] [log] [blame]
package dockertests
import (
"github.com/30x/apidApigeeSync"
"github.com/30x/apid-core"
"encoding/json"
"net/http"
)
const oauthExpiresIn = 2 * 60
type MockAuthServer struct {
}
func (m *MockAuthServer) sendToken (w http.ResponseWriter, req *http.Request) {
oauthToken := apidApigeeSync.GenerateUUID()
res := apidApigeeSync.OauthToken{
AccessToken: oauthToken,
ExpiresIn: oauthExpiresIn,
}
body, err := json.Marshal(res)
if err != nil {
panic(err)
}
w.Write(body)
}
func (m *MockAuthServer) Start (router apid.Router) {
router.HandleFunc("/accesstoken", m.sendToken).Methods("POST")
}