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
|
|
|
)
|
|
|
|
|
|
|
|
type BypassAllSuite struct {
|
|
|
|
*SeleniumSuite
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewBypassAllSuite() *BypassAllSuite {
|
|
|
|
return &BypassAllSuite{SeleniumSuite: new(SeleniumSuite)}
|
|
|
|
}
|
|
|
|
|
2019-11-25 03:27:59 +07:00
|
|
|
func (s *BypassAllSuite) SetupSuite() {
|
|
|
|
wds, err := StartWebDriver()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s.WebDriverSession = wds
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *BypassAllSuite) TearDownSuite() {
|
|
|
|
err := s.WebDriverSession.Stop()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *BypassAllSuite) TestShouldAccessPublicResource() {
|
|
|
|
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-11-02 21:32:58 +07:00
|
|
|
func TestBypassAllSuite(t *testing.T) {
|
2019-11-25 03:27:59 +07:00
|
|
|
suite.Run(t, NewBypassAllSuite())
|
|
|
|
suite.Run(t, NewCustomHeadersScenario())
|
2019-11-02 21:32:58 +07:00
|
|
|
}
|