|
|
|
|
@ -33,7 +33,9 @@ func Test_StartAuth(t *testing.T) {
|
|
|
|
|
_, _, tpAlg, _ := tp.SigningKeys()
|
|
|
|
|
tpCert, err := ParseCertificates(ctx, tp.CACert())
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
tpPrompt := []PromptParam{Consent, SelectAccount}
|
|
|
|
|
tpPrompt := []PromptParam{SelectAccount}
|
|
|
|
|
tpNoneWithMultiplePrompts := []PromptParam{None, SelectAccount}
|
|
|
|
|
tpWithMultiplePrompts := []PromptParam{Consent, SelectAccount}
|
|
|
|
|
conn, _ := db.TestSetup(t, "postgres")
|
|
|
|
|
rw := db.New(conn)
|
|
|
|
|
rootWrapper := db.TestWrapper(t)
|
|
|
|
|
@ -88,6 +90,26 @@ func Test_StartAuth(t *testing.T) {
|
|
|
|
|
WithPrompts(tpPrompt...),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
testAuthMethodWithMultiplePrompts := TestAuthMethod(
|
|
|
|
|
t, conn, databaseWrapper, org.PublicId, ActivePublicState,
|
|
|
|
|
"test-rp5", "fido",
|
|
|
|
|
WithIssuer(TestConvertToUrls(t, tp.Addr())[0]),
|
|
|
|
|
WithApiUrl(TestConvertToUrls(t, testController.URL)[0]),
|
|
|
|
|
WithSigningAlgs(Alg(tpAlg)),
|
|
|
|
|
WithCertificates(tpCert...),
|
|
|
|
|
WithPrompts(tpWithMultiplePrompts...),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
testAuthMethodNoneWithMultiplePrompts := TestAuthMethod(
|
|
|
|
|
t, conn, databaseWrapper, org.PublicId, ActivePublicState,
|
|
|
|
|
"test-rp6", "fido",
|
|
|
|
|
WithIssuer(TestConvertToUrls(t, tp.Addr())[0]),
|
|
|
|
|
WithApiUrl(TestConvertToUrls(t, testController.URL)[0]),
|
|
|
|
|
WithSigningAlgs(Alg(tpAlg)),
|
|
|
|
|
WithCertificates(tpCert...),
|
|
|
|
|
WithPrompts(tpNoneWithMultiplePrompts...),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
stdSetup := func(am *AuthMethod, repoFn OidcRepoFactory, apiSrv *httptest.Server) (a *AuthMethod, allowedRedirect string) {
|
|
|
|
|
// update the allowed redirects for the TestProvider
|
|
|
|
|
tpAllowedRedirect := fmt.Sprintf(CallbackEndpoint, apiSrv.URL)
|
|
|
|
|
@ -172,6 +194,22 @@ func Test_StartAuth(t *testing.T) {
|
|
|
|
|
authMethod: testAuthMethodWithPrompt,
|
|
|
|
|
setup: stdSetup,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "simple-with-multiple-prompts",
|
|
|
|
|
repoFn: repoFn,
|
|
|
|
|
apiSrv: testController,
|
|
|
|
|
authMethod: testAuthMethodWithMultiplePrompts,
|
|
|
|
|
setup: stdSetup,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "simple-with-none-and-multiple-prompts",
|
|
|
|
|
repoFn: repoFn,
|
|
|
|
|
apiSrv: testController,
|
|
|
|
|
authMethod: testAuthMethodNoneWithMultiplePrompts,
|
|
|
|
|
setup: stdSetup,
|
|
|
|
|
wantErrMatch: errors.T(errors.InvalidParameter),
|
|
|
|
|
wantErrContains: "prompts ([none select_account]) includes \"none\" with other values",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
|
|