Skip to content

Commit

Permalink
Refactor to a constant; update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
kbarlowgw committed Oct 31, 2023
1 parent 98624e6 commit bec46e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pkg/provider/browser/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (

var logger = logrus.WithField("provider", "browser")

var TimeoutPageWaitForRequest = newPageWaitForRequestOptions(300000)

// Client client for browser based Identity Provider
type Client struct {
Headless bool
Expand Down Expand Up @@ -94,8 +96,7 @@ var getSAMLResponse = func(page playwright.Page, loginDetails *creds.LoginDetail
}

logger.Info("waiting ...")
var timeout float64 = 300000
r, _ := page.WaitForRequest(signin_re, playwright.PageWaitForRequestOptions{Timeout: &timeout})
r, _ := page.WaitForRequest(signin_re, TimeoutPageWaitForRequest)
data, err := r.PostData()
if err != nil {
return "", err
Expand Down Expand Up @@ -124,3 +125,7 @@ func (cl *Client) Validate(loginDetails *creds.LoginDetails) error {

return nil
}

func newPageWaitForRequestOptions(timeout float64) playwright.PageWaitForRequestOptions {
return playwright.PageWaitForRequestOptions{Timeout: &timeout}
}
2 changes: 1 addition & 1 deletion pkg/provider/browser/browser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestGetSAMLResponse(t *testing.T) {
regex, err := signinRegex()
assert.Nil(t, err)
page.Mock.On("Goto", url).Return(resp, nil)
page.Mock.On("WaitForRequest", regex).Return(req)
page.Mock.On("WaitForRequest", regex, TimeoutPageWaitForRequest).Return(req)
req.Mock.On("PostData").Return(params.Encode(), nil)
// loginDetails := &creds.LoginDetails{
// URL: url,
Expand Down

0 comments on commit bec46e2

Please sign in to comment.