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

Function TestRefreshToken_Success

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

Source from the content-addressed store, hash-verified

94}
95
96func TestRefreshToken_Success(t *testing.T) {
97 mux := http.NewServeMux()
98 mux.HandleFunc("/2/oauth/token", func(w http.ResponseWriter, r *http.Request) {
99 require.NoError(t, r.ParseForm())
100 assert.Equal(t, "refresh_token", r.FormValue("grant_type"))
101 assert.Equal(t, "old-refresh-token", r.FormValue("refresh_token"))
102
103 require.NoError(t, json.NewEncoder(w).Encode(OAuthTokenResponse{
104 AccessToken: "new-access-token",
105 RefreshToken: "new-refresh-token",
106 ExpiresIn: 7200,
107 }))
108 })
109
110 ts, client := newTestClient(mux)
111 defer ts.Close()
112
113 resp, err := client.RefreshToken("old-refresh-token")
114 require.NoError(t, err)
115 assert.Equal(t, "new-access-token", resp.AccessToken)
116 assert.Equal(t, "new-refresh-token", resp.RefreshToken)
117}
118
119func TestListApplications_Success(t *testing.T) {
120 mux := http.NewServeMux()

Callers

nothing calls this directly

Calls 3

newTestClientFunction · 0.85
RefreshTokenMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected