MCPcopy Create free account
hub / github.com/algolia/cli / TestAuthorizationCodeGrant_InvalidGrant

Function TestAuthorizationCodeGrant_InvalidGrant

api/dashboard/client_test.go:78–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

76}
77
78func TestAuthorizationCodeGrant_InvalidGrant(t *testing.T) {
79 mux := http.NewServeMux()
80 mux.HandleFunc("/2/oauth/token", func(w http.ResponseWriter, r *http.Request) {
81 w.WriteHeader(http.StatusBadRequest)
82 require.NoError(t, json.NewEncoder(w).Encode(OAuthErrorResponse{
83 Error: "invalid_grant",
84 ErrorDescription: "Authorization code has expired.",
85 }))
86 })
87
88 ts, client := newTestClient(mux)
89 defer ts.Close()
90
91 _, err := client.AuthorizationCodeGrant("expired-code", "verifier", "http://localhost:12345")
92 assert.Error(t, err)
93 assert.Contains(t, err.Error(), "Authorization code has expired")
94}
95
96func TestRefreshToken_Success(t *testing.T) {
97 mux := http.NewServeMux()

Callers

nothing calls this directly

Calls 4

newTestClientFunction · 0.85
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected