Skip to content

Commit 9909d82

Browse files
committed
fix: set default device flow url
1 parent a27a5d4 commit 9909d82

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

internal/server/deviceflow.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ retry:
5151
}
5252
if host == "" {
5353
// Default to the request hostname when in single tenant mode
54-
host = rctx.Request.URL.Host
54+
host = rctx.Request.Host
5555
}
5656

5757
return &api.DeviceFlowResponse{

internal/server/deviceflow_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,20 @@ func TestAPI_StartDeviceFlow(t *testing.T) {
102102
srv := setupServer(t, withAdminUser)
103103
routes := srv.GenerateRoutes()
104104

105-
u := "https://api.example.com:2020/api/device"
106-
req, err := http.NewRequest(http.MethodPost, u, nil)
107-
assert.NilError(t, err)
105+
req := httptest.NewRequest(http.MethodPost, "/api/device", nil)
108106
req.Header.Set("Infra-Version", apiVersionLatest)
109107
resp := httptest.NewRecorder()
110108
routes.ServeHTTP(resp, req)
111109

112110
flowResp := &api.DeviceFlowResponse{}
113-
err = json.NewDecoder(resp.Body).Decode(flowResp)
111+
err := json.NewDecoder(resp.Body).Decode(flowResp)
114112
assert.NilError(t, err)
115113

116114
assert.Equal(t, resp.Code, http.StatusCreated, (*responseDebug)(resp))
117115
expected := &api.DeviceFlowResponse{
118116
DeviceCode: "<any-string>",
119117
UserCode: "<any-string>",
120-
VerificationURI: "https://api.example.com:2020/device",
118+
VerificationURI: "https://example.com/device",
121119
ExpiresInSeconds: 600,
122120
PollIntervalSeconds: 5,
123121
}

0 commit comments

Comments
 (0)