mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
683c4a70bf
* refactor(web): improve 2fa enrollment process This PR will change some of the wording and colours for the 2FA processes in order to provide more clarity and address some accessibility issues for end users. The following is a summary of the changes: * One-Time Password ⭢ Time-based One-Time Password * Security Key ⭢ Security Key - U2F ![Screenshot_2021-02-02-09-36-17](https://user-images.githubusercontent.com/3339418/107138185-17656100-6967-11eb-8fac-9e75c7a82d09.png) * QRCode ⭢ QR Code ![Screenshot_2021-02-07-05-07-25](https://user-images.githubusercontent.com/3339418/107138196-29df9a80-6967-11eb-811f-d77c9bb0159e.png) * `Not registered yet?` text to display `Lost device?` if a user has already registered a device of said type ![Screenshot_2021-02-02-10-24-54](https://user-images.githubusercontent.com/3339418/107138205-395ee380-6967-11eb-8826-83e1438dd146.png) * Change button and text colour in e-mails that Authelia generates * Change Authelia email footer to be more security conscious ![Screenshot_2021-02-07-04-51-40](https://user-images.githubusercontent.com/3339418/107138211-4085f180-6967-11eb-890b-9d931bd1ce76.png) The docs have also been updated to clarify the 2fa device enrollment limitation which only allows users to register one of each device type concurrently. Closes #1560.
150 lines
3.4 KiB
Go
150 lines
3.4 KiB
Go
package suites
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
type DuoPushWebDriverSuite struct {
|
|
*SeleniumSuite
|
|
}
|
|
|
|
func NewDuoPushWebDriverSuite() *DuoPushWebDriverSuite {
|
|
return &DuoPushWebDriverSuite{SeleniumSuite: new(SeleniumSuite)}
|
|
}
|
|
|
|
func (s *DuoPushWebDriverSuite) SetupSuite() {
|
|
wds, err := StartWebDriver()
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
s.WebDriverSession = wds
|
|
}
|
|
|
|
func (s *DuoPushWebDriverSuite) TearDownSuite() {
|
|
err := s.WebDriverSession.Stop()
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func (s *DuoPushWebDriverSuite) SetupTest() {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
defer cancel()
|
|
|
|
s.doLogout(ctx, s.T())
|
|
}
|
|
|
|
func (s *DuoPushWebDriverSuite) TearDownTest() {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
defer cancel()
|
|
|
|
s.doLogout(ctx, s.T())
|
|
s.doLoginOneFactor(ctx, s.T(), "john", "password", false, "")
|
|
s.verifyIsSecondFactorPage(ctx, s.T())
|
|
s.doChangeMethod(ctx, s.T(), "one-time-password")
|
|
s.WaitElementLocatedByID(ctx, s.T(), "one-time-password-method")
|
|
}
|
|
|
|
func (s *DuoPushWebDriverSuite) TestShouldSucceedAuthentication() {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
|
defer cancel()
|
|
|
|
ConfigureDuo(s.T(), Allow)
|
|
|
|
s.doLoginOneFactor(ctx, s.T(), "john", "password", false, "")
|
|
s.doChangeMethod(ctx, s.T(), "push-notification")
|
|
s.verifyIsHome(ctx, s.T())
|
|
}
|
|
|
|
func (s *DuoPushWebDriverSuite) TestShouldFailAuthentication() {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
|
defer cancel()
|
|
|
|
ConfigureDuo(s.T(), Deny)
|
|
|
|
s.doLoginOneFactor(ctx, s.T(), "john", "password", false, "")
|
|
s.doChangeMethod(ctx, s.T(), "push-notification")
|
|
s.WaitElementLocatedByClassName(ctx, s.T(), "failure-icon")
|
|
}
|
|
|
|
type DuoPushDefaultRedirectionSuite struct {
|
|
*SeleniumSuite
|
|
}
|
|
|
|
func NewDuoPushDefaultRedirectionSuite() *DuoPushDefaultRedirectionSuite {
|
|
return &DuoPushDefaultRedirectionSuite{SeleniumSuite: new(SeleniumSuite)}
|
|
}
|
|
|
|
func (s *DuoPushDefaultRedirectionSuite) SetupSuite() {
|
|
wds, err := StartWebDriver()
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
s.WebDriverSession = wds
|
|
}
|
|
|
|
func (s *DuoPushDefaultRedirectionSuite) TearDownSuite() {
|
|
err := s.WebDriverSession.Stop()
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func (s *DuoPushDefaultRedirectionSuite) SetupTest() {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
defer cancel()
|
|
|
|
s.doLogout(ctx, s.T())
|
|
}
|
|
|
|
func (s *DuoPushDefaultRedirectionSuite) TestUserIsRedirectedToDefaultURL() {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
|
defer cancel()
|
|
|
|
s.doLoginOneFactor(ctx, s.T(), "john", "password", false, "")
|
|
s.doChangeMethod(ctx, s.T(), "push-notification")
|
|
s.verifyURLIs(ctx, s.T(), HomeBaseURL+"/")
|
|
}
|
|
|
|
type DuoPushSuite struct {
|
|
suite.Suite
|
|
}
|
|
|
|
func NewDuoPushSuite() *DuoPushSuite {
|
|
return &DuoPushSuite{}
|
|
}
|
|
|
|
func (s *DuoPushSuite) TestDuoPushWebDriverSuite() {
|
|
suite.Run(s.T(), NewDuoPushWebDriverSuite())
|
|
}
|
|
|
|
func (s *DuoPushSuite) TestDuoPushRedirectionURLSuite() {
|
|
suite.Run(s.T(), NewDuoPushDefaultRedirectionSuite())
|
|
}
|
|
|
|
func (s *DuoPushSuite) TestAvailableMethodsScenario() {
|
|
suite.Run(s.T(), NewAvailableMethodsScenario([]string{
|
|
"TIME-BASED ONE-TIME PASSWORD",
|
|
"PUSH NOTIFICATION",
|
|
}))
|
|
}
|
|
|
|
func (s *DuoPushSuite) TestUserPreferencesScenario() {
|
|
suite.Run(s.T(), NewUserPreferencesScenario())
|
|
}
|
|
|
|
func TestDuoPushSuite(t *testing.T) {
|
|
suite.Run(t, NewDuoPushSuite())
|
|
}
|