-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/go_modules/github.com/playwrigh…
…t-community/playwright-go-0.3700.0
- Loading branch information
Showing
9 changed files
with
371 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ type FixtureData struct { | |
ProofUpToken string // UVrFbiiZj6kdD6oWm4k87CkipgjEbKhlq_dKoMTo8p0TRCf4utimEAnOizRQ7qAoHaotT08os5kctHfJhXw7dkactSsYjtYo9Lt_1vlPPmZ8i0FtfrwjMeztp0sMY6PHkfRO_sWIHR2bsvIpjaKqqNTJ8PZCuwNmfR8Tx2Jdud3F1FcUgkF3-MG5omxJR7oaueRn1SvnjR-sWEleKptBqLTFnVwNeY8kVfpiKV4liNACZkWc9N5CJRC7HO4aLHVUkKcWaCERUZWeaHh0Bdk_aHSZFll1C6yBv0v4IIJfTQuCOdRMXmqvSpxpRUcwgZ7vdY6krAYUAV8SG926Fptr3if69AM5GHxKN4AlyNNJZ5ghv0yqwI4aGTg1vsanq0q8ZE80TOCBZdMz39Tr_J5MKMW2HO7lEMPtZYBCYwz3Z4nzbgWo9aB65GcxNcnzXgBMeiwjgxQphpFahbj89Rc8H0PWbN4Yhh-aDlv_UMwd2lp1I98hxdEn-8uA56xCE4l1647RuwSiCIfzE_6dYxXm8Q | ||
UserName string // [email protected] | ||
UserNameUrlEncoded string // exampleuser%40exampledomain.com | ||
SErrorCode string // 50058 | ||
} | ||
|
||
var fixtureData *FixtureData | ||
|
@@ -308,6 +309,57 @@ func Test_Authenticate(t *testing.T) { | |
require.Nil(t, err) | ||
require.NotEmpty(t, got) | ||
}) | ||
t.Run("Default login with KMSI and MFA but Authenticator required", func(t *testing.T) { | ||
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
switch r.URL.Path { | ||
case "/index", "/applications/redirecttofederatedapplication.aspx": | ||
writeFixtureBytes(t, w, r, "ConvergedSignIn.html", FixtureData{ | ||
UrlPost: "/defaultLogin", | ||
UrlGetCredentialType: "/getCredentialType", | ||
}) | ||
case "/getCredentialType": | ||
writeFixtureBytes(t, w, r, "GetCredentialType_default.json", FixtureData{}) | ||
case "/defaultLogin": | ||
writeFixtureBytes(t, w, r, "KmsiInterrupt.html", FixtureData{ | ||
UrlPost: "/hForm", | ||
}) | ||
case "/hForm": | ||
writeFixtureBytes(t, w, r, "HiddenForm.html", FixtureData{ | ||
UrlHiddenForm: "/sRequest", | ||
}) | ||
case "/sRequest": | ||
writeFixtureBytes(t, w, r, "SAMLRequest.html", FixtureData{ | ||
UrlSamlRequest: "/sResponse?SAMLRequest=ExampleValue", | ||
}) | ||
case "/sResponse": | ||
writeFixtureBytes(t, w, r, "ConvergedTFA.html", FixtureData{ | ||
UrlPost: "/processAuth", | ||
UrlBeginAuth: "/beginAuth", | ||
UrlEndAuth: "/endAuth", | ||
}) | ||
case "/beginAuth": | ||
writeFixtureBytes(t, w, r, "BeginAuth.json", FixtureData{}) | ||
case "/endAuth": | ||
writeFixtureBytes(t, w, r, "EndAuth.json", FixtureData{}) | ||
case "/processAuth": | ||
writeFixtureBytes(t, w, r, "ConvergedProofUpRedirect.html", FixtureData{ | ||
SErrorCode: "502031", | ||
}) | ||
default: | ||
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) | ||
} | ||
})) | ||
defer ts.Close() | ||
|
||
pr := &mocks.Prompter{} | ||
prompter.SetPrompter(pr) | ||
pr.Mock.On("StringRequired", "Enter verification code").Return("000000") | ||
|
||
ac, loginDetails := setupTestClient(t, ts) | ||
_, err := ac.Authenticate(loginDetails) | ||
require.Error(t, err) | ||
require.Contains(t, err.Error(), "502031") | ||
}) | ||
t.Run("ADFS login with KMSI and MFA", func(t *testing.T) { | ||
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
switch r.URL.Path { | ||
|
@@ -386,56 +438,57 @@ func writeFixtureBytes(t *testing.T, w http.ResponseWriter, r *http.Request, tem | |
template, err := template.ParseFiles("testdata/" + templateFile) | ||
require.Nil(t, err) | ||
var tpl bytes.Buffer | ||
err = template.Execute(&tpl, urlFixtures(r.Host, variableFixture)) | ||
err = template.Execute(&tpl, responseFixtures(r.Host, variableFixture)) | ||
require.Nil(t, err) | ||
_, _ = w.Write(tpl.Bytes()) | ||
} | ||
|
||
func urlFixtures(host string, urls FixtureData) *FixtureData { | ||
func responseFixtures(host string, variableFixture FixtureData) *FixtureData { | ||
const scheme = "https://" | ||
fixtureData := genFixtureData() | ||
if urls.UrlFederationRedirect != "" { | ||
fixtureData.UrlFederationRedirect = scheme + host + urls.UrlFederationRedirect | ||
fixtureData.SErrorCode = variableFixture.SErrorCode | ||
if variableFixture.UrlFederationRedirect != "" { | ||
fixtureData.UrlFederationRedirect = scheme + host + variableFixture.UrlFederationRedirect | ||
} else { | ||
fixtureData.UrlFederationRedirect = "" | ||
} | ||
if urls.UrlSkipMfaRegistration != "" { | ||
fixtureData.UrlSkipMfaRegistration = scheme + host + urls.UrlSkipMfaRegistration | ||
if variableFixture.UrlSkipMfaRegistration != "" { | ||
fixtureData.UrlSkipMfaRegistration = scheme + host + variableFixture.UrlSkipMfaRegistration | ||
} else { | ||
fixtureData.UrlSkipMfaRegistration = "" | ||
} | ||
if urls.UrlGetCredentialType != "" { | ||
fixtureData.UrlGetCredentialType = scheme + host + urls.UrlGetCredentialType | ||
if variableFixture.UrlGetCredentialType != "" { | ||
fixtureData.UrlGetCredentialType = scheme + host + variableFixture.UrlGetCredentialType | ||
} else { | ||
fixtureData.UrlGetCredentialType = "" | ||
} | ||
if urls.UrlPost != "" { | ||
fixtureData.UrlPost = scheme + host + urls.UrlPost | ||
if variableFixture.UrlPost != "" { | ||
fixtureData.UrlPost = scheme + host + variableFixture.UrlPost | ||
} else { | ||
fixtureData.UrlPost = "" | ||
} | ||
if urls.UrlBeginAuth != "" { | ||
fixtureData.UrlBeginAuth = scheme + host + urls.UrlBeginAuth | ||
if variableFixture.UrlBeginAuth != "" { | ||
fixtureData.UrlBeginAuth = scheme + host + variableFixture.UrlBeginAuth | ||
} else { | ||
fixtureData.UrlBeginAuth = "" | ||
} | ||
if urls.UrlEndAuth != "" { | ||
fixtureData.UrlEndAuth = scheme + host + urls.UrlEndAuth | ||
if variableFixture.UrlEndAuth != "" { | ||
fixtureData.UrlEndAuth = scheme + host + variableFixture.UrlEndAuth | ||
} else { | ||
fixtureData.UrlEndAuth = "" | ||
} | ||
if urls.UrlProcessAuth != "" { | ||
fixtureData.UrlProcessAuth = scheme + host + urls.UrlProcessAuth | ||
if variableFixture.UrlProcessAuth != "" { | ||
fixtureData.UrlProcessAuth = scheme + host + variableFixture.UrlProcessAuth | ||
} else { | ||
fixtureData.UrlProcessAuth = "" | ||
} | ||
if urls.UrlHiddenForm != "" { | ||
fixtureData.UrlHiddenForm = scheme + host + urls.UrlHiddenForm | ||
if variableFixture.UrlHiddenForm != "" { | ||
fixtureData.UrlHiddenForm = scheme + host + variableFixture.UrlHiddenForm | ||
} else { | ||
fixtureData.UrlHiddenForm = "" | ||
} | ||
if urls.UrlSamlRequest != "" { | ||
fixtureData.UrlSamlRequest = scheme + host + urls.UrlSamlRequest | ||
if variableFixture.UrlSamlRequest != "" { | ||
fixtureData.UrlSamlRequest = scheme + host + variableFixture.UrlSamlRequest | ||
} else { | ||
fixtureData.UrlSamlRequest = "" | ||
} | ||
|
Oops, something went wrong.