Skip to content

Commit

Permalink
Merge pull request #3548 from infrahq/mxyng/default-device-flow-host
Browse files Browse the repository at this point in the history
fix: set default device flow url
  • Loading branch information
mxyng authored Nov 3, 2022
2 parents a27a5d4 + 9909d82 commit 30461d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/server/deviceflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
8 changes: 3 additions & 5 deletions internal/server/deviceflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<any-string>",
UserCode: "<any-string>",
VerificationURI: "https://api.example.com:2020/device",
VerificationURI: "https://example.com/device",
ExpiresInSeconds: 600,
PollIntervalSeconds: 5,
}
Expand Down

0 comments on commit 30461d3

Please sign in to comment.