Skip to content

Commit

Permalink
Final update of tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
GollyTicker committed Oct 5, 2023
1 parent 0d5e710 commit 5852fee
Show file tree
Hide file tree
Showing 136 changed files with 342 additions and 194 deletions.
16 changes: 8 additions & 8 deletions EXAMPLES.md
Expand Up @@ -26,7 +26,7 @@ $ docker run -v "$PWD/test/proto:/proto" --network host qaware/protocurl \
-u http://localhost:8080/happy-day/verify \
-d "includeReason: true"

=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
includeReason: true
=========================== POST Response Text =========================== <<<
isHappyDay: true
Expand All @@ -41,7 +41,7 @@ $ docker run -v "$PWD/test/proto:/proto" --network host qaware/protocurl \
-f happyday.proto -i happyday.HappyDayRequest -o happyday.HappyDayResponse \
-u http://localhost:8080/happy-day/verify -d ""

=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>

=========================== POST Response Text =========================== <<<
isHappyDay: true
Expand All @@ -56,7 +56,7 @@ $ docker run -v "$PWD/test/proto:/proto" --network host qaware/protocurl \
-u http://localhost:8080/happy-day/verify \
-d "date: { seconds: 1648044939}"

=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
date: {
seconds: 1648044939
}
Expand Down Expand Up @@ -96,7 +96,7 @@ $ docker run -v "$PWD/test/proto:/proto" --network host qaware/protocurl \
-u http://localhost:8080/happy-day/verify \
-d "{ \"date\": \"2022-03-23T14:15:39Z\" }"

=========================== POST Request JSON =========================== >>>
=========================== POST Request JSON =========================== >>>
{"date":"2022-03-23T14:15:39Z"}
=========================== POST Response JSON =========================== <<<
{"formattedDate":"Wed, 23 Mar 2022 14:15:39 GMT"}
Expand All @@ -110,7 +110,7 @@ $ docker run -v "$PWD/test/proto:/proto" --network host qaware/protocurl \
-u http://localhost:8080/happy-day/verify --out=json:pretty \
-d "{ \"date\": \"2022-03-23T14:15:39Z\" }"

