Skip to content

Commit

Permalink
Fix broken tests (TykTechnologies#2483)
Browse files Browse the repository at this point in the history
  • Loading branch information
furkansenharputlu authored and buger committed Sep 3, 2019
1 parent 2a5ddcc commit 2a37a6e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gateway/host_checker.go
Expand Up @@ -11,7 +11,7 @@ import (
"time"

"github.com/jeffail/tunny"
"github.com/pires/go-proxyproto"
proxyproto "github.com/pires/go-proxyproto"
cache "github.com/pmylund/go-cache"

"github.com/TykTechnologies/tyk/apidef"
Expand Down
6 changes: 1 addition & 5 deletions gateway/mw_jwt_test.go
Expand Up @@ -419,7 +419,6 @@ func TestJWTSessionRSABearerInvalidTwoBears(t *testing.T) {

func prepareJWTSessionRSAWithRawSourceOnWithClientID(isBench bool) string {
spec := BuildAndLoadAPI(func(spec *APISpec) {
spec.APIID = "777888"
spec.OrgID = "default"
spec.UseKeylessAccess = false
spec.EnableJWT = true
Expand Down Expand Up @@ -1094,9 +1093,6 @@ func TestJWTExistingSessionRSAWithRawSourcePolicyIDChanged(t *testing.T) {
})
user_id := uuid.New()

t.Log(p1ID)
t.Log(p2ID)

jwtToken := CreateJWKToken(func(t *jwt.Token) {
t.Header["kid"] = "12345"
t.Claims.(jwt.MapClaims)["foo"] = "bar"
Expand All @@ -1105,7 +1101,7 @@ func TestJWTExistingSessionRSAWithRawSourcePolicyIDChanged(t *testing.T) {
t.Claims.(jwt.MapClaims)["exp"] = time.Now().Add(time.Hour * 72).Unix()
})

sessionID := generateToken("default", fmt.Sprintf("%x", md5.Sum([]byte("user"))))
sessionID := generateToken("default", fmt.Sprintf("%x", md5.Sum([]byte(user_id))))

authHeaders := map[string]string{"authorization": jwtToken}
t.Run("Initial request with 1st policy", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion gateway/proxy_muxer.go
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/TykTechnologies/again"
"github.com/TykTechnologies/tyk/config"
"github.com/TykTechnologies/tyk/tcp"
"github.com/pires/go-proxyproto"
proxyproto "github.com/pires/go-proxyproto"
cache "github.com/pmylund/go-cache"

"golang.org/x/net/http2"
Expand Down
7 changes: 1 addition & 6 deletions gateway/proxy_muxer_test.go
Expand Up @@ -2,16 +2,13 @@ package gateway

import (
"encoding/json"
"io/ioutil"
"net"
"net/http"
"net/http/httptest"
"reflect"
"strconv"
"sync/atomic"
"testing"

"github.com/TykTechnologies/tyk/config"
)

func TestTCPDial_with_service_discovery(t *testing.T) {
Expand Down Expand Up @@ -102,9 +99,7 @@ func TestTCPDial_with_service_discovery(t *testing.T) {
spec.ListenPort = p
spec.Proxy.TargetURL = service1.Addr().String()
})
g := config.Global()
b, _ := json.Marshal(g)
ioutil.WriteFile("config.json", b, 0600)

e := "service1"
var result []string

Expand Down
2 changes: 1 addition & 1 deletion gateway/testutil.go
Expand Up @@ -419,6 +419,7 @@ func CreateStandardSession() *user.SessionState {

func CreateStandardPolicy() *user.Policy {
return &user.Policy{
OrgID: "default",
Rate: 1000.0,
Per: 1.0,
QuotaMax: -1,
Expand All @@ -433,7 +434,6 @@ func CreatePolicy(pGen ...func(p *user.Policy)) string {
pID := keyGen.GenerateAuthKey("")
pol := CreateStandardPolicy()
pol.ID = pID
pol.OrgID = "default"

if len(pGen) > 0 {
pGen[0](pol)
Expand Down

0 comments on commit 2a37a6e

Please sign in to comment.