Merge pull request #1882 from vmware-tanzu/chrome_debugging

Add some logging and comments making it easier to debug with chrome
This commit is contained in:
Joshua Casey
2024-03-05 16:15:40 -06:00
committed by GitHub
2 changed files with 23 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved.
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package integration
@@ -2966,6 +2966,15 @@ func startLocalCallbackServer(t *testing.T) *localCallbackServer {
// Handle the callback by sending the *http.Request object back through a channel.
callbacks := make(chan *http.Request, 1)
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
t.Logf("got request at localhost callback listener with method %s, URL %s headers: %#v", r.Method, r.URL.String(), r.Header)
if r.Method == http.MethodGet && r.URL.Path == "/favicon.ico" {
// Chrome will request favicons. The favicon request will come after the authcode request.
// 404 those requests rather than hanging on the channel send below.
w.WriteHeader(http.StatusNotFound)
return
}
callbacks <- r
}))
server.URL += "/callback"

View File

@@ -1,4 +1,4 @@
// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved.
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Package browsertest provides integration test helpers for our browser-based tests.
@@ -56,10 +56,22 @@ func OpenBrowser(t *testing.T) *Browser {
options := append(
// Start with the defaults.
chromedp.DefaultExecAllocatorOptions[:],
// Add "ignore-certificate-errors" Chrome flag.
chromedp.IgnoreCertErrors,
// Uncomment this to watch the browser while the test runs.
// chromedp.Flag("headless", false), chromedp.Flag("hide-scrollbars", false), chromedp.Flag("mute-audio", false),
// Uncomment this to automatically open the devtools window when the browser opens. Helpful when not headless.
// chromedp.Flag("auto-open-devtools-for-tabs", true),
// Uncomment one of these lines (and update path if needed) to use
// Google Chrome Beta (download from https://www.google.com/chrome/beta/)
// when running integration tests on your local machine.
// These are the default paths for macOS and Linux, respectively.
// chromedp.ExecPath("/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta"),
// chromedp.ExecPath("/usr/bin/google-chrome-beta"),
)
if runtime.GOOS != "darwin" && runtime.GOOS != "windows" {