Skip to content

Commit 653ddcc

Browse files
authored
fix(agent): remove unused token debug handler (#12602)
1 parent 8d7819f commit 653ddcc

File tree

3 files changed

+0
-30
lines changed

3 files changed

+0
-30
lines changed

agent/agent.go

-13
Original file line numberDiff line numberDiff line change
@@ -1714,18 +1714,6 @@ func (a *agent) HandleHTTPDebugManifest(w http.ResponseWriter, r *http.Request)
17141714
}
17151715
}
17161716

1717-
func (a *agent) HandleHTTPDebugToken(w http.ResponseWriter, r *http.Request) {
1718-
tok := a.sessionToken.Load()
1719-
if tok == nil {
1720-
a.logger.Error(r.Context(), "no session token in-memory")
1721-
w.WriteHeader(http.StatusInternalServerError)
1722-
_, _ = fmt.Fprintf(w, "no session token in-memory")
1723-
return
1724-
}
1725-
w.WriteHeader(http.StatusOK)
1726-
_, _ = fmt.Fprintf(w, *tok)
1727-
}
1728-
17291717
func (a *agent) HandleHTTPDebugLogs(w http.ResponseWriter, r *http.Request) {
17301718
logPath := filepath.Join(a.logDir, "coder-agent.log")
17311719
f, err := os.Open(logPath)
@@ -1753,7 +1741,6 @@ func (a *agent) HTTPDebug() http.Handler {
17531741
r.Get("/debug/magicsock", a.HandleHTTPDebugMagicsock)
17541742
r.Get("/debug/magicsock/debug-logging/{state}", a.HandleHTTPMagicsockDebugLoggingState)
17551743
r.Get("/debug/manifest", a.HandleHTTPDebugManifest)
1756-
r.Get("/debug/token", a.HandleHTTPDebugToken)
17571744
r.NotFound(func(w http.ResponseWriter, r *http.Request) {
17581745
w.WriteHeader(http.StatusNotFound)
17591746
_, _ = w.Write([]byte("404 not found"))

agent/agent_test.go

-16
Original file line numberDiff line numberDiff line change
@@ -2088,22 +2088,6 @@ func TestAgent_DebugServer(t *testing.T) {
20882088
require.NotNil(t, v)
20892089
})
20902090

2091-
t.Run("Token", func(t *testing.T) {
2092-
t.Parallel()
2093-
2094-
ctx := testutil.Context(t, testutil.WaitLong)
2095-
req, err := http.NewRequestWithContext(ctx, http.MethodGet, srv.URL+"/debug/token", nil)
2096-
require.NoError(t, err)
2097-
2098-
res, err := srv.Client().Do(req)
2099-
require.NoError(t, err)
2100-
require.Equal(t, http.StatusOK, res.StatusCode)
2101-
defer res.Body.Close()
2102-
resBody, err := io.ReadAll(res.Body)
2103-
require.NoError(t, err)
2104-
require.Equal(t, "token", string(resBody))
2105-
})
2106-
21072091
t.Run("Logs", func(t *testing.T) {
21082092
t.Parallel()
21092093

agent/api.go

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func (a *agent) apiHandler() http.Handler {
4040
r.Get("/debug/magicsock", a.HandleHTTPDebugMagicsock)
4141
r.Get("/debug/magicsock/debug-logging/{state}", a.HandleHTTPMagicsockDebugLoggingState)
4242
r.Get("/debug/manifest", a.HandleHTTPDebugManifest)
43-
r.Get("/debug/token", a.HandleHTTPDebugToken)
4443

4544
return r
4645
}

0 commit comments

Comments
 (0)