Skip to content

Commit 9024da3

Browse files
authored
Merge pull request #625 from marle3003/develop
Develop
2 parents 3377be3 + 151f61f commit 9024da3

File tree

280 files changed

+8397
-3272
lines changed

Some content is hidden

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

280 files changed

+8397
-3272
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup node
2121
uses: actions/setup-node@v4
2222
with:
23-
node-version: 20
23+
node-version: 23
2424
- name: build webui
2525
working-directory: ./webui
2626
run: |
@@ -29,7 +29,7 @@ jobs:
2929
npm run build
3030
3131
- name: Run Unit tests.
32-
run: go test -v -coverprofile=coverage.out -covermode=atomic ./...
32+
run: go test -v --cover -coverprofile=coverage.out -covermode=atomic ./...
3333

3434
- name: Upload Coverage report to CodeCov
3535
uses: codecov/codecov-action@v3

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
go-version: 1.23.4
3030
- uses: actions/setup-node@v4
3131
with:
32-
node-version: 20
32+
node-version: 23
3333
registry-url: 'https://registry.npmjs.org'
3434
- run: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
3535
- run: npm install
@@ -62,7 +62,7 @@ jobs:
6262
go-version: 1.23.4
6363
- uses: actions/setup-node@v4
6464
with:
65-
node-version: 20
65+
node-version: 23
6666
registry-url: 'https://registry.npmjs.org'
6767
- run: choco install go-task
6868
- run: npm install

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
publish-report:
5050
name: Publish Playwright Report
51-
if: "(success() || needs.test.result == 'failure') && github.repository == 'marle3003/mokapi'"
51+
if: "(success() || needs.test.result == 'failure') && github.event.pull_request.head.repo.full_name == 'marle3003/mokapi'"
5252
needs: [ test ]
5353
runs-on: ubuntu-latest
5454
continue-on-error: true

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ Explore tutorials that walk you through mocking different protocols and scenario
122122

