snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
244
server/tests/apigw/main_test.go
Normal file
244
server/tests/apigw/main_test.go
Normal file
@@ -0,0 +1,244 @@
|
||||
package apigw
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/apigw/types"
|
||||
"github.com/cortezaproject/corteza/server/pkg/dal"
|
||||
"github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers/sqlite"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/app"
|
||||
as "github.com/cortezaproject/corteza/server/automation/service"
|
||||
"github.com/cortezaproject/corteza/server/pkg/api/server"
|
||||
"github.com/cortezaproject/corteza/server/pkg/apigw"
|
||||
"github.com/cortezaproject/corteza/server/pkg/auth"
|
||||
"github.com/cortezaproject/corteza/server/pkg/cli"
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoy"
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoy/csv"
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoy/directory"
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoy/resource"
|
||||
es "github.com/cortezaproject/corteza/server/pkg/envoy/store"
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoy/yaml"
|
||||
"github.com/cortezaproject/corteza/server/pkg/eventbus"
|
||||
"github.com/cortezaproject/corteza/server/pkg/id"
|
||||
"github.com/cortezaproject/corteza/server/pkg/label"
|
||||
ltype "github.com/cortezaproject/corteza/server/pkg/label/types"
|
||||
"github.com/cortezaproject/corteza/server/pkg/logger"
|
||||
"github.com/cortezaproject/corteza/server/store"
|
||||
"github.com/cortezaproject/corteza/server/system/rest"
|
||||
"github.com/cortezaproject/corteza/server/system/service"
|
||||
sysTypes "github.com/cortezaproject/corteza/server/system/types"
|
||||
"github.com/cortezaproject/corteza/server/tests/helpers"
|
||||
"github.com/go-chi/chi/v5"
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
"github.com/steinfletcher/apitest"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type (
|
||||
helper struct {
|
||||
t *testing.T
|
||||
a *require.Assertions
|
||||
|
||||
cUser *sysTypes.User
|
||||
roleID uint64
|
||||
token []byte
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
testApp *app.CortezaApp
|
||||
r chi.Router
|
||||
|
||||
eventBus = eventbus.New()
|
||||
)
|
||||
|
||||
func init() {
|
||||
helpers.RecursiveDotEnvLoad()
|
||||
}
|
||||
|
||||
func InitTestApp() {
|
||||
ctx := cli.Context()
|
||||
|
||||
if testApp == nil {
|
||||
testApp = helpers.NewIntegrationTestApp(ctx, func(app *app.CortezaApp) (err error) {
|
||||
service.DefaultStore, err = sqlite.ConnectInMemory(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
eventbus.Set(eventBus)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
if err := testApp.Activate(ctx); err != nil {
|
||||
panic(fmt.Errorf("could not activate corteza: %v", err))
|
||||
}
|
||||
|
||||
if r == nil {
|
||||
r = chi.NewRouter()
|
||||
r.Use(server.BaseMiddleware(false, logger.Default())...)
|
||||
helpers.BindAuthMiddleware(r)
|
||||
|
||||
// Sys routes for route management tests
|
||||
r.Group(rest.MountRoutes())
|
||||
|
||||
// API gw routes
|
||||
apigw.Setup(types.Config{Enabled: true, Profiler: struct {
|
||||
Enabled bool
|
||||
Global bool
|
||||
}{Enabled: true, Global: true}}, service.DefaultLogger, service.DefaultStore)
|
||||
err := apigw.Service().Reload(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
r.Handle("/*", apigw.Service())
|
||||
}
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
InitTestApp()
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func newHelper(t *testing.T) helper {
|
||||
h := helper{
|
||||
t: t,
|
||||
a: require.New(t),
|
||||
roleID: id.Next(),
|
||||
cUser: &sysTypes.User{
|
||||
ID: id.Next(),
|
||||
},
|
||||
}
|
||||
|
||||
h.cUser.SetRoles(h.roleID)
|
||||
helpers.UpdateRBAC(h.roleID)
|
||||
|
||||
var err error
|
||||
ctx := context.Background()
|
||||
h.token, err = auth.TokenIssuer.Issue(ctx, auth.WithIdentity(h.cUser))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return h
|
||||
}
|
||||
|
||||
func (h helper) MyRole() uint64 {
|
||||
return h.roleID
|
||||
}
|
||||
|
||||
// Returns context w/ security details
|
||||
func (h helper) secCtx() context.Context {
|
||||
return auth.SetIdentityToContext(context.Background(), h.cUser)
|
||||
}
|
||||
|
||||
// apitest basics, initialize, set handler, add auth
|
||||
func (h helper) apiInit() *apitest.APITest {
|
||||
InitTestApp()
|
||||
|
||||
return apitest.
|
||||
New().
|
||||
Handler(r).
|
||||
Intercept(helpers.ReqHeaderRawAuthBearer(h.token))
|
||||
|
||||
}
|
||||
|
||||
func setupScenario(t *testing.T) (context.Context, helper, store.Storer) {
|
||||
ctx, h, s := setup(t)
|
||||
loadScenario(ctx, s, t, h)
|
||||
loadRbacRules(ctx, s, t, h)
|
||||
_ = apigw.Service().Reload(ctx)
|
||||
|
||||
return ctx, h, s
|
||||
}
|
||||
|
||||
func loadRbacRules(ctx context.Context, s store.Storer, t *testing.T, h helper) {
|
||||
helpers.AllowMeWorkflowSearch(h)
|
||||
}
|
||||
|
||||
func setup(t *testing.T) (context.Context, helper, store.Storer) {
|
||||
h := newHelper(t)
|
||||
s := service.DefaultStore
|
||||
|
||||
u := &sysTypes.User{
|
||||
ID: id.Next(),
|
||||
}
|
||||
|
||||
u.SetRoles(auth.BypassRoles().IDs()...)
|
||||
|
||||
ctx := auth.SetIdentityToContext(context.Background(), u)
|
||||
return ctx, h, s
|
||||
}
|
||||
|
||||
// Unwraps error before it passes it to the tester
|
||||
func (h helper) noError(err error) {
|
||||
for errors.Unwrap(err) != nil {
|
||||
err = errors.Unwrap(err)
|
||||
}
|
||||
|
||||
h.a.NoError(err)
|
||||
}
|
||||
|
||||
func (h helper) setLabel(res label.LabeledResource, name, value string) {
|
||||
h.a.NoError(store.UpsertLabel(h.secCtx(), service.DefaultStore, <ype.Label{
|
||||
Kind: res.LabelResourceKind(),
|
||||
ResourceID: res.LabelResourceID(),
|
||||
Name: name,
|
||||
Value: ltype.LabelValue{Val: value},
|
||||
}))
|
||||
}
|
||||
|
||||
func loadScenario(ctx context.Context, s store.Storer, t *testing.T, h helper) {
|
||||
loadScenarioWithName(ctx, s, t, h, t.Name()[5:])
|
||||
}
|
||||
|
||||
func loadScenarioWithName(ctx context.Context, s store.Storer, t *testing.T, h helper, scenario string) {
|
||||
cleanup(ctx, h, s)
|
||||
parseEnvoy(ctx, s, h, path.Join("testdata", scenario))
|
||||
loadWorkflows(ctx, h)
|
||||
}
|
||||
|
||||
func loadWorkflows(ctx context.Context, h helper) {
|
||||
err := as.DefaultWorkflow.Load(ctx)
|
||||
h.a.NoError(err)
|
||||
}
|
||||
|
||||
func cleanup(ctx context.Context, h helper, s store.Storer) {
|
||||
h.noError(s.TruncateApigwFilters(ctx))
|
||||
h.noError(s.TruncateApigwRoutes(ctx))
|
||||
h.noError(s.TruncateRbacRules(ctx))
|
||||
h.noError(s.TruncateAutomationTriggers(ctx))
|
||||
h.noError(s.TruncateAutomationWorkflows(ctx))
|
||||
}
|
||||
|
||||
func parseEnvoy(ctx context.Context, s store.Storer, h helper, path string) {
|
||||
nn, err := directory.Decode(
|
||||
ctx,
|
||||
path,
|
||||
yaml.Decoder(),
|
||||
csv.Decoder(),
|
||||
)
|
||||
if err != nil {
|
||||
h.t.Fatalf("failed to decode scenario data: %v", err)
|
||||
}
|
||||
|
||||
crs := resource.ComposeRecordShaper()
|
||||
nn, err = resource.Shape(nn, crs)
|
||||
h.a.NoError(err)
|
||||
|
||||
// import into the store
|
||||
se := es.NewStoreEncoder(s, dal.Service(), nil)
|
||||
bld := envoy.NewBuilder(se)
|
||||
g, err := bld.Build(ctx, nn...)
|
||||
h.a.NoError(err)
|
||||
err = envoy.Encode(ctx, g, se)
|
||||
h.a.NoError(err)
|
||||
}
|
||||
20
server/tests/apigw/postfilter_string_json_test.go
Normal file
20
server/tests/apigw/postfilter_string_json_test.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package apigw
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_postfilter_string_json(t *testing.T) {
|
||||
var (
|
||||
_, h, _ = setupScenario(t)
|
||||
)
|
||||
|
||||
h.apiInit().
|
||||
Get("/json/string").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Body("{\"baz\":{\"@value\":{\"1\":{\"@value\":1,\"@type\":\"Float\"},\"2\":{\"@value\":2,\"@type\":\"Float\"}},\"@type\":\"Vars\"},\"foo\":{\"@value\":\"bar\",\"@type\":\"String\"}}").
|
||||
End()
|
||||
}
|
||||
20
server/tests/apigw/postfilter_string_kv_test.go
Normal file
20
server/tests/apigw/postfilter_string_kv_test.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package apigw
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_postfilter_string_kv(t *testing.T) {
|
||||
var (
|
||||
_, h, _ = setupScenario(t)
|
||||
)
|
||||
|
||||
h.apiInit().
|
||||
Get("/json/kv").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Body("{\"baz\":\"123\",\"foo\":\"bar\"}").
|
||||
End()
|
||||
}
|
||||
28
server/tests/apigw/prefilter_header_failing_test.go
Normal file
28
server/tests/apigw/prefilter_header_failing_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package apigw
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_prefilter_header_failing(t *testing.T) {
|
||||
var (
|
||||
_, h, _ = setupScenario(t)
|
||||
)
|
||||
|
||||
h.apiInit().
|
||||
Get("/test").
|
||||
Header("Accept", "application/json").
|
||||
Header("Token", "brute-force-guess").
|
||||
Expect(t).
|
||||
Status(http.StatusBadRequest).
|
||||
End()
|
||||
|
||||
h.apiInit().
|
||||
Get("/test-hyphen").
|
||||
Header("Accept-Language", "fr-CH, fr;q=0.9").
|
||||
Header("Token", "brute-force-guess").
|
||||
Expect(t).
|
||||
Status(http.StatusBadRequest).
|
||||
End()
|
||||
}
|
||||
46
server/tests/apigw/prefilter_header_n_routes_test.go
Normal file
46
server/tests/apigw/prefilter_header_n_routes_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package apigw
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_prefilter_header_n_routes(t *testing.T) {
|
||||
var (
|
||||
_, h, _ = setupScenario(t)
|
||||
)
|
||||
|
||||
// First (a) route query validation
|
||||
h.apiInit().
|
||||
Get("/a").
|
||||
Header("P", "a").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
End()
|
||||
|
||||
h.apiInit().
|
||||
Get("/a").
|
||||
Header("P", "b").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusBadRequest).
|
||||
End()
|
||||
|
||||
// Second (b) route query validation
|
||||
h.apiInit().
|
||||
Get("/b").
|
||||
Header("P", "b").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
End()
|
||||
|
||||
h.apiInit().
|
||||
Get("/b").
|
||||
Header("P", "a").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusBadRequest).
|
||||
End()
|
||||
}
|
||||
28
server/tests/apigw/prefilter_header_passing_test.go
Normal file
28
server/tests/apigw/prefilter_header_passing_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package apigw
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_prefilter_header_passing(t *testing.T) {
|
||||
var (
|
||||
_, h, _ = setupScenario(t)
|
||||
)
|
||||
|
||||
h.apiInit().
|
||||
Get("/test").
|
||||
Header("Accept", "application/json").
|
||||
Header("Token", "super-secret-token").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
End()
|
||||
|
||||
h.apiInit().
|
||||
Get("/test-hyphen").
|
||||
Header("Accept-Language", "fr-CH, fr;q=0.9").
|
||||
Header("Token", "super-secret-token").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
End()
|
||||
}
|
||||
28
server/tests/apigw/prefilter_query_failing_test.go
Normal file
28
server/tests/apigw/prefilter_query_failing_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package apigw
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_prefilter_query_failing(t *testing.T) {
|
||||
var (
|
||||
_, h, _ = setupScenario(t)
|
||||
)
|
||||
|
||||
h.apiInit().
|
||||
Get("/test").
|
||||
Query("token", "brute-force-guess").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusBadRequest).
|
||||
End()
|
||||
|
||||
h.apiInit().
|
||||
Get("/test-hyphen").
|
||||
Query("foo-bar", "encrypted-string").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusBadRequest).
|
||||
End()
|
||||
}
|
||||
46
server/tests/apigw/prefilter_query_n_routes_test.go
Normal file
46
server/tests/apigw/prefilter_query_n_routes_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package apigw
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_prefilter_query_n_routes(t *testing.T) {
|
||||
var (
|
||||
_, h, _ = setupScenario(t)
|
||||
)
|
||||
|
||||
// First (a) route query validation
|
||||
h.apiInit().
|
||||
Get("/a").
|
||||
Query("p", "a").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
End()
|
||||
|
||||
h.apiInit().
|
||||
Get("/a").
|
||||
Query("p", "b").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusBadRequest).
|
||||
End()
|
||||
|
||||
// Second (b) route query validation
|
||||
h.apiInit().
|
||||
Get("/b").
|
||||
Query("p", "b").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
End()
|
||||
|
||||
h.apiInit().
|
||||
Get("/b").
|
||||
Query("p", "a").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusBadRequest).
|
||||
End()
|
||||
}
|
||||
28
server/tests/apigw/prefilter_query_passing_test.go
Normal file
28
server/tests/apigw/prefilter_query_passing_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package apigw
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_prefilter_query_passing(t *testing.T) {
|
||||
var (
|
||||
_, h, _ = setupScenario(t)
|
||||
)
|
||||
|
||||
h.apiInit().
|
||||
Get("/test").
|
||||
Query("token", "super-secret-token").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
End()
|
||||
|
||||
h.apiInit().
|
||||
Get("/test-hyphen").
|
||||
Query("foo-bar", "encrypted-string").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
End()
|
||||
}
|
||||
21
server/tests/apigw/processing_payload_simple_test.go
Normal file
21
server/tests/apigw/processing_payload_simple_test.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package apigw
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_processor_payload_simple(t *testing.T) {
|
||||
var (
|
||||
_, h, _ = setupScenario(t)
|
||||
)
|
||||
|
||||
h.apiInit().
|
||||
Get("/test").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Body("60").
|
||||
End()
|
||||
|
||||
}
|
||||
65
server/tests/apigw/route_reload_test.go
Normal file
65
server/tests/apigw/route_reload_test.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package apigw
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/store"
|
||||
"github.com/cortezaproject/corteza/server/tests/helpers"
|
||||
)
|
||||
|
||||
func Test_route_reload(t *testing.T) {
|
||||
var (
|
||||
ctx, h, s = setupScenario(t)
|
||||
)
|
||||
|
||||
r, err := store.LookupApigwRouteByEndpoint(ctx, s, "/test")
|
||||
h.a.NoError(err)
|
||||
|
||||
h.apiInit().
|
||||
Get("/test").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Body("60").
|
||||
End()
|
||||
|
||||
helpers.AllowMe(h, r.RbacResource(), "update")
|
||||
h.apiInit().
|
||||
Put(fmt.Sprintf("/apigw/route/%d", r.ID)).
|
||||
Header("Accept", "application/json").
|
||||
FormData("endpoint", "/test").
|
||||
FormData("method", "GET").
|
||||
FormData("enabled", "false").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
|
||||
h.apiInit().
|
||||
Get("/test").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusNotFound).
|
||||
End()
|
||||
|
||||
h.apiInit().
|
||||
Put(fmt.Sprintf("/apigw/route/%d", r.ID)).
|
||||
Header("Accept", "application/json").
|
||||
FormData("endpoint", "/test").
|
||||
FormData("method", "GET").
|
||||
FormData("enabled", "true").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
|
||||
h.apiInit().
|
||||
Get("/test").
|
||||
Header("Accept", "application/json").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Body("60").
|
||||
End()
|
||||
}
|
||||
38
server/tests/apigw/testdata/postfilter_string_json/def.yaml
vendored
Normal file
38
server/tests/apigw/testdata/postfilter_string_json/def.yaml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
apigateway:
|
||||
- endpoint: /json/string
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: response
|
||||
kind: postfilter
|
||||
enabled: true
|
||||
params:
|
||||
input:
|
||||
expr: toJSON(test)
|
||||
type: String
|
||||
header:
|
||||
Content-Type: [ application/json ]
|
||||
- ref: workflow
|
||||
kind: processer
|
||||
enabled: true
|
||||
params:
|
||||
workflow: 'test_variable_json'
|
||||
|
||||
workflows:
|
||||
- id: 1
|
||||
enabled: true
|
||||
trace: false
|
||||
handle: test_variable_json
|
||||
meta:
|
||||
name: Test variable
|
||||
triggers:
|
||||
- enabled: true
|
||||
stepID: 1
|
||||
steps:
|
||||
- stepID: 1
|
||||
kind: expressions
|
||||
arguments:
|
||||
- target: test
|
||||
type: Any
|
||||
expr: |
|
||||
{"foo":"bar","baz":{"1":1, "2":2}}
|
||||
38
server/tests/apigw/testdata/postfilter_string_kv/def.yaml
vendored
Normal file
38
server/tests/apigw/testdata/postfilter_string_kv/def.yaml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
apigateway:
|
||||
- endpoint: /json/kv
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: response
|
||||
kind: postfilter
|
||||
enabled: true
|
||||
params:
|
||||
input:
|
||||
expr: test
|
||||
type: KV
|
||||
header:
|
||||
Content-Type: [ application/json ]
|
||||
- ref: workflow
|
||||
kind: processer
|
||||
enabled: true
|
||||
params:
|
||||
workflow: 'test_variable_kv'
|
||||
|
||||
workflows:
|
||||
- id: 1
|
||||
enabled: true
|
||||
trace: false
|
||||
handle: test_variable_kv
|
||||
meta:
|
||||
name: Test variable
|
||||
triggers:
|
||||
- enabled: true
|
||||
stepID: 1
|
||||
steps:
|
||||
- stepID: 1
|
||||
kind: expressions
|
||||
arguments:
|
||||
- target: test
|
||||
type: KV
|
||||
expr: |
|
||||
{"foo":"bar","baz":123}
|
||||
20
server/tests/apigw/testdata/prefilter_header_failing/def.yaml
vendored
Normal file
20
server/tests/apigw/testdata/prefilter_header_failing/def.yaml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
apigateway:
|
||||
- endpoint: /test
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "header"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "Token == \"super-secret-token\""
|
||||
|
||||
- endpoint: /test-hyphen
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "header"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "Accept-Language == \"fr-CH, fr;q=0.9\""
|
||||
20
server/tests/apigw/testdata/prefilter_header_n_routes/def.yaml
vendored
Normal file
20
server/tests/apigw/testdata/prefilter_header_n_routes/def.yaml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
apigateway:
|
||||
- endpoint: /a
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "header"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "P == \"a\""
|
||||
|
||||
- endpoint: /b
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "header"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "P == \"b\""
|
||||
20
server/tests/apigw/testdata/prefilter_header_passing/def.yaml
vendored
Normal file
20
server/tests/apigw/testdata/prefilter_header_passing/def.yaml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
apigateway:
|
||||
- endpoint: /test
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "header"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "Token == \"super-secret-token\""
|
||||
|
||||
- endpoint: /test-hyphen
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "header"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "headers[\"Accept-Language\"] == \"fr-CH, fr;q=0.9\""
|
||||
21
server/tests/apigw/testdata/prefilter_query_failing/def.yaml
vendored
Normal file
21
server/tests/apigw/testdata/prefilter_query_failing/def.yaml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
apigateway:
|
||||
- endpoint: /test
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "queryParam"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "token == \"super-secret-token\""
|
||||
|
||||
- endpoint: /test-hyphen
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "queryParam"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "foo-bar == \"encrypted-string\""
|
||||
|
||||
20
server/tests/apigw/testdata/prefilter_query_n_routes/def.yaml
vendored
Normal file
20
server/tests/apigw/testdata/prefilter_query_n_routes/def.yaml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
apigateway:
|
||||
- endpoint: /a
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "queryParam"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "p == \"a\""
|
||||
|
||||
- endpoint: /b
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "queryParam"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "p == \"b\""
|
||||
20
server/tests/apigw/testdata/prefilter_query_passing/def.yaml
vendored
Normal file
20
server/tests/apigw/testdata/prefilter_query_passing/def.yaml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
apigateway:
|
||||
- endpoint: /test
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "queryParam"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "token == \"super-secret-token\""
|
||||
|
||||
- endpoint: /test-hyphen
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "queryParam"
|
||||
kind: "prefilter"
|
||||
enabled: true
|
||||
params:
|
||||
expr: "params[\"foo-bar\"] == \"encrypted-string\""
|
||||
15
server/tests/apigw/testdata/processor_payload_simple/def.yaml
vendored
Normal file
15
server/tests/apigw/testdata/processor_payload_simple/def.yaml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
apigateway:
|
||||
- endpoint: /test
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "payload"
|
||||
kind: "processer"
|
||||
enabled: true
|
||||
params:
|
||||
jsfunc: |
|
||||
const x = 10;
|
||||
const y = 20;
|
||||
const z = x + y;
|
||||
|
||||
return x + y + z
|
||||
15
server/tests/apigw/testdata/route_reload/def.yaml
vendored
Normal file
15
server/tests/apigw/testdata/route_reload/def.yaml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
apigateway:
|
||||
- endpoint: /test
|
||||
method: GET
|
||||
enabled: true
|
||||
filters:
|
||||
- ref: "payload"
|
||||
kind: "processer"
|
||||
enabled: true
|
||||
params:
|
||||
jsfunc: |
|
||||
const x = 10;
|
||||
const y = 20;
|
||||
const z = x + y;
|
||||
|
||||
return x + y + z
|
||||
Reference in New Issue
Block a user