From 9909d8261effc584b23eec41d218324aa6032dd8 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Wed, 2 Nov 2022 16:53:08 -0700 Subject: [PATCH] fix: set default device flow url --- internal/server/deviceflow.go | 2 +- internal/server/deviceflow_test.go | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/server/deviceflow.go b/internal/server/deviceflow.go index a340fba354..c3558e4b28 100644 --- a/internal/server/deviceflow.go +++ b/internal/server/deviceflow.go @@ -51,7 +51,7 @@ retry: } if host == "" { // Default to the request hostname when in single tenant mode - host = rctx.Request.URL.Host + host = rctx.Request.Host } return &api.DeviceFlowResponse{ diff --git a/internal/server/deviceflow_test.go b/internal/server/deviceflow_test.go index bd5d7bb389..984c60db3d 100644 --- a/internal/server/deviceflow_test.go +++ b/internal/server/deviceflow_test.go @@ -102,22 +102,20 @@ func TestAPI_StartDeviceFlow(t *testing.T) { srv := setupServer(t, withAdminUser) routes := srv.GenerateRoutes() - u := "https://api.example.com:2020/api/device" - req, err := http.NewRequest(http.MethodPost, u, nil) - assert.NilError(t, err) + req := httptest.NewRequest(http.MethodPost, "/api/device", nil) req.Header.Set("Infra-Version", apiVersionLatest) resp := httptest.NewRecorder() routes.ServeHTTP(resp, req) flowResp := &api.DeviceFlowResponse{} - err = json.NewDecoder(resp.Body).Decode(flowResp) + err := json.NewDecoder(resp.Body).Decode(flowResp) assert.NilError(t, err) assert.Equal(t, resp.Code, http.StatusCreated, (*responseDebug)(resp)) expected := &api.DeviceFlowResponse{ DeviceCode: "", UserCode: "", - VerificationURI: "https://api.example.com:2020/device", + VerificationURI: "https://example.com/device", ExpiresInSeconds: 600, PollIntervalSeconds: 5, }