2019-11-02 14:32:58 +00:00
|
|
|
package suites
|
|
|
|
|
|
|
|
import (
|
2019-11-24 20:27:59 +00:00
|
|
|
"context"
|
|
|
|
"log"
|
2019-11-02 14:32:58 +00:00
|
|
|
"testing"
|
2019-11-24 20:27:59 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
2019-11-02 14:32:58 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type DuoPushSuite struct {
|
|
|
|
*SeleniumSuite
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDuoPushSuite() *DuoPushSuite {
|
|
|
|
return &DuoPushSuite{SeleniumSuite: new(SeleniumSuite)}
|
|
|
|
}
|
|
|
|
|
2019-11-24 20:27:59 +00:00
|
|
|
func (s *DuoPushSuite) SetupSuite() {
|
|
|
|
wds, err := StartWebDriver()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s.WebDriverSession = wds
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DuoPushSuite) TearDownSuite() {
|
|
|
|
err := s.WebDriverSession.Stop()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-30 16:49:52 +00:00
|
|
|
func (s *DuoPushSuite) SetupTest() {
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
s.doLogout(ctx, s.T())
|
|
|
|
}
|
|
|
|
|
2019-11-24 20:27:59 +00:00
|
|
|
func (s *DuoPushSuite) TearDownTest() {
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
s.doChangeMethod(ctx, s.T(), "one-time-password")
|
2019-11-30 16:49:52 +00:00
|
|
|
s.WaitElementLocatedByID(ctx, s.T(), "one-time-password-method")
|
2019-11-24 20:27:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DuoPushSuite) TestShouldSucceedAuthentication() {
|
2019-11-30 16:49:52 +00:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
2019-11-24 20:27:59 +00:00
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
ConfigureDuo(s.T(), Allow)
|
|
|
|
|
|
|
|
s.doLoginOneFactor(ctx, s.T(), "john", "password", false, "")
|
|
|
|
s.doChangeMethod(ctx, s.T(), "push-notification")
|
|
|
|
s.WaitElementLocatedByClassName(ctx, s.T(), "success-icon")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DuoPushSuite) TestShouldFailAuthentication() {
|
2019-11-30 16:49:52 +00:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
2019-11-24 20:27:59 +00:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2019-11-02 14:32:58 +00:00
|
|
|
func TestDuoPushSuite(t *testing.T) {
|
2019-11-24 20:27:59 +00:00
|
|
|
suite.Run(t, NewDuoPushSuite())
|
|
|
|
suite.Run(t, NewAvailableMethodsScenario([]string{
|
|
|
|
"ONE-TIME PASSWORD",
|
|
|
|
"PUSH NOTIFICATION",
|
|
|
|
}))
|
|
|
|
suite.Run(t, NewUserPreferencesScenario())
|
2019-11-02 14:32:58 +00:00
|
|
|
}
|