=========================== POST Request JSON =========================== >>>
=========================== POST Request JSON =========================== >>>
{"date":"2022-03-23T14:15:39Z"}
=========================== POST Response JSON =========================== <<<
{
Expand Down Expand Up @@ -157,7 +157,7 @@ $ docker run -v "$PWD/test/proto:/proto" --network host qaware/protocurl \
-d "date: { seconds: 1648044939}" \
--curl -n -H 'Content-Type: application/octet-stream'

=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
date: {
seconds: 1648044939
}
Expand Down Expand Up @@ -410,7 +410,7 @@ Searching for message with base name: HappyDayRequest
Resolved message package-paths for name HappyDayRequest: [happyday.HappyDayRequest]
Searching for message with base name: HappyDayRequest
Resolved message package-paths for name HappyDayRequest: [happyday.HappyDayRequest]
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
date: {
seconds: 1648044939
}
Expand All @@ -435,7 +435,7 @@ Total curl args:
=========================== POST Response Headers =========================== <<<
HTTP/1.1 200 OK
Content-Type: application/x-protobuf
Date: Tue, 03 Oct 2023 20:46:17 GMT
Date: Thu, 05 Oct 2023 09:21:38 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 35
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -103,7 +103,7 @@ Then protocurl will
and produce the following output:

```
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
includeReason: true
=========================== POST Response Text =========================== <<<
isHappyDay: true
Expand Down
169 changes: 159 additions & 10 deletions TESTS.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/generated.usage.txt
Expand Up @@ -28,7 +28,7 @@ Flags:
-h, --help help for protocurl
--in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'.
-F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f <file> is provided, this -F is set and the files are inferred.
-X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically. (default "POST")
-X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST")
--no-curl Forces the use of the built-in internal http request instead of curl.
-n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type.
--out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them.
Expand Down
2 changes: 1 addition & 1 deletion src/flags.go
Expand Up @@ -61,7 +61,7 @@ func intialiseFlags() {
"Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f <file> is provided, this -F is set and the files are inferred.")

flags.StringVarP(&CurrentConfig.Method, "method", "X", "POST",
"HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically.")
"HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically.")

flags.StringVarP(&CurrentConfig.RequestType, "request-type", "i", "",
"Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest")
Expand Down
3 changes: 1 addition & 2 deletions src/protocurl.go
Expand Up @@ -113,8 +113,7 @@ func encodeToBinary(requestType string, text string, registry *protoregistry.Fil
)

if !CurrentConfig.ShowOutputOnly {
// todo. remove one space here for aligned output
fmt.Printf("%s %s Request %s %s %s\n%s\n",
fmt.Printf("%s %s Request %s %s %s\n%s\n",
VISUAL_SEPARATOR, CurrentConfig.Method, displayIn(CurrentConfig.InTextType), VISUAL_SEPARATOR,
SEND, reconstructedRequestText)
}
Expand Down
4 changes: 2 additions & 2 deletions test/results/additional-curl-args--X_GET-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== GET Request Text =========================== >>>
=========================== GET Request Text =========================== >>>
date: {
seconds: 1642044939
nanos: 152000000
Expand All @@ -10,7 +10,7 @@ includeReason: true
=========================== GET Response Headers =========================== <<<
HTTP/1.1 200 OK
Content-Type: application/x-protobuf
Date: Wed, 04 Oct 2023 08:55:15 GMT
Date: Thu, 05 Oct 2023 09:18:01 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 65
Expand Down
4 changes: 2 additions & 2 deletions test/results/additional-curl-args-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
date: {
seconds: 1642044939
nanos: 152000000
Expand All @@ -10,7 +10,7 @@ includeReason: true
=========================== POST Response Headers =========================== <<<
HTTP/1.1 200 OK
Content-Type: application/x-protobuf
Date: Tue, 03 Oct 2023 20:42:35 GMT
Date: Thu, 05 Oct 2023 09:18:00 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 65
Expand Down
6 changes: 3 additions & 3 deletions test/results/additional-curl-args-verbose--X_GET-expected.txt
Expand Up @@ -235,7 +235,7 @@ Searching for message with base name: HappyDayRequest
Resolved message package-paths for name HappyDayRequest: [happyday.HappyDayRequest]
Searching for message with base name: HappyDayRequest
Resolved message package-paths for name HappyDayRequest: [happyday.HappyDayRequest]
=========================== GET Request Text =========================== >>>
=========================== GET Request Text =========================== >>>
date: {
seconds: 1642044939
nanos: 152000000
Expand Down Expand Up @@ -279,7 +279,7 @@ Total curl args:
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/x-protobuf
< Date: Wed, 04 Oct 2023 08:55:21 GMT
< Date: Thu, 05 Oct 2023 09:18:02 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< Content-Length: 65
Expand All @@ -290,7 +290,7 @@ Total curl args:
=========================== GET Response Headers =========================== <<<
HTTP/1.1 200 OK
Content-Type: application/x-protobuf
Date: Wed, 04 Oct 2023 08:55:21 GMT
Date: Thu, 05 Oct 2023 09:18:02 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 65
Expand Down
6 changes: 3 additions & 3 deletions test/results/additional-curl-args-verbose-expected.txt
Expand Up @@ -235,7 +235,7 @@ Searching for message with base name: HappyDayRequest
Resolved message package-paths for name HappyDayRequest: [happyday.HappyDayRequest]
Searching for message with base name: HappyDayRequest
Resolved message package-paths for name HappyDayRequest: [happyday.HappyDayRequest]
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
date: {
seconds: 1642044939
nanos: 152000000
Expand Down Expand Up @@ -279,7 +279,7 @@ Total curl args:
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/x-protobuf
< Date: Tue, 03 Oct 2023 20:42:36 GMT
< Date: Thu, 05 Oct 2023 09:18:01 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< Content-Length: 65
Expand All @@ -290,7 +290,7 @@ Total curl args:
=========================== POST Response Headers =========================== <<<
HTTP/1.1 200 OK
Content-Type: application/x-protobuf
Date: Tue, 03 Oct 2023 20:42:36 GMT
Date: Thu, 05 Oct 2023 09:18:01 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 65
Expand Down
4 changes: 2 additions & 2 deletions test/results/display-binary-and-headers--X_GET-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== GET Request Text =========================== >>>
=========================== GET Request Text =========================== >>>
date: {
seconds: 1642044939
nanos: 152000000
Expand All @@ -10,7 +10,7 @@ includeReason: true
=========================== GET Response Headers =========================== <<<
HTTP/1.1 200 OK
Content-Type: application/x-protobuf
Date: Wed, 04 Oct 2023 08:55:07 GMT
Date: Thu, 05 Oct 2023 09:18:00 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 65
Expand Down
4 changes: 2 additions & 2 deletions test/results/display-binary-and-headers-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
date: {
seconds: 1642044939
nanos: 152000000
Expand All @@ -10,7 +10,7 @@ includeReason: true
=========================== POST Response Headers =========================== <<<
HTTP/1.1 200 OK
Content-Type: application/x-protobuf
Date: Tue, 03 Oct 2023 20:42:35 GMT
Date: Thu, 05 Oct 2023 09:17:59 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 65
Expand Down
4 changes: 2 additions & 2 deletions test/results/display-binary-and-headers-no-curl-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
date: {
seconds: 1642044939
nanos: 152000000
Expand All @@ -12,7 +12,7 @@ HTTP/1.1 200 OK
Content-Length: 65
Connection: keep-alive
Content-Type: application/x-protobuf
Date: Tue, 03 Oct 2023 20:42:35 GMT
Date: Thu, 05 Oct 2023 09:17:59 GMT
Keep-Alive: timeout=5
=========================== POST Response Binary =========================== <<<
00000000 08 01 12 1c 54 68 75 72 73 64 61 79 20 69 73 20 |....Thursday is |
Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-empty--X_GET-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== GET Request Text =========================== >>>
=========================== GET Request Text =========================== >>>

=========================== GET Response Text =========================== <<<

Expand Down
4 changes: 2 additions & 2 deletions test/results/echo-empty--X_GET_-v-expected.txt
Expand Up @@ -231,7 +231,7 @@ file: {
}
Looking up message with full name: happyday.HappyDayRequest
Looking up message with full name: happyday.HappyDayRequest
=========================== GET Request Text =========================== >>>
=========================== GET Request Text =========================== >>>

=========================== GET Request Binary =========================== >>>
Found curl: /usr/bin/curl
Expand All @@ -253,7 +253,7 @@ Total curl args:
=========================== GET Response Headers =========================== <<<
HTTP/1.1 200 OK
Content-Type: application/x-protobuf
Date: Wed, 04 Oct 2023 12:50:55 GMT
Date: Thu, 05 Oct 2023 09:18:15 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 0
Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-empty--X_HEAD-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== HEAD Request Text =========================== >>>
=========================== HEAD Request Text =========================== >>>

=========================== HEAD Response Text =========================== <<<

Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-empty--X_HEAD_--no-curl-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== HEAD Request Text =========================== >>>
=========================== HEAD Request Text =========================== >>>

######### STDERR #########
Error: HTTP method HEAD not supported with internal HTTP implementation. Please use curl.
Expand Down
4 changes: 2 additions & 2 deletions test/results/echo-empty--X_HEAD_-v-expected.txt
Expand Up @@ -231,7 +231,7 @@ file: {
}
Looking up message with full name: happyday.HappyDayRequest
Looking up message with full name: happyday.HappyDayRequest
=========================== HEAD Request Text =========================== >>>
=========================== HEAD Request Text =========================== >>>

=========================== HEAD Request Binary =========================== >>>
Found curl: /usr/bin/curl
Expand All @@ -253,7 +253,7 @@ Total curl args:
=========================== HEAD Response Headers =========================== <<<
HTTP/1.1 200 OK
Content-Type: application/x-protobuf
Date: Wed, 04 Oct 2023 12:50:02 GMT
Date: Thu, 05 Oct 2023 09:18:21 GMT
Connection: keep-alive
Keep-Alive: timeout=5
=========================== HEAD Response Binary =========================== <<<
Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-empty-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>

=========================== POST Response Text =========================== <<<

Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-empty-no-curl-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>

=========================== POST Response Text =========================== <<<

Expand Down
4 changes: 2 additions & 2 deletions test/results/echo-empty-with-curl-args--X_GET-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== GET Request Text =========================== >>>
=========================== GET Request Text =========================== >>>
includeReason: true
=========================== CURL ERROR ===========================
* Trying 127.0.0.1:8080...
Expand All @@ -16,7 +16,7 @@ includeReason: true
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/x-protobuf
< Date: Wed, 04 Oct 2023 08:57:18 GMT
< Date: Thu, 05 Oct 2023 09:18:28 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< Content-Length: 2
Expand Down
4 changes: 2 additions & 2 deletions test/results/echo-empty-with-curl-args-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
includeReason: true
=========================== CURL ERROR ===========================
* Trying 127.0.0.1:8080...
Expand All @@ -16,7 +16,7 @@ includeReason: true
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/x-protobuf
< Date: Tue, 03 Oct 2023 20:42:44 GMT
< Date: Thu, 05 Oct 2023 09:18:27 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< Content-Length: 2
Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-filled--X_GET-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== GET Request Text =========================== >>>
=========================== GET Request Text =========================== >>>
date: {
seconds: 1648044939
nanos: 152000000
Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-filled-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
date: {
seconds: 1648044939
nanos: 152000000
Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-filled-no-curl-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
date: {
seconds: 1648044939
nanos: 152000000
Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-full--X_GET-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== GET Request Text =========================== >>>
=========================== GET Request Text =========================== >>>
date: {
seconds: 1648044939
nanos: 152000000
Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-full-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== POST Request Text =========================== >>>
=========================== POST Request Text =========================== >>>
date: {
seconds: 1648044939
nanos: 152000000
Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-full-json--X_GET-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== GET Request JSON =========================== >>>
=========================== GET Request JSON =========================== >>>
{"includeReason":true,"double":0.12346789,"int32":123123123,"int64":"123123123123123","string":"some string here","bytes":"AAEC//79","fooEnum":"BAZ","misc":[{},{"weatherOfPastFewDays":["1","2"],"fooEnum":"FAZ"},{"fooString":"abc"}],"float":0.123}
=========================== GET Response JSON =========================== <<<
{"includeReason":true,"double":0.12346789,"int32":123123123,"int64":"123123123123123","string":"some string here","bytes":"AAEC//79","fooEnum":"BAZ","misc":[{},{"weatherOfPastFewDays":["1","2"],"fooEnum":"FAZ"},{"fooString":"abc"}],"float":0.123}
Expand Down
2 changes: 1 addition & 1 deletion test/results/echo-full-json-expected.txt
@@ -1,5 +1,5 @@
######### STDOUT #########
=========================== POST Request JSON =========================== >>>
=========================== POST Request JSON =========================== >>>
{"includeReason":true,"double":0.12346789,"int32":123123123,"int64":"123123123123123","string":"some string here","bytes":"AAEC//79","fooEnum":"BAZ","misc":[{},{"weatherOfPastFewDays":["1","2"],"fooEnum":"FAZ"},{"fooString":"abc"}],"float":0.123}
=========================== POST Response JSON =========================== <<<
{"includeReason":true,"double":0.12346789,"int32":123123123,"int64":"123123123123123","string":"some string here","bytes":"AAEC//79","fooEnum":"BAZ","misc":[{},{"weatherOfPastFewDays":["1","2"],"fooEnum":"FAZ"},{"fooString":"abc"}],"float":0.123}
Expand Down

0 comments on commit 5852fee

Please sign in to comment.