MSP-1777 [v] after review#2
This commit is contained in:
1 parent
dfbc05cd7d
commit
1fa746c3e9
5 files changed
+23
-71
No files matched your search
@@ -2,14 +2,11 @@ package tests
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
etp "github.com/integration-system/isp-etp-go/v2"
|
||||
etpcli "github.com/integration-system/isp-etp-go/v2/client"
|
||||
@@ -144,14 +141,6 @@ func (s *HappyPathTestSuite) TestHttpProxy() {
|
||||
func (s *HappyPathTestSuite) TestWsProxy() { // nolint: funlen
|
||||
test, require := test.New(s.T())
|
||||
config, redisCli, systemCli, adminCli := s.commonDependencies(test)
|
||||
fName := "/tmp/TestWsProxy" + strconv.FormatInt(time.Now().Unix(), 10) + ".log"
|
||||
logger, _ := log.New(log.WithLevel(log.DebugLevel), log.WithFileRotation(log.Rotation{
|
||||
File: fName,
|
||||
MaxSizeMb: 1,
|
||||
MaxDays: 1,
|
||||
MaxBackups: 1,
|
||||
Compress: false,
|
||||
}))
|
||||
|
||||
requestId := requestid.Next()
|
||||
wsServer := etp.NewServer(context.Background(), etp.ServerConfig{
|
||||
@@ -177,7 +166,7 @@ func (s *HappyPathTestSuite) TestWsProxy() { // nolint: funlen
|
||||
require.NoError(err)
|
||||
rr := lb.NewRoundRobin([]string{targetUrl.Host})
|
||||
targetClients := map[string]*lb.RoundRobin{"target": rr}
|
||||
locator := assembly.NewLocator(logger, nil, targetClients, routes.NewRoutes(), systemCli, adminCli)
|
||||
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes.NewRoutes(), systemCli, adminCli)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/ws",
|
||||
@@ -208,30 +197,6 @@ func (s *HappyPathTestSuite) TestWsProxy() { // nolint: funlen
|
||||
require.EqualValues("world", string(resp))
|
||||
err = cli.Close()
|
||||
require.NoError(err)
|
||||
|
||||
requestUrl, err = url.Parse(srv.URL)
|
||||
require.NoError(err)
|
||||
requestUrl.Path = "ws/sevrice"
|
||||
requestUrl.RawQuery = url.Values{
|
||||
"x-application-token": []string{"token"},
|
||||
"x-auth-admin": []string{"mock-token"},
|
||||
}.Encode()
|
||||
err = cli.Dial(context.Background(), requestUrl.String())
|
||||
require.NoError(err)
|
||||
resp, err = cli.EmitWithAck(context.Background(), "hello", []byte("data"))
|
||||
require.NoError(err)
|
||||
require.EqualValues("world", string(resp))
|
||||
err = cli.Close()
|
||||
require.NoError(err)
|
||||
|
||||
time.Sleep(time.Second)
|
||||
|
||||
f, err := os.Open(fName)
|
||||
require.NoError(err)
|
||||
logBody, err := io.ReadAll(f)
|
||||
require.NoError(err)
|
||||
require.Contains(string(logBody), "ws/sevrice")
|
||||
require.NotContains(string(logBody), "ws/service")
|
||||
}
|
||||
|
||||
func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, redis.UniversalClient, *client.Client, *client.Client) {
|
||||
@@ -256,7 +221,7 @@ func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, r
|
||||
Redis: &conf.Redis{Address: redisCli.address},
|
||||
Http: conf.Http{MaxRequestBodySizeInMb: 1, ProxyTimeoutInSec: 15},
|
||||
Logging: conf.Logging{LogLevel: log.DebugLevel, RequestLogEnable: true, BodyLogEnable: true,
|
||||
Skip: []string{"endpoint", "ws.service"}},
|
||||
SkipBodyLoggingEndpointPrefixes: []string{"endpoint"}},
|
||||
Caching: conf.Caching{AuthorizationDataInSec: 1, AuthenticationDataInSec: 1},
|
||||
DailyLimits: []conf.DailyLimit{{ApplicationId: 1, RequestsPerDay: 100}},
|
||||
Throttling: []conf.Throttling{{ApplicationId: 1, RequestsPerSeconds: 100}},
|
||||
|
||||
Reference in new issue
Block a user