Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/go_modules/github.com/playwrigh…
Browse files Browse the repository at this point in the history
…t-community/playwright-go-0.3500.0
  • Loading branch information
mapkon authored Jul 19, 2023
2 parents b6a6320 + f5f7ed0 commit f1be86d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/provider/googleapps/googleapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,24 @@ func (kc *Client) Authenticate(loginDetails *creds.LoginDetails) (string, error)
if responseDoc.Selection.Find("#passwordError").Text() != "" {
return "", errors.New("Password error")
}

if err := isMissing2StepSetup(responseDoc); err != nil {
return "", err
}

return "", errors.New("page is missing saml assertion")
}

return samlAssertion, nil
}

func isMissing2StepSetup(responseDoc *goquery.Document) error {
if responseDoc.Selection.Find("section.aN1Vld ").Text() != "" {
return errors.New("Because of your organization settings, you must set-up 2-Step Verification in your account")
}
return nil
}

func (kc *Client) tryDisplayCaptcha(captchaPictureURL string) (string, error) {
// TODO: check for user flag for easy captcha presentation

Expand Down
10 changes: 10 additions & 0 deletions pkg/provider/googleapps/googleapps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ func TestWrongPassword(t *testing.T) {
require.NotEqual(t, "", txt)
}

func TestMustEnable2StepVerification(t *testing.T) {
html := `<html><body><section class="aN1Vld "><div class="yOnVIb" jsname="MZArnb"><div jsname="x2WF9"><p class="vOZun">Your sign-in settings don’t meet your organization’s 2-Step Verification policy.</p><p class="vOZun">Contact your admin for more info.</p></div><input type="hidden" name="identifierInput" value="" id="identifierId"></div></section></body></html>`

doc, err := goquery.NewDocumentFromReader(strings.NewReader(html))
require.Nil(t, err)
twoStepIsMissingErr := isMissing2StepSetup(doc)
require.Error(t, twoStepIsMissingErr)
require.Equal(t, twoStepIsMissingErr.Error(), "Because of your organization settings, you must set-up 2-Step Verification in your account")
}

func TestExtractDevicePushExtraNumber(t *testing.T) {
data1, err := os.ReadFile("example/challenge-extra-number.html")
require.Nil(t, err)
Expand Down

0 comments on commit f1be86d

Please sign in to comment.