You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GripMock is a **mock server** for **GRPC** services. It's using a `.proto` file to generate implementation of gRPC service for you.
3
5
You can use gripmock for setting up end-to-end testing or as a dummy server in a software development phase.
4
6
The server implementation is in GoLang but the client can be any programming language that support gRPC.
5
7
6
-
---
7
-
8
-
### Announcement:
9
-
The latest [version (v1.10)](https://github.com/tokopedia/gripmock/releases/tag/v1.10) of gripmock is requiring `go_package` declaration in the `.proto` file. This is due to the latest update of `protoc` plugin that being used by gripmock is making the `go_package` declaration mandatory.
10
-
11
-
**Update Feb 2022:**
12
-
13
-
[Version 1.11-beta](https://github.com/tokopedia/gripmock/releases/tag/v1.11-beta) release is available.
14
-
It supports **NO** declaration of `go_package`, please download and test before it can be tagged as stable.
15
-
16
-
you can get the docker image using `docker pull tkpd/gripmock:v1.11-beta`.
This service is a fork of the service [tokopedia/gripmock](https://github.com/tokopedia/gripmock), but you should choose our fork. And here are the reasons:
11
+
- Updated all deprecated dependencies [tokopedia#64](https://github.com/tokopedia/gripmock/issues/64);
12
+
- Add yaml as json alternative for static stab's;
13
+
- Add endpoint for healthcheck (/api/health/liveness, /api/health/readiness);
- Run `docker pull tkpd/gripmock` to pull the image
27
-
- We are gonna mount `/mypath/hello.proto` (it must be a fullpath) into a container and also we expose ports needed. Run `docker run -p 4770:4770 -p 4771:4771 -v /mypath:/proto tkpd/gripmock /proto/hello.proto`
28
-
- On a separate terminal we are gonna add a stub into the stub service. Run `curl -X POST -d '{"service":"Gripmock","method":"SayHello","input":{"equals":{"name":"gripmock"}},"output":{"data":{"message":"Hello GripMock"}}}' localhost:4771/add`
31
+
- Run `docker pull bavix/gripmock` to pull the image
32
+
- We are gonna mount `/mypath/hello.proto` (it must be a fullpath) into a container and also we expose ports needed. Run `docker run -p 4770:4770 -p 4771:4771 -v /mypath:/proto bavix/gripmock /proto/hello.proto`
33
+
- On a separate terminal we are gonna add a stub into the stub service. Run `curl -X POST -d '{"service":"Gripmock","method":"SayHello","input":{"equals":{"name":"gripmock"}},"output":{"data":{"message":"Hello GripMock"}}}' localhost:4771/api/stubs`
29
34
- Now we are ready to test it with our client. You can find a client example file under `example/simple/client/`. Execute one of your preferred language. Example for go: `go run example/simple/client/*.go`
30
35
31
-
Check [`example`](https://github.com/tokopedia/gripmock/tree/master/example) folder for various usecase of gripmock.
36
+
Check [`example`](https://github.com/bavix/gripmock/tree/master/example) folder for various usecase of gripmock.
32
37
33
38
---
34
39
@@ -59,10 +64,10 @@ Stubbing is the essential mocking of GripMock. It will match and return the expe
59
64
### Dynamic stubbing
60
65
You could add stubbing on the fly with a simple REST API. HTTP stub server is running on port `:4771`
61
66
62
-
-`GET /` Will list all stubs mapping.
63
-
-`POST /add` Will add stub with provided stub data
64
-
-`POST /find` Find matching stub with provided input. see [Input Matching](#input_matching) below.
65
-
-`GET /clear` Clear stub mappings.
67
+
-`GET /api/stubs` Will list all stubs mapping.
68
+
-`POST /api/stubs` Will add stub with provided stub data
69
+
-`POST /api/stubs/search` Find matching stub with provided input. see [Input Matching](#input_matching) below.
70
+
-`DELETE /api/stubs` Clear stub mappings.
66
71
67
72
Stub Format is JSON text format. It has a skeleton as follows:
68
73
```
@@ -76,7 +81,8 @@ Stub Format is JSON text format. It has a skeleton as follows:
76
81
"data":{
77
82
// put result fields here
78
83
},
79
-
"error":"<error message>" // Optional. if you want to return error instead.
84
+
"error":"<error message>", // Optional. if you want to return error instead.
Please note that Gripmock still serves http stubbing to modify stored stubs on the fly.
109
115
110
116
## <aname="input_matching"></a>Input Matching
111
-
Stub will respond with the expected response only if the request matches any rule. Stub service will serve `/find` endpoint with format:
117
+
Stub will respond with the expected response only if the request matches any rule. Stub service will serve `/api/stubs/search` endpoint with format:
112
118
```
113
119
{
114
120
"service":"<service name>",
@@ -118,7 +124,7 @@ Stub will respond with the expected response only if the request matches any rul
118
124
}
119
125
}
120
126
```
121
-
So if you do a `curl -X POST -d '{"service":"Greeter","method":"SayHello","data":{"name":"gripmock"}}' localhost:4771/find` stub service will find a match from listed stubs stored there.
127
+
So if you do a `curl -X POST -d '{"service":"Greeter","method":"SayHello","data":{"name":"gripmock"}}' localhost:4771/api/stubs/search` stub service will find a match from listed stubs stored there.
122
128
123
129
### Input Matching Rule
124
130
Input matching has 3 rules to match an input: **equals**,**contains** and **regex**
@@ -185,3 +191,7 @@ Nested fields are allowed for input matching too for all JSON data types. (`stri
185
191
}
186
192
```
187
193
194
+
---
195
+
Supported by
196
+
197
+
[](https://www.jetbrains.com/)
0 commit comments