mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
a991379a74
Some tests are not fully rewritten in Go, a typescript wrapper is called instead until we remove the remaining TS tests and dependencies. Also, dockerize every components (mainly Authelia backend, frontend and kind) so that the project does not interfere with user host anymore (open ports for instance). The only remaining intrusive change is the one done during bootstrap to add entries in /etc/hosts. It will soon be avoided using authelia.com domain that I own.
66 lines
1.3 KiB
Go
66 lines
1.3 KiB
Go
package suites
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
type TwoFactorSuite struct {
|
|
*SeleniumSuite
|
|
}
|
|
|
|
func NewTwoFactorSuite() *TwoFactorSuite {
|
|
return &TwoFactorSuite{
|
|
SeleniumSuite: new(SeleniumSuite),
|
|
}
|
|
}
|
|
|
|
func (s *TwoFactorSuite) SetupSuite() {
|
|
wds, err := StartWebDriver()
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
s.SeleniumSuite.WebDriverSession = wds
|
|
}
|
|
|
|
func (s *TwoFactorSuite) TearDownSuite() {
|
|
err := s.WebDriverSession.Stop()
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func (s *TwoFactorSuite) SetupTest() {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
defer cancel()
|
|
|
|
doLogout(ctx, s.SeleniumSuite)
|
|
doVisit(s.SeleniumSuite, HomeBaseURL)
|
|
verifyURLIs(ctx, s.SeleniumSuite, HomeBaseURL)
|
|
}
|
|
|
|
func (s *TwoFactorSuite) TestShouldAuthorizeSecretAfterTwoFactor() {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
defer cancel()
|
|
|
|
// Register TOTP secret and logout.
|
|
secret := doRegisterThenLogout(ctx, s.SeleniumSuite, "john", "password")
|
|
|
|
targetURL := fmt.Sprintf("%s/secret.html", AdminBaseURL)
|
|
doLoginTwoFactor(ctx, s.SeleniumSuite, "john", "password", false, secret, targetURL)
|
|
|
|
verifySecretAuthorized(ctx, s.SeleniumSuite)
|
|
}
|
|
|
|
func TestRunTwoFactor(t *testing.T) {
|
|
suite.Run(t, NewTwoFactorSuite())
|
|
}
|