From 135cf718d5c820503dba36b28ccec48ceeff6826 Mon Sep 17 00:00:00 2001 From: Clement Michaud Date: Wed, 4 Dec 2019 08:46:49 +0100 Subject: [PATCH] Fix DuoPush suite and do some clean up. --- cmd/authelia-scripts/cmd_ci.go | 5 ----- cmd/authelia-scripts/cmd_suites.go | 2 +- config.template.yml | 4 ++-- example/compose/authelia/resources/entrypoint.sh | 6 +++++- example/compose/nginx/backend/html/home/index.html | 4 ++-- internal/configuration/test_resources/config.yml | 4 ++-- internal/suites/action_2fa_methods.go | 1 + internal/suites/scenario_user_preferences_test.go | 6 +----- internal/suites/suite_duo_push.go | 2 +- .../LoginPortal/SecondFactor/MethodSelectionDialog.tsx | 3 +-- 10 files changed, 16 insertions(+), 21 deletions(-) diff --git a/cmd/authelia-scripts/cmd_ci.go b/cmd/authelia-scripts/cmd_ci.go index 16ea9d6fa..c237822a3 100644 --- a/cmd/authelia-scripts/cmd_ci.go +++ b/cmd/authelia-scripts/cmd_ci.go @@ -27,9 +27,4 @@ func RunCI(cmd *cobra.Command, args []string) { if err := utils.CommandWithStdout("authelia-scripts", "--log-level", "debug", "unittest").Run(); err != nil { log.Fatal(err) } - - log.Info("=====> Build Docker stage <=====") - if err := utils.CommandWithStdout("authelia-scripts", "--log-level", "debug", "docker", "build").Run(); err != nil { - log.Fatal(err) - } } diff --git a/cmd/authelia-scripts/cmd_suites.go b/cmd/authelia-scripts/cmd_suites.go index 02e7d2134..cba27645c 100644 --- a/cmd/authelia-scripts/cmd_suites.go +++ b/cmd/authelia-scripts/cmd_suites.go @@ -237,7 +237,7 @@ func runSuiteTests(suiteName string, withEnv bool) error { if suite.TestTimeout > 0 { timeout = fmt.Sprintf("%ds", int64(suite.TestTimeout/time.Second)) } - testCmdLine := fmt.Sprintf("go test -v ./internal/suites -timeout %s -run '^(Test%sSuite)$'", timeout, suiteName) + testCmdLine := fmt.Sprintf("go test -count=1 -v ./internal/suites -timeout %s -run '^(Test%sSuite)$'", timeout, suiteName) log.Infof("Running tests of suite %s...", suiteName) log.Debugf("Running tests with command: %s", testCmdLine) diff --git a/config.template.yml b/config.template.yml index 74ec4dfea..3ea6bdf85 100644 --- a/config.template.yml +++ b/config.template.yml @@ -157,10 +157,10 @@ access_control: # Rules applied to 'admins' group - domain: "mx2.mail.example.com" - subject: "groups:admins" + subject: "group:admins" policy: deny - domain: "*.example.com" - subject: "groups:admins" + subject: "group:admins" policy: two_factor # Rules applied to 'dev' group diff --git a/example/compose/authelia/resources/entrypoint.sh b/example/compose/authelia/resources/entrypoint.sh index e1ba78bab..e31d1459f 100755 --- a/example/compose/authelia/resources/entrypoint.sh +++ b/example/compose/authelia/resources/entrypoint.sh @@ -7,4 +7,8 @@ go get github.com/cespare/reflex mkdir -p /var/lib/authelia mkdir -p /etc/authelia -reflex -c /resources/reflex.conf \ No newline at end of file +# Sleep 10 seconds to wait the end of npm install updating web directory +# and making reflex reload multiple times. +sleep 10 + +reflex -c /resources/reflex.conf diff --git a/example/compose/nginx/backend/html/home/index.html b/example/compose/nginx/backend/html/home/index.html index a2cbf11e5..3838ef9f2 100644 --- a/example/compose/nginx/backend/html/home/index.html +++ b/example/compose/nginx/backend/html/home/index.html @@ -92,10 +92,10 @@ # Rules applied to 'admins' group - domain: 'mx2.mail.example.com' - subject: 'groups:admins' + subject: 'group:admins' policy: deny - domain: '*.example.com' - subject: 'groups:admins' + subject: 'group:admins' policy: two_factor # Rules applied to 'dev' group diff --git a/internal/configuration/test_resources/config.yml b/internal/configuration/test_resources/config.yml index 59e050d27..0877460b6 100644 --- a/internal/configuration/test_resources/config.yml +++ b/internal/configuration/test_resources/config.yml @@ -50,10 +50,10 @@ access_control: # Rules applied to 'admins' group - domain: "mx2.mail.example.com" - subject: "groups:admins" + subject: "group:admins" policy: deny - domain: "*.example.com" - subject: "groups:admins" + subject: "group:admins" policy: two_factor # Rules applied to 'dev' group diff --git a/internal/suites/action_2fa_methods.go b/internal/suites/action_2fa_methods.go index 17ccaca20..8b66742f6 100644 --- a/internal/suites/action_2fa_methods.go +++ b/internal/suites/action_2fa_methods.go @@ -8,5 +8,6 @@ import ( func (wds *WebDriverSession) doChangeMethod(ctx context.Context, t *testing.T, method string) { wds.WaitElementLocatedByID(ctx, t, "methods-button").Click() + wds.WaitElementLocatedByID(ctx, t, "methods-dialog") wds.WaitElementLocatedByID(ctx, t, fmt.Sprintf("%s-option", method)).Click() } diff --git a/internal/suites/scenario_user_preferences_test.go b/internal/suites/scenario_user_preferences_test.go index 7d4fd7321..5e86caf63 100644 --- a/internal/suites/scenario_user_preferences_test.go +++ b/internal/suites/scenario_user_preferences_test.go @@ -47,17 +47,13 @@ func (s *UserPreferencesScenario) SetupTest() { } func (s *UserPreferencesScenario) TestShouldRememberLastUsed2FAMethod() { - ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 40*time.Second) defer cancel() // Authenticate s.doLoginOneFactor(ctx, s.T(), "john", "password", false, "") s.verifyIsSecondFactorPage(ctx, s.T()) - // And select OTP method - s.doChangeMethod(ctx, s.T(), "one-time-password") - s.WaitElementLocatedByID(ctx, s.T(), "one-time-password-method") - // Then switch to push notification method s.doChangeMethod(ctx, s.T(), "push-notification") s.WaitElementLocatedByID(ctx, s.T(), "push-notification-method") diff --git a/internal/suites/suite_duo_push.go b/internal/suites/suite_duo_push.go index 1ecf46e4a..bed1dc7a7 100644 --- a/internal/suites/suite_duo_push.go +++ b/internal/suites/suite_duo_push.go @@ -49,7 +49,7 @@ func init() { SetUp: setup, SetUpTimeout: 5 * time.Minute, OnSetupTimeout: onSetupTimeout, - TestTimeout: 1 * time.Minute, + TestTimeout: 2 * time.Minute, TearDown: teardown, TearDownTimeout: 2 * time.Minute, diff --git a/web/src/views/LoginPortal/SecondFactor/MethodSelectionDialog.tsx b/web/src/views/LoginPortal/SecondFactor/MethodSelectionDialog.tsx index 565cff432..4257204f6 100644 --- a/web/src/views/LoginPortal/SecondFactor/MethodSelectionDialog.tsx +++ b/web/src/views/LoginPortal/SecondFactor/MethodSelectionDialog.tsx @@ -23,12 +23,11 @@ export default function (props: Props) { return ( - + {props.methods.has(SecondFactorMethod.TOTP) ?