2019-11-02 21:32:58 +07:00
|
|
|
package suites
|
|
|
|
|
|
|
|
import (
|
2019-11-25 03:27:59 +07:00
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2019-11-02 21:32:58 +07:00
|
|
|
"testing"
|
2019-11-25 03:27:59 +07:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
2019-11-02 21:32:58 +07:00
|
|
|
)
|
|
|
|
|
2019-12-06 04:35:03 +07:00
|
|
|
type BypassAllWebDriverSuite struct {
|
2019-11-02 21:32:58 +07:00
|
|
|
*SeleniumSuite
|
|
|
|
}
|
|
|
|
|
2019-12-06 04:35:03 +07:00
|
|
|
func NewBypassAllWebDriverSuite() *BypassAllWebDriverSuite {
|
|
|
|
return &BypassAllWebDriverSuite{SeleniumSuite: new(SeleniumSuite)}
|
2019-11-02 21:32:58 +07:00
|
|
|
}
|
|
|
|
|
2019-12-06 04:35:03 +07:00
|
|
|
func (s *BypassAllWebDriverSuite) SetupSuite() {
|
2019-11-25 03:27:59 +07:00
|
|
|
wds, err := StartWebDriver()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s.WebDriverSession = wds
|
|
|
|
}
|
|
|
|
|
2019-12-06 04:35:03 +07:00
|
|
|
func (s *BypassAllWebDriverSuite) TearDownSuite() {
|
2019-11-25 03:27:59 +07:00
|
|
|
err := s.WebDriverSession.Stop()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-06 04:35:03 +07:00
|
|
|
func (s *BypassAllWebDriverSuite) TestShouldAccessPublicResource() {
|
2019-11-25 03:27:59 +07:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
s.doVisit(s.T(), fmt.Sprintf("%s/secret.html", AdminBaseURL))
|
|
|
|
s.verifySecretAuthorized(ctx, s.T())
|
|
|
|
|
|
|
|
s.doVisit(s.T(), fmt.Sprintf("%s/secret.html", PublicBaseURL))
|
|
|
|
s.verifySecretAuthorized(ctx, s.T())
|
|
|
|
}
|
|
|
|
|
2019-12-06 04:35:03 +07:00
|
|
|
type BypassAllSuite struct {
|
|
|
|
suite.Suite
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewBypassAllSuite() *BypassAllSuite {
|
|
|
|
return &BypassAllSuite{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *BypassAllSuite) TestBypassAllWebDriverSuite() {
|
|
|
|
suite.Run(s.T(), NewBypassAllWebDriverSuite())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *BypassAllSuite) TestCustomHeadersScenario() {
|
|
|
|
suite.Run(s.T(), NewCustomHeadersScenario())
|
|
|
|
}
|
|
|
|
|
2019-11-02 21:32:58 +07:00
|
|
|
func TestBypassAllSuite(t *testing.T) {
|
2021-03-14 14:08:26 +07:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skipping suite test in short mode")
|
|
|
|
}
|
|
|
|
|
2019-11-25 03:27:59 +07:00
|
|
|
suite.Run(t, NewBypassAllSuite())
|
2019-11-02 21:32:58 +07:00
|
|
|
}
|