123123
- [Get Started](https://mokapi.io/docs/guides/welcome)
124124
- [HTTP](https://mokapi.io/docs/guides/http)
125-
- [Kafka](https://mokapi.io/docs/guides/kafka/overview)
126-
- [LDAP](https://mokapi.io/docs/guides/ldap/overview)
127-
- [SMTP](https://mokapi.io/docs/guides/smtp/overview)
125+
- [Kafka](https://mokapi.io/docs/guides/kafka)
126+
- [LDAP](https://mokapi.io/docs/guides/ldap)
127+
- [SMTP](https://mokapi.io/docs/guides/mail)
128128
- [Javascript API](https://mokapi.io/docs/javascript-api)
129129
- [Resources](https://mokapi.io/docs/resources)
130130

acceptance/acceptance_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"github.com/stretchr/testify/require"
55
"github.com/stretchr/testify/suite"
66
"mokapi/config/static"
7-
"mokapi/runtime/events"
87
"testing"
98
"time"
109
)
@@ -24,11 +23,6 @@ type BaseSuite struct {
2423
func (suite *BaseSuite) initCmd(cfg *static.Config) {
2524
//logrus.SetOutput(io.Discard)
2625

27-
events.SetStore(20, events.NewTraits().WithNamespace("http"))
28-
events.SetStore(20, events.NewTraits().WithNamespace("kafka"))
29-
events.SetStore(20, events.NewTraits().WithNamespace("smtp"))
30-
events.SetStore(20, events.NewTraits().WithNamespace("ldap"))
31-
3226
suite.cfg = cfg
3327
cmd, err := Start(cfg)
3428
require.NoError(suite.T(), err)

acceptance/cmd_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"mokapi/feature"
1414
"mokapi/providers/asyncapi3"
1515
"mokapi/providers/directory"
16+
mail2 "mokapi/providers/mail"
1617
"mokapi/providers/openapi"
1718
"mokapi/providers/swagger"
1819
"mokapi/runtime"
@@ -51,13 +52,13 @@ func Start(cfg *static.Config) (*Cmd, error) {
5152

5253
http := server.NewHttpManager(scriptEngine, certStore, app)
5354
kafka := server.NewKafkaManager(scriptEngine, app)
54-
smtp := server.NewSmtpManager(app, scriptEngine, certStore)
55+
mailManager := server.NewMailManager(app, scriptEngine, certStore)
5556
ldap := server.NewLdapDirectoryManager(scriptEngine, certStore, app)
5657

5758
watcher.AddListener(func(e dynamic.ConfigEvent) {
5859
kafka.UpdateConfig(e)
5960
http.Update(e)
60-
smtp.UpdateConfig(e)
61+
mailManager.UpdateConfig(e)
6162
ldap.UpdateConfig(e)
6263
if err := scriptEngine.AddScript(e); err != nil {
6364
panic(err)
@@ -76,7 +77,7 @@ func Start(cfg *static.Config) (*Cmd, error) {
7677

7778
pool := safe.NewPool(context.Background())
7879
ctx, cancel := context.WithCancel(context.Background())
79-
s := server.NewServer(pool, app, watcher, kafka, http, smtp, ldap, scriptEngine)
80+
s := server.NewServer(pool, app, watcher, kafka, http, mailManager, ldap, scriptEngine)
8081
s.StartAsync(ctx)
8182

8283
return &Cmd{
@@ -110,4 +111,7 @@ func registerDynamicTypes() {
110111
dynamic.Register("smtp", func(v version.Version) bool {
111112
return true
112113
}, &mail.Config{})
114+
dynamic.Register("mail", func(v version.Version) bool {
115+
return true
116+
}, &mail2.Config{})
113117
}

acceptance/ldap_test.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package acceptance
22

33
import (
4+
"fmt"
45
"github.com/stretchr/testify/require"
56
"mokapi/config/static"
67
"mokapi/ldap"
7-
"mokapi/providers/directory"
8-
"mokapi/runtime/events"
98
"mokapi/runtime/metrics"
9+
"mokapi/try"
10+
"net/http"
1011
"time"
1112
)
1213

@@ -30,12 +31,7 @@ func (suite *LdapSuite) TearDownSuite() {
3031
suite.Client.Close()
3132
}
3233

33-
func (suite *BaseSuite) BeforeTest(_, _ string) {
34-
events.SetStore(20, events.NewTraits().WithNamespace("ldap"))
35-
}
36-
3734
func (suite *LdapSuite) AfterTest(_, _ string) {
38-
events.Reset()
3935
suite.cmd.App.Monitor.Reset()
4036
}
4137

@@ -66,14 +62,12 @@ func (suite *LdapSuite) TestLog() {
6662
}
6763
_, err := suite.Client.Search(search)
6864
require.NoError(suite.T(), err)
69-
e := events.GetEvents(events.NewTraits().WithNamespace("ldap"))
70-
require.Len(suite.T(), e, 1)
71-
data := e[0].Data.(*directory.SearchLog)
72-
require.Equal(suite.T(), "WholeSubtree", data.Request.Scope)
73-
require.Equal(suite.T(), "(objectClass=user)", data.Request.Filter)
74-
require.Equal(suite.T(), []string{"mail"}, data.Request.Attributes)
75-
require.Len(suite.T(), data.Response.Results, 4)
76-
require.Equal(suite.T(), "Success", data.Response.Status)
65+
66+
try.GetRequest(suite.T(), fmt.Sprintf("http://127.0.0.1:%v/api/events?namespace=ldap", suite.cfg.Api.Port),
67+
nil,
68+
try.HasStatusCode(http.StatusOK),
69+
try.BodyContains(`:{"request":{"operation":"Search","baseDN":"","scope":"WholeSubtree","dereferencePolicy":0,"sizeLimit":0,"timeLimit":0,"typesOnly":false,"filter":"(objectClass=user)","attributes":["mail"],"controls":null}`),
70+
)
7771
}
7872

7973
func (suite *LdapSuite) TestMetric() {

acceptance/mail/config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
mail: 1.0
2+
info:
3+
title: Mokapi MailServer
4+
servers:
5+
smtps:
6+
host: localhost:8025
7+
protocol: smtps
8+
rules:
9+
allowSender:
10+
sender: .*@foo.bar
11+
action: allow

acceptance/mail/config_old.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
smtp: 1.0
2+
info:
3+
title: Mokapi MailServer Old
4+
server: smtp://localhost:8030

acceptance/mail/smtp.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)