Skip to content

Commit a5f3f76

Browse files
committed
Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/webui/develop/vite-8.0.0' into dependabot/npm_and_yarn/webui/develop/vite-8.0.0
2 parents ad5bbe2 + 0e08d0c commit a5f3f76

101 files changed

Lines changed: 1649 additions & 877 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

acceptance/cmd_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ func Start(cfg *static.Config) (*Cmd, error) {
3737
feature.Enable(cfg.Features)
3838

3939
registerDynamicTypes()
40-
app := runtime.New(cfg)
41-
generator.SetConfig(cfg.DataGen)
4240

4341
watcher := server.NewConfigWatcher(cfg)
42+
app := runtime.New(cfg, watcher)
43+
generator.SetConfig(cfg.DataGen)
4444

4545
certStore, err := cert.NewStore(cfg)
4646
if err != nil {

api/handler_events_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"mokapi/config/dynamic/dynamictest"
78
"mokapi/config/static"
89
"mokapi/providers/asyncapi3/kafka/store"
910
"mokapi/providers/openapi"
@@ -202,7 +203,7 @@ func TestHandler_Events(t *testing.T) {
202203
tc := tc
203204
t.Run(tc.name, func(t *testing.T) {
204205
cfg := &static.Config{}
205-
app := runtime.New(cfg)
206+
app := runtime.New(cfg, &dynamictest.Reader{})
206207

207208
h := New(app, static.Api{})
208209
tc.fn(t, h, app.Events)
@@ -330,7 +331,7 @@ func TestHandler_KafkaEvents(t *testing.T) {
330331
tc := tc
331332
t.Run(tc.name, func(t *testing.T) {
332333
cfg := &static.Config{}
333-
app := runtime.New(cfg)
334+
app := runtime.New(cfg, &dynamictest.Reader{})
334335

335336
h := New(app, static.Api{})
336337
tc.fn(t, h, app.Events)

api/handler_fileserver_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"mokapi/api"
66
"mokapi/config/dynamic"
7+
"mokapi/config/dynamic/dynamictest"
78
"mokapi/config/static"
89
"mokapi/providers/openapi/openapitest"
910
"mokapi/runtime"
@@ -131,7 +132,7 @@ func TestHandler_FileServer(t *testing.T) {
131132
t.Parallel()
132133

133134
cfg := &static.Config{}
134-
h := api.New(runtime.New(cfg), tc.config)
135+
h := api.New(runtime.New(cfg, &dynamictest.Reader{}), tc.config)
135136
tc.fn(t, h)
136137
})
137138
}
@@ -146,7 +147,7 @@ func TestOpenGraphInDashboard(t *testing.T) {
146147
name: "http service",
147148
test: func(t *testing.T) {
148149
cfg := &static.Config{}
149-
app := runtime.New(cfg)
150+
app := runtime.New(cfg, &dynamictest.Reader{})
150151
app.AddHttp(&dynamic.Config{Info: dynamic.ConfigInfo{Url: mustParse("https://foo.bar")}, Data: openapitest.NewConfig("3.0", openapitest.WithInfo("Swagger Petstore", "1.0", "This is a sample server Petstore server."))})
151152
h := api.New(app, static.Api{Path: "/mokapi", Dashboard: true})
152153
try.Handler(t,
@@ -166,7 +167,7 @@ func TestOpenGraphInDashboard(t *testing.T) {
166167
name: "http service path without summary and description",
167168
test: func(t *testing.T) {
168169
cfg := &static.Config{}
169-
app := runtime.New(cfg)
170+
app := runtime.New(cfg, &dynamictest.Reader{})
170171
app.AddHttp(&dynamic.Config{Info: dynamic.ConfigInfo{Url: mustParse("https://foo.bar")}, Data: openapitest.NewConfig("3.0",
171172
openapitest.WithInfo("Swagger Petstore", "1.0", "This is a sample server Petstore server."),
172173
openapitest.WithPath("/pet/{petId}"),
@@ -190,7 +191,7 @@ func TestOpenGraphInDashboard(t *testing.T) {
190191
name: "http service path with summary and description",
191192
test: func(t *testing.T) {
192193
cfg := &static.Config{}
193-
app := runtime.New(cfg)
194+
app := runtime.New(cfg, &dynamictest.Reader{})
194195
app.AddHttp(&dynamic.Config{Info: dynamic.ConfigInfo{Url: mustParse("https://foo.bar")}, Data: openapitest.NewConfig("3.0",
195196
openapitest.WithInfo("Swagger Petstore", "1.0", "This is a sample server Petstore server."),
196197
openapitest.WithPath("/pet/{petId}",
@@ -216,7 +217,7 @@ func TestOpenGraphInDashboard(t *testing.T) {
216217
name: "http service path with no summary but description",
217218
test: func(t *testing.T) {
218219
cfg := &static.Config{}
219-
app := runtime.New(cfg)
220+
app := runtime.New(cfg, &dynamictest.Reader{})
220221
app.AddHttp(&dynamic.Config{Info: dynamic.ConfigInfo{Url: mustParse("https://foo.bar")}, Data: openapitest.NewConfig("3.0",
221222
openapitest.WithInfo("Swagger Petstore", "1.0", "This is a sample server Petstore server."),
222223
openapitest.WithPath("/pet/{petId}",
@@ -241,7 +242,7 @@ func TestOpenGraphInDashboard(t *testing.T) {
241242
name: "http service endpoint no summary and no description",
242243
test: func(t *testing.T) {
243244
cfg := &static.Config{}
244-
app := runtime.New(cfg)
245+
app := runtime.New(cfg, &dynamictest.Reader{})
245246
app.AddHttp(&dynamic.Config{Info: dynamic.ConfigInfo{Url: mustParse("https://foo.bar")}, Data: openapitest.NewConfig("3.0",
246247
openapitest.WithInfo("Swagger Petstore", "1.0", "This is a sample server Petstore server."),
247248
openapitest.WithPath("/pet/{petId}",
@@ -266,7 +267,7 @@ func TestOpenGraphInDashboard(t *testing.T) {
266267
name: "http service endpoint get right path",
267268
test: func(t *testing.T) {
268269
cfg := &static.Config{}
269-
app := runtime.New(cfg)
270+
app := runtime.New(cfg, &dynamictest.Reader{})
270271
app.AddHttp(&dynamic.Config{Info: dynamic.ConfigInfo{Url: mustParse("https://foo.bar")}, Data: openapitest.NewConfig("3.0",
271272
openapitest.WithInfo("Swagger Petstore", "1.0", "This is a sample server Petstore server."),
272273
openapitest.WithPath("/pet/{petId}",

api/handler_http_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestHandler_Http(t *testing.T) {
6666
{
6767
name: "get http service info",
6868
app: func() *runtime.App {
69-
app := runtime.New(&static.Config{})
69+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
7070
cfg := &dynamic.Config{
7171
Info: dynamictest.NewConfigInfo(), Data: openapitest.NewConfig("3.0.0",
7272
openapitest.WithInfo("foo", "1.0", "bar"),
@@ -328,7 +328,7 @@ func TestHandler_Http(t *testing.T) {
328328

329329
func TestHandler_Http_NotFound(t *testing.T) {
330330
cfg := &static.Config{}
331-
h := New(runtime.New(cfg), static.Api{})
331+
h := New(runtime.New(cfg, &dynamictest.Reader{}), static.Api{})
332332

333333
try.Handler(t,
334334
http.MethodGet,

api/handler_kafka.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"time"
1818

1919
"github.com/pkg/errors"
20+
log "github.com/sirupsen/logrus"
2021
)
2122

2223
type kafkaSummary struct {
@@ -564,18 +565,38 @@ func newTopic(t *store.Topic, ch *asyncapi3.Channel, cfg *asyncapi3.Config) topi
564565
}
565566

566567
if msg.Payload != nil && msg.Payload.Value != nil {
567-
m.Payload = &schemaInfo{Schema: msg.Payload.Value.Schema, Format: msg.Payload.Value.Format}
568+
format := ""
569+
if msf, ok := msg.Payload.Value.(*asyncapi3.MultiSchemaFormat); ok {
570+
format = msf.Format
571+
}
572+
s, err := msg.Payload.GetSchema()
573+
if err != nil {
574+
log.Errorf("failed to get schema for message in topic '%s': %v", t.Name, err)
575+
}
576+
m.Payload = &schemaInfo{Schema: s, Format: format}
568577
}
569578
if msg.Headers != nil && msg.Headers.Value != nil {
570-
m.Header = &schemaInfo{Schema: msg.Headers.Value.Schema, Format: msg.Headers.Value.Format}
579+
format := ""
580+
if msf, ok := msg.Headers.Value.(*asyncapi3.MultiSchemaFormat); ok {
581+
format = msf.Format
582+
}
583+
s, err := msg.Headers.GetSchema()
584+
if err != nil {
585+
log.Errorf("failed to get schema for headers in topic '%s': %v", t.Name, err)
586+
}
587+
m.Header = &schemaInfo{Schema: s, Format: format}
571588
}
572589

573590
if m.ContentType == "" {
574591
m.ContentType = cfg.DefaultContentType
575592
}
576593

577594
if msg.Bindings.Kafka.Key != nil {
578-
m.Key = &schemaInfo{Schema: msg.Bindings.Kafka.Key.Value.Schema}
595+
s, err := msg.Bindings.Kafka.Key.GetSchema()
596+
if err != nil {
597+
log.Errorf("failed to get schema for key in topic '%s': %v", t.Name, err)
598+
}
599+
m.Key = &schemaInfo{Schema: s}
579600
}
580601
if result.Messages == nil {
581602
result.Messages = map[string]messageConfig{}

api/handler_kafka_test.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestHandler_Kafka(t *testing.T) {
5757
{
5858
name: "get kafka services",
5959
app: func() *runtime.App {
60-
app := runtime.New(&static.Config{})
60+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
6161
_, _ = app.Kafka.Add(&dynamic.Config{
6262
Info: dynamic.ConfigInfo{Url: try.MustUrl("kafka.yaml")},
6363
Data: asyncapi3test.NewConfig(
@@ -91,7 +91,7 @@ func TestHandler_Kafka(t *testing.T) {
9191
{
9292
name: "get specific",
9393
app: func() *runtime.App {
94-
app := runtime.New(&static.Config{})
94+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
9595
cfg := &dynamic.Config{
9696
Info: dynamictest.NewConfigInfo(),
9797
Data: asyncapi3test.NewConfig(
@@ -221,7 +221,7 @@ func TestHandler_Kafka(t *testing.T) {
221221
{
222222
name: "get specific with group",
223223
app: func() *runtime.App {
224-
app := runtime.New(&static.Config{})
224+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
225225
app.Kafka.Set("foo", getKafkaInfoWithGroup(asyncapi3test.NewConfig(
226226
asyncapi3test.WithInfo("foo", "bar", "1.0"),
227227
asyncapi3test.WithServer("foo", "kafka", "foo.bar"),
@@ -246,7 +246,7 @@ func TestHandler_Kafka(t *testing.T) {
246246
{
247247
name: "get specific with group no generation",
248248
app: func() *runtime.App {
249-
app := runtime.New(&static.Config{})
249+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
250250
app.Kafka.Set("foo", getKafkaInfoWithGroup(asyncapi3test.NewConfig(
251251
asyncapi3test.WithInfo("foo", "bar", "1.0"),
252252
asyncapi3test.WithServer("foo", "kafka", "foo.bar"),
@@ -273,7 +273,7 @@ func TestHandler_Kafka(t *testing.T) {
273273
return t1
274274
}
275275

276-
app := runtime.New(&static.Config{})
276+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
277277
app.Kafka.Set("foo", getKafkaInfoWithGroup(asyncapi3test.NewConfig(
278278
asyncapi3test.WithInfo("foo", "bar", "1.0"),
279279
asyncapi3test.WithServer("foo", "kafka", "foo.bar"),
@@ -321,7 +321,7 @@ func TestHandler_Kafka(t *testing.T) {
321321
{
322322
name: "get specific with topic and openapi schema",
323323
app: func() *runtime.App {
324-
app := runtime.New(&static.Config{})
324+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
325325
app.Kafka.Set("foo", getKafkaInfo(asyncapi3test.NewConfig(
326326
asyncapi3test.WithInfo("foo", "bar", "1.0"),
327327
asyncapi3test.WithChannel("foo",
@@ -369,7 +369,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
369369
{
370370
name: "get kafka topics but empty",
371371
app: func() *runtime.App {
372-
app := runtime.New(&static.Config{})
372+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
373373
_, _ = app.Kafka.Add(&dynamic.Config{
374374
Info: dynamic.ConfigInfo{Url: try.MustUrl("kafka.yaml")},
375375
Data: asyncapi3test.NewConfig(
@@ -394,7 +394,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
394394
{
395395
name: "get kafka topics with one topic",
396396
app: func() *runtime.App {
397-
app := runtime.New(&static.Config{})
397+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
398398
_, _ = app.Kafka.Add(&dynamic.Config{
399399
Info: dynamic.ConfigInfo{Url: try.MustUrl("kafka.yaml")},
400400
Data: asyncapi3test.NewConfig(
@@ -424,7 +424,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
424424
{
425425
name: "get specific kafka topic",
426426
app: func() *runtime.App {
427-
app := runtime.New(&static.Config{})
427+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
428428
_, _ = app.Kafka.Add(&dynamic.Config{
429429
Info: dynamic.ConfigInfo{Url: try.MustUrl("kafka.yaml")},
430430
Data: asyncapi3test.NewConfig(
@@ -454,7 +454,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
454454
{
455455
name: "get specific kafka topic but not found",
456456
app: func() *runtime.App {
457-
app := runtime.New(&static.Config{})
457+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
458458
_, _ = app.Kafka.Add(&dynamic.Config{
459459
Info: dynamic.ConfigInfo{Url: try.MustUrl("kafka.yaml")},
460460
Data: asyncapi3test.NewConfig(
@@ -482,7 +482,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
482482
{
483483
name: "produce kafka message into topic",
484484
app: func() *runtime.App {
485-
app := runtime.New(&static.Config{})
485+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
486486

487487
msg := asyncapi3test.NewMessage(
488488
asyncapi3test.WithContentType("application/json"),
@@ -532,7 +532,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
532532
{
533533
name: "produce kafka message into topic using binary",
534534
app: func() *runtime.App {
535-
app := runtime.New(&static.Config{})
535+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
536536
_, _ = app.Kafka.Add(&dynamic.Config{
537537
Info: dynamic.ConfigInfo{Url: try.MustUrl("kafka.yaml")},
538538
Data: asyncapi3test.NewConfig(
@@ -571,7 +571,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
571571
{
572572
name: "produce invalid kafka message into topic",
573573
app: func() *runtime.App {
574-
app := runtime.New(&static.Config{})
574+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
575575

576576
msg := asyncapi3test.NewMessage(
577577
asyncapi3test.WithContentType("application/json"),
@@ -627,7 +627,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
627627
{
628628
name: "get kafka partitions",
629629
app: func() *runtime.App {
630-
app := runtime.New(&static.Config{})
630+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
631631
_, _ = app.Kafka.Add(&dynamic.Config{
632632
Info: dynamic.ConfigInfo{Url: try.MustUrl("kafka.yaml")},
633633
Data: asyncapi3test.NewConfig(
@@ -656,7 +656,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
656656
{
657657
name: "get specific kafka partition",
658658
app: func() *runtime.App {
659-
app := runtime.New(&static.Config{})
659+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
660660
_, _ = app.Kafka.Add(&dynamic.Config{
661661
Info: dynamic.ConfigInfo{Url: try.MustUrl("kafka.yaml")},
662662
Data: asyncapi3test.NewConfig(
@@ -685,7 +685,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
685685
{
686686
name: "produce kafka message into specific partition",
687687
app: func() *runtime.App {
688-
app := runtime.New(&static.Config{})
688+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
689689

690690
msg := asyncapi3test.NewMessage(
691691
asyncapi3test.WithContentType("application/json"),
@@ -739,7 +739,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
739739
{
740740
name: "produce kafka message into specific partition using XML",
741741
app: func() *runtime.App {
742-
app := runtime.New(&static.Config{})
742+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
743743

744744
msg := asyncapi3test.NewMessage(
745745
asyncapi3test.WithContentType("application/xml"),
@@ -801,7 +801,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
801801
{
802802
name: "produce kafka message into specific partition using plain XML string",
803803
app: func() *runtime.App {
804-
app := runtime.New(&static.Config{})
804+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
805805

806806
msg := asyncapi3test.NewMessage(
807807
asyncapi3test.WithContentType("application/xml"),
@@ -853,7 +853,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
853853
{
854854
name: "produce invalid kafka message into specific partition using plain XML string",
855855
app: func() *runtime.App {
856-
app := runtime.New(&static.Config{})
856+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
857857

858858
msg := asyncapi3test.NewMessage(
859859
asyncapi3test.WithContentType("application/xml"),
@@ -912,7 +912,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
912912
{
913913
name: "get records",
914914
app: func() *runtime.App {
915-
app := runtime.New(&static.Config{})
915+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
916916

917917
msg := asyncapi3test.NewMessage(
918918
asyncapi3test.WithContentType("application/json"),
@@ -970,7 +970,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
970970
{
971971
name: "get specific record",
972972
app: func() *runtime.App {
973-
app := runtime.New(&static.Config{})
973+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
974974

975975
msg := asyncapi3test.NewMessage(
976976
asyncapi3test.WithContentType("application/json"),
@@ -1035,7 +1035,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
10351035
}
10361036

10371037
func TestHandler_Kafka_NotFound(t *testing.T) {
1038-
h := api.New(runtime.New(&static.Config{}), static.Api{})
1038+
h := api.New(runtime.New(&static.Config{}, &dynamictest.Reader{}), static.Api{})
10391039

10401040
try.Handler(t,
10411041
http.MethodGet,

api/handler_ldap_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestHandler_Ldap(t *testing.T) {
3232
{
3333
name: "get ldap services",
3434
app: func() *runtime.App {
35-
app := runtime.New(&static.Config{})
35+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
3636
app.Ldap.Set("foo", &runtime.LdapInfo{
3737
Config: &directory.Config{Info: directory.Info{Name: "foo", Description: "bar", Version: "1.0"}},
3838
})
@@ -45,7 +45,7 @@ func TestHandler_Ldap(t *testing.T) {
4545
{
4646
name: "get ldap service",
4747
app: func() *runtime.App {
48-
app := runtime.New(&static.Config{})
48+
app := runtime.New(&static.Config{}, &dynamictest.Reader{})
4949
cfg := &dynamic.Config{
5050
Info: dynamictest.NewConfigInfo(),
5151
Data: &directory.Config{

0 commit comments

Comments
 (0)