From 1104ea79d860ceca830e99e3103c81256bfa1bf5 Mon Sep 17 00:00:00 2001 From: GollyTicker Date: Tue, 17 May 2022 00:11:27 +0200 Subject: [PATCH] Decoding of raw messages into text format via omission of -o or --decode-raw. Json is not supported. --- EXAMPLES.md | 26 +- doc/generate-docs.sh | 20 ++ doc/generated.usage.txt | 6 +- doc/template.EXAMPLES.md | 15 + src/flags.go | 23 +- src/protoConversions.go | 8 +- src/protoRegistry.go | 14 + src/protocurl.go | 23 +- .../additional-curl-args-verbose-expected.txt | 5 +- test/results/far-future-json--v-expected.txt | 3 +- test/results/help-expected.txt | 6 +- test/results/help-missing-curl-expected.txt | 6 +- .../help-missing-curl-no-curl-expected.txt | 6 +- test/results/help-no-curl-expected.txt | 6 +- ...inferred-message-package-path-expected.txt | 3 +- ...path-name-clash-explicit-path-expected.txt | 3 +- test/results/json-in-text-output-expected.txt | 3 +- test/results/missing-args-expected.txt | 10 +- .../results/missing-args-no-curl-expected.txt | 10 +- .../results/missing-args-partial-expected.txt | 10 +- .../missing-args-partial-no-curl-expected.txt | 10 +- test/results/missing-protoc-expected.txt | 1 + .../missing-protoc-global-expected.txt | 1 + .../missing-protocurl-internal-expected.txt | 1 + test/results/moved-lib-expected.txt | 1 + ...-type-arg-inferred-decode-raw-expected.txt | 279 ++++++++++++++++++ ...type-arg-overidden-decode-raw-expected.txt | 277 +++++++++++++++++ test/results/text-in-json-output-expected.txt | 3 +- .../unknown-message-as-json-expected.txt | 4 + .../unknown-message-as-text-expected.txt | 10 + .../verbose-custom-headers-expected.txt | 3 +- test/results/verbose-expected.txt | 3 +- ...verbose-long-args-equals-args-expected.txt | 3 +- .../results/verbose-missing-curl-expected.txt | 3 +- test/results/verbose-no-curl-expected.txt | 3 +- test/suite/test.sh | 5 + test/suite/testcases.json | 29 ++ 37 files changed, 796 insertions(+), 46 deletions(-) create mode 100644 test/results/response-type-arg-inferred-decode-raw-expected.txt create mode 100644 test/results/response-type-arg-overidden-decode-raw-expected.txt create mode 100644 test/results/unknown-message-as-json-expected.txt create mode 100644 test/results/unknown-message-as-text-expected.txt diff --git a/EXAMPLES.md b/EXAMPLES.md index 15b7b5b..a24b530 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -35,6 +35,7 @@ formattedDate: "Thu, 01 Jan 1970 00:00:00 GMT" ``` **Explict full message package paths and explicit proto file** + ```bash $ docker run -v "$PWD/test/proto:/proto" --network host qaware/protocurl \ -f happyday.proto -i happyday.HappyDayRequest -o happyday.HappyDayResponse \ @@ -48,6 +49,7 @@ formattedDate: "Thu, 01 Jan 1970 00:00:00 GMT" ``` **Using imported and nested messages such as well-known Google Protobuf types** + ```bash $ docker run -v "$PWD/test/proto:/proto" --network host qaware/protocurl \ -i ..HappyDayRequest -o ..HappyDayResponse \ @@ -62,6 +64,27 @@ date: { formattedDate: "Wed, 23 Mar 2022 14:15:39 GMT" ``` +**Omitting -o \ shows raw format** + +```bash +$ docker run -v "$PWD/test/proto:/proto" --network host qaware/protocurl \ + -q -f happyday.proto -i happyday.HappyDayRequest \ + -u http://localhost:8080/happy-day/verify \ + -d "includeReason: true" + +1: 1 +2: "Thursday is a Happy Day! ⭐" +3: "Thu, 01 Jan 1970 00:00:00 GMT" +4: "" +``` + +When the response type is unknown or one wants to debug and see what is all in the response, +then this format shows the values for the given field numbers (instead of their field names). + +However, since +[Protobuf is not self-describing](https://developers.google.com/protocol-buffers/docs/techniques#self-description) +the types cannot be correctly inferred and may be incorrect. + **JSON** ```bash @@ -142,6 +165,7 @@ Invoked with following default & parsed arguments: "DataText": "date: { seconds: 1648044939}", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" @@ -386,7 +410,7 @@ Total curl args: =========================== Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:44:45 GMT +Date: Wed, 18 May 2022 20:30:02 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 35 diff --git a/doc/generate-docs.sh b/doc/generate-docs.sh index 23f83ab..2b15a1e 100755 --- a/doc/generate-docs.sh +++ b/doc/generate-docs.sh @@ -3,6 +3,11 @@ set -e WORKING_DIR="$1" +if [[ "$WORKING_DIR" == "" ]]; then + echo "Please provide the working directory as a a docker-mount friendly path." + exit 1 +fi + source test/suite/setup.sh ESCAPED="failed to substitute" @@ -117,6 +122,20 @@ $(docker run -v "$WORKING_DIR/test/proto:/proto" --network host protocurl \ escapeString "$EXAMPLE_OUTPUT_ONLY" EXAMPLE_OUTPUT_ONLY="$ESCAPED" +# EXAMPLE_RAW_FORMAT ============================= +EXAMPLE_RAW_FORMAT="\$ docker run -v \"\$PWD/test/proto:/proto\" --network host qaware/protocurl \\ + -q -f happyday.proto -i happyday.HappyDayRequest \\ + -u http://localhost:8080/happy-day/verify \\ + -d \"includeReason: true\" + +$(docker run -v "$WORKING_DIR/test/proto:/proto" --network host protocurl \ + -q -f happyday.proto -i happyday.HappyDayRequest \ + -u http://localhost:8080/happy-day/verify \ + -d "includeReason: true")" + +escapeString "$EXAMPLE_RAW_FORMAT" +EXAMPLE_RAW_FORMAT="$ESCAPED" + # EXAMPLE OUTPUT ONLY WITH ERROR ============================= EXAMPLE_OUTPUT_ONLY_WITH_ERR_1="\$ docker run -v \"\$PWD/test/proto:/proto\" --network host qaware/protocurl \\ -q -i ..HappyDayRequest -o ..HappyDayResponse \\ @@ -157,6 +176,7 @@ echo "$EXAMPLES_TEMPLATE" | sed "s%___EXAMPLE_1___%$EXAMPLE_1%" | sed "s%___EXAMPLE_2___%$EXAMPLE_2%" | sed "s%___EXAMPLE_3___%$EXAMPLE_3%" | + sed "s%___EXAMPLE_RAW_FORMAT__%$EXAMPLE_RAW_FORMAT%" | sed "s%___EXAMPLE_JSON___%$EXAMPLE_JSON%" | sed "s%___EXAMPLE_JSON_PRETTY___%$EXAMPLE_JSON_PRETTY%" | sed "s%___EXAMPLE_OUTPUT_ONLY___%$EXAMPLE_OUTPUT_ONLY%" | diff --git a/doc/generated.usage.txt b/doc/generated.usage.txt index 565862f..1cd84f8 100644 --- a/doc/generated.usage.txt +++ b/doc/generated.usage.txt @@ -11,8 +11,9 @@ The bundle also includes the google protobuf .proto files necessary to create Fi If the bundled 'protoc' is used, then these .proto files are included. Otherwise .proto files from the system-wide include are used. The Header 'Content-Type: application/x-protobuf' is set as a request header by default. When converting between binary and text, the encoding UTF-8 is always used. +When the correct response type is unknown or being debugged, omitting -o will attempt to show the response in raw format. -Bug reports: https://github.com/qaware/protocurl/issues +Enhancements and bugs: https://github.com/qaware/protocurl/issues Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" @@ -22,6 +23,7 @@ Flags: -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -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. @@ -34,7 +36,7 @@ Flags: --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. -i, --request-type string Mandatory: 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. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string Mandatory: The Protobuf response type. See -i + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. diff --git a/doc/template.EXAMPLES.md b/doc/template.EXAMPLES.md index 5c0bab3..204a1d6 100644 --- a/doc/template.EXAMPLES.md +++ b/doc/template.EXAMPLES.md @@ -25,15 +25,30 @@ ___EXAMPLE_1___ ``` **Explict full message package paths and explicit proto file** + ```bash ___EXAMPLE_2___ ``` **Using imported and nested messages such as well-known Google Protobuf types** + ```bash ___EXAMPLE_3___ ``` +**Omitting -o \ shows raw format** + +```bash +___EXAMPLE_RAW_FORMAT__ +``` + +When the response type is unknown or one wants to debug and see what is all in the response, +then this format shows the values for the given field numbers (instead of their field names). + +However, since +[Protobuf is not self-describing](https://developers.google.com/protocol-buffers/docs/techniques#self-description) +the types cannot be correctly inferred and may be incorrect. + **JSON** ```bash diff --git a/src/flags.go b/src/flags.go index 9d8388c..92eda17 100644 --- a/src/flags.go +++ b/src/flags.go @@ -60,8 +60,10 @@ func intialiseFlags() { AssertSuccess(rootCmd.MarkFlagRequired("request-type")) flags.StringVarP(&CurrentConfig.ResponseType, "response-type", "o", "", - "Mandatory: The Protobuf response type. See -i ") - AssertSuccess(rootCmd.MarkFlagRequired("response-type")) + "The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used.") + + flags.BoolVar(&CurrentConfig.DecodeRawResponse, "decode-raw", false, + "Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format "+string(OText)+" is supported. Use -o to see correct contents.") flags.StringVar(&tmpInTextType, "in", "", "Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON.") @@ -124,6 +126,19 @@ func propagateFlags() { CurrentConfig.DisplayBinaryAndHttp = false } + if CurrentConfig.ResponseType == "" && !CurrentConfig.DecodeRawResponse { + CurrentConfig.DecodeRawResponse = true + if CurrentConfig.Verbose { + fmt.Println("Response type (-o) was not provided, hence --decode-raw will be used.") + } + + } else if CurrentConfig.ResponseType != "" && CurrentConfig.DecodeRawResponse { + CurrentConfig.DecodeRawResponse = false + if CurrentConfig.Verbose { + fmt.Println("Response type (-o) was provided, hence --decode-raw will be overidden.") + } + } + if strings.HasPrefix(strings.TrimSpace(CurrentConfig.DataText), "{") { tmpDataTextInferredType = IJson } else { @@ -183,6 +198,10 @@ func propagateFlags() { } } + if CurrentConfig.DecodeRawResponse && (strings.Contains(string(CurrentConfig.OutTextType), "json")) { + PanicWithMessage("Decoding of raw messages is not supported with output format " + string(CurrentConfig.OutTextType) + ". Please use " + string(OText) + " instead.") + } + if CurrentConfig.ForceNoCurl && len(CurrentConfig.RequestHeaders) != 0 { PanicDueToUnsupportedHeadersWhenInternalHttp(CurrentConfig.RequestHeaders) } diff --git a/src/protoConversions.go b/src/protoConversions.go index 5a469a1..d80c2a0 100644 --- a/src/protoConversions.go +++ b/src/protoConversions.go @@ -72,7 +72,7 @@ func protoBinaryToMsgAndText(messageType string, binary []byte, outFormat OutTex var textBytes = []byte{} switch outFormat { case OText: - textBytes, err = textFormatOptions.Marshal(msg) + textBytes, err = formatUnknownFieldsIfApplicable(textFormatOptions).Marshal(msg) case OJsonDense: textBytes, err = jsonDenseformatOptions.Marshal(msg) case OJsonPretty: @@ -85,3 +85,9 @@ func protoBinaryToMsgAndText(messageType string, binary []byte, outFormat OutTex return text, msg } + +func formatUnknownFieldsIfApplicable(opts prototext.MarshalOptions) prototext.MarshalOptions { + newOpts := opts // shallow copy + newOpts.EmitUnknown = true + return newOpts +} diff --git a/src/protoRegistry.go b/src/protoRegistry.go index f78cc56..12e1d94 100644 --- a/src/protoRegistry.go +++ b/src/protoRegistry.go @@ -19,10 +19,13 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" "google.golang.org/protobuf/types/descriptorpb" + "google.golang.org/protobuf/types/known/emptypb" ) const protoFileExtension = ".proto" +const WellKnownEmptyMessageType = "google.protobuf.Empty" + /* Given a directory of .proto files, we use `protoc` to convert these to an equivalent FileDescriptorSet payload where imports have been resolved. @@ -96,9 +99,20 @@ func convertProtoFilesToProtoRegistryFiles() *protoregistry.Files { protoRegistryFiles, err := protodesc.NewFiles(&protoFileDescriptorSet) PanicOnError(err) + if CurrentConfig.DecodeRawResponse { + if CurrentConfig.Verbose { + fmt.Printf("Adding %s to proto registry to ensure it can be used for decoding raw Protobuf.\n", WellKnownEmptyMessageType) + } + _ = protoRegistryFiles.RegisterFile(wellKnownEmptyMessageProtoFileDescriptorForRawFormat()) + } + return protoRegistryFiles } +func wellKnownEmptyMessageProtoFileDescriptorForRawFormat() protoreflect.FileDescriptor { + return emptypb.File_google_protobuf_empty_proto +} + func collectRelevantProtoFiles() []string { if CurrentConfig.InferProtoFiles { if CurrentConfig.Verbose { diff --git a/src/protocurl.go b/src/protocurl.go index 1aa7624..915b6b6 100644 --- a/src/protocurl.go +++ b/src/protocurl.go @@ -10,7 +10,7 @@ import ( ) const GithubRepositoryLink = "https://github.com/qaware/protocurl" -const BugReportsLink = "https://github.com/qaware/protocurl/issues" +const EnhancementsAndBugsLink = "https://github.com/qaware/protocurl/issues" type Config struct { ProtoFilesDir string @@ -21,6 +21,7 @@ type Config struct { DataText string InTextType InTextType OutTextType OutTextType + DecodeRawResponse bool DisplayBinaryAndHttp bool RequestHeaders []string CustomCurlPath string @@ -65,8 +66,9 @@ var rootCmd = &cobra.Command{ "The bundle also includes the google protobuf .proto files necessary to create FileDescriptorSet payloads via '" + ProtocExecutableName + "'.\n" + "If the bundled '" + ProtocExecutableName + "' is used, then these .proto files are included. Otherwise .proto files from the system-wide include are used.\n" + "The Header 'Content-Type: application/x-protobuf' is set as a request header by default.\n" + - "When converting between binary and text, the encoding UTF-8 is always used.\n\n" + - "Bug reports: " + BugReportsLink, + "When converting between binary and text, the encoding UTF-8 is always used.\n" + + "When the correct response type is unknown or being debugged, omitting -o will attempt to show the response in raw format.\n\n" + + "Enhancements and bugs: " + EnhancementsAndBugsLink, Example: " protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d \"myField: true, otherField: 1337\"", Args: cobra.OnlyValidArgs, DisableFlagsInUseLine: true, @@ -147,7 +149,9 @@ func decodeResponse(responseBinary []byte, responseHeaders string, registry *pro fmt.Printf("%s Response Binary %s %s\n%s", VISUAL_SEPARATOR, VISUAL_SEPARATOR, RECV, hex.Dump(responseBinary)) } - responseText, _ := protoBinaryToMsgAndText(CurrentConfig.ResponseType, responseBinary, CurrentConfig.OutTextType, registry) + responseMessageType := properResponseTypeIfProvidedOrEmptyType() + + responseText, _ := protoBinaryToMsgAndText(responseMessageType, responseBinary, CurrentConfig.OutTextType, registry) if !CurrentConfig.ShowOutputOnly { fmt.Printf("%s Response %s %s %s\n", @@ -156,6 +160,17 @@ func decodeResponse(responseBinary []byte, responseHeaders string, registry *pro fmt.Printf("%s\n", responseText) } +func properResponseTypeIfProvidedOrEmptyType() string { + if CurrentConfig.ResponseType != "" { + return CurrentConfig.ResponseType + } else { + if CurrentConfig.Verbose { + fmt.Printf("Decoding response against %s as no response type was provided.\n", WellKnownEmptyMessageType) + } + return WellKnownEmptyMessageType + } +} + func addDefaultHeaderArgument() { if CurrentConfig.Verbose { fmt.Printf("Adding default header argument to request headers : %s\n", DefaultHeaders) diff --git a/test/results/additional-curl-args-verbose-expected.txt b/test/results/additional-curl-args-verbose-expected.txt index 4c2580b..8fddf2e 100644 --- a/test/results/additional-curl-args-verbose-expected.txt +++ b/test/results/additional-curl-args-verbose-expected.txt @@ -13,6 +13,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true, date: { seconds: 1642044939, nanos: 152000000 }", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" @@ -276,7 +277,7 @@ Total curl args: * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Content-Type: application/x-protobuf -< Date: Tue, 26 Apr 2022 22:34:37 GMT +< Date: Mon, 16 May 2022 22:09:07 GMT < Connection: keep-alive < Keep-Alive: timeout=5 < Content-Length: 65 @@ -287,7 +288,7 @@ Total curl args: =========================== Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:34:37 GMT +Date: Mon, 16 May 2022 22:09:07 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/far-future-json--v-expected.txt b/test/results/far-future-json--v-expected.txt index 784a50c..7358531 100644 --- a/test/results/far-future-json--v-expected.txt +++ b/test/results/far-future-json--v-expected.txt @@ -13,6 +13,7 @@ Invoked with following default & parsed arguments: "DataText": "{ \"includeReason\": true, \"date\": \"9999-12-31T23:59:59Z\"}", "InTextType": "json", "OutTextType": "json", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" @@ -255,7 +256,7 @@ Total curl args: =========================== Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:34:54 GMT +Date: Mon, 16 May 2022 22:09:10 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 63 diff --git a/test/results/help-expected.txt b/test/results/help-expected.txt index 3f4bb94..6acdd58 100644 --- a/test/results/help-expected.txt +++ b/test/results/help-expected.txt @@ -12,8 +12,9 @@ The bundle also includes the google protobuf .proto files necessary to create Fi If the bundled 'protoc' is used, then these .proto files are included. Otherwise .proto files from the system-wide include are used. The Header 'Content-Type: application/x-protobuf' is set as a request header by default. When converting between binary and text, the encoding UTF-8 is always used. +When the correct response type is unknown or being debugged, omitting -o will attempt to show the response in raw format. -Bug reports: https://github.com/qaware/protocurl/issues +Enhancements and bugs: https://github.com/qaware/protocurl/issues Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" @@ -23,6 +24,7 @@ Flags: -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -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. @@ -35,7 +37,7 @@ Flags: --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. -i, --request-type string Mandatory: 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. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string Mandatory: The Protobuf response type. See -i + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. diff --git a/test/results/help-missing-curl-expected.txt b/test/results/help-missing-curl-expected.txt index 3f4bb94..6acdd58 100644 --- a/test/results/help-missing-curl-expected.txt +++ b/test/results/help-missing-curl-expected.txt @@ -12,8 +12,9 @@ The bundle also includes the google protobuf .proto files necessary to create Fi If the bundled 'protoc' is used, then these .proto files are included. Otherwise .proto files from the system-wide include are used. The Header 'Content-Type: application/x-protobuf' is set as a request header by default. When converting between binary and text, the encoding UTF-8 is always used. +When the correct response type is unknown or being debugged, omitting -o will attempt to show the response in raw format. -Bug reports: https://github.com/qaware/protocurl/issues +Enhancements and bugs: https://github.com/qaware/protocurl/issues Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" @@ -23,6 +24,7 @@ Flags: -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -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. @@ -35,7 +37,7 @@ Flags: --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. -i, --request-type string Mandatory: 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. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string Mandatory: The Protobuf response type. See -i + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. diff --git a/test/results/help-missing-curl-no-curl-expected.txt b/test/results/help-missing-curl-no-curl-expected.txt index 3f4bb94..6acdd58 100644 --- a/test/results/help-missing-curl-no-curl-expected.txt +++ b/test/results/help-missing-curl-no-curl-expected.txt @@ -12,8 +12,9 @@ The bundle also includes the google protobuf .proto files necessary to create Fi If the bundled 'protoc' is used, then these .proto files are included. Otherwise .proto files from the system-wide include are used. The Header 'Content-Type: application/x-protobuf' is set as a request header by default. When converting between binary and text, the encoding UTF-8 is always used. +When the correct response type is unknown or being debugged, omitting -o will attempt to show the response in raw format. -Bug reports: https://github.com/qaware/protocurl/issues +Enhancements and bugs: https://github.com/qaware/protocurl/issues Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" @@ -23,6 +24,7 @@ Flags: -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -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. @@ -35,7 +37,7 @@ Flags: --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. -i, --request-type string Mandatory: 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. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string Mandatory: The Protobuf response type. See -i + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. diff --git a/test/results/help-no-curl-expected.txt b/test/results/help-no-curl-expected.txt index 3f4bb94..6acdd58 100644 --- a/test/results/help-no-curl-expected.txt +++ b/test/results/help-no-curl-expected.txt @@ -12,8 +12,9 @@ The bundle also includes the google protobuf .proto files necessary to create Fi If the bundled 'protoc' is used, then these .proto files are included. Otherwise .proto files from the system-wide include are used. The Header 'Content-Type: application/x-protobuf' is set as a request header by default. When converting between binary and text, the encoding UTF-8 is always used. +When the correct response type is unknown or being debugged, omitting -o will attempt to show the response in raw format. -Bug reports: https://github.com/qaware/protocurl/issues +Enhancements and bugs: https://github.com/qaware/protocurl/issues Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" @@ -23,6 +24,7 @@ Flags: -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -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. @@ -35,7 +37,7 @@ Flags: --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. -i, --request-type string Mandatory: 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. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string Mandatory: The Protobuf response type. See -i + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. diff --git a/test/results/inferred-message-package-path-expected.txt b/test/results/inferred-message-package-path-expected.txt index bd50b69..800e202 100644 --- a/test/results/inferred-message-package-path-expected.txt +++ b/test/results/inferred-message-package-path-expected.txt @@ -12,6 +12,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true, date: { seconds: 1648044939, nanos: 152000000 }", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" @@ -257,7 +258,7 @@ Total curl args: =========================== Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:32:39 GMT +Date: Mon, 16 May 2022 22:08:45 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 68 diff --git a/test/results/inferred-message-package-path-name-clash-explicit-path-expected.txt b/test/results/inferred-message-package-path-name-clash-explicit-path-expected.txt index a0d73c1..3b9c75a 100644 --- a/test/results/inferred-message-package-path-name-clash-explicit-path-expected.txt +++ b/test/results/inferred-message-package-path-name-clash-explicit-path-expected.txt @@ -13,6 +13,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true, date: { seconds: 1648044939, nanos: 152000000 }", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" @@ -322,7 +323,7 @@ Total curl args: =========================== Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:33:01 GMT +Date: Mon, 16 May 2022 22:08:50 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 68 diff --git a/test/results/json-in-text-output-expected.txt b/test/results/json-in-text-output-expected.txt index 442fbad..224b09d 100644 --- a/test/results/json-in-text-output-expected.txt +++ b/test/results/json-in-text-output-expected.txt @@ -13,6 +13,7 @@ Invoked with following default & parsed arguments: "DataText": "{ \"includeReason\": true, \"date\": \"2022-03-23T14:15:39Z\" }", "InTextType": "json", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" @@ -255,7 +256,7 @@ Total curl args: =========================== Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:33:35 GMT +Date: Mon, 16 May 2022 22:08:57 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 68 diff --git a/test/results/missing-args-expected.txt b/test/results/missing-args-expected.txt index 348c090..ec029e8 100644 --- a/test/results/missing-args-expected.txt +++ b/test/results/missing-args-expected.txt @@ -1,6 +1,6 @@ ######### STDOUT ######### ######### STDERR ######### -Error: required flag(s) "data-text","request-type","response-type","url" not set +Error: required flag(s) "data-text","request-type","url" not set Usage: protocurl [flags] -I proto-dir -i request-type -o response-type -u url -d request-text @@ -10,8 +10,9 @@ The bundle also includes the google protobuf .proto files necessary to create Fi If the bundled 'protoc' is used, then these .proto files are included. Otherwise .proto files from the system-wide include are used. The Header 'Content-Type: application/x-protobuf' is set as a request header by default. When converting between binary and text, the encoding UTF-8 is always used. +When the correct response type is unknown or being debugged, omitting -o will attempt to show the response in raw format. -Bug reports: https://github.com/qaware/protocurl/issues +Enhancements and bugs: https://github.com/qaware/protocurl/issues Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" @@ -21,6 +22,7 @@ Flags: -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -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. @@ -33,11 +35,11 @@ Flags: --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. -i, --request-type string Mandatory: 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. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string Mandatory: The Protobuf response type. See -i + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. --version version for protocurl -Error: required flag(s) "data-text","request-type","response-type","url" not set +Error: required flag(s) "data-text","request-type","url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-args-no-curl-expected.txt b/test/results/missing-args-no-curl-expected.txt index 348c090..ec029e8 100644 --- a/test/results/missing-args-no-curl-expected.txt +++ b/test/results/missing-args-no-curl-expected.txt @@ -1,6 +1,6 @@ ######### STDOUT ######### ######### STDERR ######### -Error: required flag(s) "data-text","request-type","response-type","url" not set +Error: required flag(s) "data-text","request-type","url" not set Usage: protocurl [flags] -I proto-dir -i request-type -o response-type -u url -d request-text @@ -10,8 +10,9 @@ The bundle also includes the google protobuf .proto files necessary to create Fi If the bundled 'protoc' is used, then these .proto files are included. Otherwise .proto files from the system-wide include are used. The Header 'Content-Type: application/x-protobuf' is set as a request header by default. When converting between binary and text, the encoding UTF-8 is always used. +When the correct response type is unknown or being debugged, omitting -o will attempt to show the response in raw format. -Bug reports: https://github.com/qaware/protocurl/issues +Enhancements and bugs: https://github.com/qaware/protocurl/issues Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" @@ -21,6 +22,7 @@ Flags: -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -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. @@ -33,11 +35,11 @@ Flags: --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. -i, --request-type string Mandatory: 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. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string Mandatory: The Protobuf response type. See -i + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. --version version for protocurl -Error: required flag(s) "data-text","request-type","response-type","url" not set +Error: required flag(s) "data-text","request-type","url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-args-partial-expected.txt b/test/results/missing-args-partial-expected.txt index 973af63..dccdbaf 100644 --- a/test/results/missing-args-partial-expected.txt +++ b/test/results/missing-args-partial-expected.txt @@ -1,6 +1,6 @@ ######### STDOUT ######### ######### STDERR ######### -Error: required flag(s) "data-text","response-type","url" not set +Error: required flag(s) "data-text","url" not set Usage: protocurl [flags] -I proto-dir -i request-type -o response-type -u url -d request-text @@ -10,8 +10,9 @@ The bundle also includes the google protobuf .proto files necessary to create Fi If the bundled 'protoc' is used, then these .proto files are included. Otherwise .proto files from the system-wide include are used. The Header 'Content-Type: application/x-protobuf' is set as a request header by default. When converting between binary and text, the encoding UTF-8 is always used. +When the correct response type is unknown or being debugged, omitting -o will attempt to show the response in raw format. -Bug reports: https://github.com/qaware/protocurl/issues +Enhancements and bugs: https://github.com/qaware/protocurl/issues Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" @@ -21,6 +22,7 @@ Flags: -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -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. @@ -33,11 +35,11 @@ Flags: --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. -i, --request-type string Mandatory: 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. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string Mandatory: The Protobuf response type. See -i + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. --version version for protocurl -Error: required flag(s) "data-text","response-type","url" not set +Error: required flag(s) "data-text","url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-args-partial-no-curl-expected.txt b/test/results/missing-args-partial-no-curl-expected.txt index 973af63..dccdbaf 100644 --- a/test/results/missing-args-partial-no-curl-expected.txt +++ b/test/results/missing-args-partial-no-curl-expected.txt @@ -1,6 +1,6 @@ ######### STDOUT ######### ######### STDERR ######### -Error: required flag(s) "data-text","response-type","url" not set +Error: required flag(s) "data-text","url" not set Usage: protocurl [flags] -I proto-dir -i request-type -o response-type -u url -d request-text @@ -10,8 +10,9 @@ The bundle also includes the google protobuf .proto files necessary to create Fi If the bundled 'protoc' is used, then these .proto files are included. Otherwise .proto files from the system-wide include are used. The Header 'Content-Type: application/x-protobuf' is set as a request header by default. When converting between binary and text, the encoding UTF-8 is always used. +When the correct response type is unknown or being debugged, omitting -o will attempt to show the response in raw format. -Bug reports: https://github.com/qaware/protocurl/issues +Enhancements and bugs: https://github.com/qaware/protocurl/issues Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" @@ -21,6 +22,7 @@ Flags: -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -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. @@ -33,11 +35,11 @@ Flags: --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. -i, --request-type string Mandatory: 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. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string Mandatory: The Protobuf response type. See -i + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. --version version for protocurl -Error: required flag(s) "data-text","response-type","url" not set +Error: required flag(s) "data-text","url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-protoc-expected.txt b/test/results/missing-protoc-expected.txt index 49b3d4b..52a3f9a 100644 --- a/test/results/missing-protoc-expected.txt +++ b/test/results/missing-protoc-expected.txt @@ -13,6 +13,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" diff --git a/test/results/missing-protoc-global-expected.txt b/test/results/missing-protoc-global-expected.txt index a631cb6..cbf1f3a 100644 --- a/test/results/missing-protoc-global-expected.txt +++ b/test/results/missing-protoc-global-expected.txt @@ -13,6 +13,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" diff --git a/test/results/missing-protocurl-internal-expected.txt b/test/results/missing-protocurl-internal-expected.txt index 856366b..38673cb 100644 --- a/test/results/missing-protocurl-internal-expected.txt +++ b/test/results/missing-protocurl-internal-expected.txt @@ -13,6 +13,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" diff --git a/test/results/moved-lib-expected.txt b/test/results/moved-lib-expected.txt index 4a7738e..54d9493 100644 --- a/test/results/moved-lib-expected.txt +++ b/test/results/moved-lib-expected.txt @@ -13,6 +13,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" diff --git a/test/results/response-type-arg-inferred-decode-raw-expected.txt b/test/results/response-type-arg-inferred-decode-raw-expected.txt new file mode 100644 index 0000000..796cba7 --- /dev/null +++ b/test/results/response-type-arg-inferred-decode-raw-expected.txt @@ -0,0 +1,279 @@ +######### STDOUT ######### +Response type (-o) was not provided, hence --decode-raw will be used. +Inferred input text type as text. +Infering proto files (-F), since -f was not provided. +protocurl , build , https://github.com/qaware/protocurl +Adding default header argument to request headers : [Content-Type: application/x-protobuf] +Invoked with following default & parsed arguments: +{ + "ProtoFilesDir": "/proto", + "ProtoInputFilePath": "", + "RequestType": "..HappyDayRequest", + "ResponseType": "", + "Url": "http://localhost:8080/happy-day/verify", + "DataText": "includeReason: true", + "InTextType": "text", + "OutTextType": "text", + "DecodeRawResponse": true, + "DisplayBinaryAndHttp": true, + "RequestHeaders": [ + "Content-Type: application/x-protobuf" + ], + "CustomCurlPath": "", + "AdditionalCurlArgs": "", + "Verbose": true, + "ShowOutputOnly": false, + "ForceNoCurl": false, + "ForceCurl": false, + "GlobalProtoc": false, + "CustomProtocPath": "", + "InferProtoFiles": true +} +Found bundled protoc at /protocurl/protocurl-internal/bin/protoc +Using google protobuf include: /protocurl/protocurl-internal/include +Converting all files in /proto to a FileDescriptorSet. +Found .proto: happyday.proto +=========================== .proto descriptor =========================== +file: { + name: "google/protobuf/timestamp.proto" + package: "google.protobuf" + message_type: { + name: "Timestamp" + field: { + name: "seconds" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT64 + json_name: "seconds" + } + field: { + name: "nanos" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + json_name: "nanos" + } + } + options: { + java_package: "com.google.protobuf" + java_outer_classname: "TimestampProto" + java_multiple_files: true + go_package: "google.golang.org/protobuf/types/known/timestamppb" + cc_enable_arenas: true + objc_class_prefix: "GPB" + csharp_namespace: "Google.Protobuf.WellKnownTypes" + } + syntax: "proto3" +} +file: { + name: "happyday.proto" + package: "happyday" + dependency: "google/protobuf/timestamp.proto" + message_type: { + name: "HappyDayRequest" + field: { + name: "date" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".google.protobuf.Timestamp" + json_name: "date" + } + field: { + name: "includeReason" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BOOL + json_name: "includeReason" + } + field: { + name: "double" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_DOUBLE + json_name: "double" + } + field: { + name: "int32" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_INT32 + json_name: "int32" + } + field: { + name: "int64" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_INT64 + json_name: "int64" + } + field: { + name: "string" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "string" + } + field: { + name: "bytes" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_BYTES + json_name: "bytes" + } + field: { + name: "fooEnum" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".happyday.Foo" + json_name: "fooEnum" + } + field: { + name: "misc" + number: 9 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".happyday.MiscInfo" + json_name: "misc" + } + field: { + name: "float" + number: 10 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + json_name: "float" + } + field: { + name: "NonCamel_case_FieldName" + number: 11 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "NonCamelCaseFieldName" + } + } + message_type: { + name: "HappyDayResponse" + field: { + name: "isHappyDay" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_BOOL + json_name: "isHappyDay" + } + field: { + name: "reason" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "reason" + } + field: { + name: "formattedDate" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "formattedDate" + } + field: { + name: "err" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "err" + } + } + message_type: { + name: "MiscInfo" + field: { + name: "weatherOfPastFewDays" + number: 1 + label: LABEL_REPEATED + type: TYPE_STRING + json_name: "weatherOfPastFewDays" + } + field: { + name: "fooString" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + oneof_index: 0 + json_name: "fooString" + } + field: { + name: "fooEnum" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".happyday.Foo" + oneof_index: 0 + json_name: "fooEnum" + } + oneof_decl: { + name: "alternative" + } + } + enum_type: { + name: "Foo" + value: { + name: "BAR" + number: 0 + } + value: { + name: "BAZ" + number: 1 + } + value: { + name: "FAZ" + number: 2 + } + } + syntax: "proto3" +} +Adding google.protobuf.Empty to proto registry to ensure it can be used for decoding raw Protobuf. +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] +=========================== Request Text =========================== >>> +includeReason: true +=========================== Request Binary =========================== >>> +00000000 10 01 |..| +Found curl: /usr/bin/curl +Invoking curl http request. +Understood additional curl args: [] +Total curl args: + -s + -X + POST + --data-binary + @ + --output + + --dump-header + + -H + Content-Type: application/x-protobuf + http://localhost:8080/happy-day/verify +=========================== Response Headers =========================== <<< +HTTP/1.1 200 OK +Content-Type: application/x-protobuf +Date: Tue, 17 May 2022 21:49:45 GMT +Connection: keep-alive +Keep-Alive: timeout=5 +Content-Length: 65 +=========================== Response Binary =========================== <<< +00000000 08 01 12 1c 54 68 75 72 73 64 61 79 20 69 73 20 |....Thursday is | +00000010 61 20 48 61 70 70 79 20 44 61 79 21 20 e2 ad 90 |a Happy Day! ...| +00000020 1a 1d 54 68 75 2c 20 30 31 20 4a 61 6e 20 31 39 |..Thu, 01 Jan 19| +00000030 37 30 20 30 30 3a 30 30 3a 30 30 20 47 4d 54 22 |70 00:00:00 GMT"| +00000040 00 |.| +Decoding response against google.protobuf.Empty as no response type was provided. +Looking up message with full name: google.protobuf.Empty +=========================== Response Text =========================== <<< +1: 1 +2: "Thursday is a Happy Day! ⭐" +3: "Thu, 01 Jan 1970 00:00:00 GMT" +4: "" +######### STDERR ######### +######### EXIT 0 ######### diff --git a/test/results/response-type-arg-overidden-decode-raw-expected.txt b/test/results/response-type-arg-overidden-decode-raw-expected.txt new file mode 100644 index 0000000..0147a7a --- /dev/null +++ b/test/results/response-type-arg-overidden-decode-raw-expected.txt @@ -0,0 +1,277 @@ +######### STDOUT ######### +Response type (-o) was provided, hence --decode-raw will be overidden. +Inferred input text type as text. +Infering proto files (-F), since -f was not provided. +protocurl , build , https://github.com/qaware/protocurl +Adding default header argument to request headers : [Content-Type: application/x-protobuf] +Invoked with following default & parsed arguments: +{ + "ProtoFilesDir": "/proto", + "ProtoInputFilePath": "", + "RequestType": "..HappyDayRequest", + "ResponseType": "..HappyDayResponse", + "Url": "http://localhost:8080/happy-day/verify", + "DataText": "includeReason: true", + "InTextType": "text", + "OutTextType": "text", + "DecodeRawResponse": false, + "DisplayBinaryAndHttp": true, + "RequestHeaders": [ + "Content-Type: application/x-protobuf" + ], + "CustomCurlPath": "", + "AdditionalCurlArgs": "", + "Verbose": true, + "ShowOutputOnly": false, + "ForceNoCurl": false, + "ForceCurl": false, + "GlobalProtoc": false, + "CustomProtocPath": "", + "InferProtoFiles": true +} +Found bundled protoc at /protocurl/protocurl-internal/bin/protoc +Using google protobuf include: /protocurl/protocurl-internal/include +Converting all files in /proto to a FileDescriptorSet. +Found .proto: happyday.proto +=========================== .proto descriptor =========================== +file: { + name: "google/protobuf/timestamp.proto" + package: "google.protobuf" + message_type: { + name: "Timestamp" + field: { + name: "seconds" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT64 + json_name: "seconds" + } + field: { + name: "nanos" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + json_name: "nanos" + } + } + options: { + java_package: "com.google.protobuf" + java_outer_classname: "TimestampProto" + java_multiple_files: true + go_package: "google.golang.org/protobuf/types/known/timestamppb" + cc_enable_arenas: true + objc_class_prefix: "GPB" + csharp_namespace: "Google.Protobuf.WellKnownTypes" + } + syntax: "proto3" +} +file: { + name: "happyday.proto" + package: "happyday" + dependency: "google/protobuf/timestamp.proto" + message_type: { + name: "HappyDayRequest" + field: { + name: "date" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".google.protobuf.Timestamp" + json_name: "date" + } + field: { + name: "includeReason" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BOOL + json_name: "includeReason" + } + field: { + name: "double" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_DOUBLE + json_name: "double" + } + field: { + name: "int32" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_INT32 + json_name: "int32" + } + field: { + name: "int64" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_INT64 + json_name: "int64" + } + field: { + name: "string" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "string" + } + field: { + name: "bytes" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_BYTES + json_name: "bytes" + } + field: { + name: "fooEnum" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".happyday.Foo" + json_name: "fooEnum" + } + field: { + name: "misc" + number: 9 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".happyday.MiscInfo" + json_name: "misc" + } + field: { + name: "float" + number: 10 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + json_name: "float" + } + field: { + name: "NonCamel_case_FieldName" + number: 11 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "NonCamelCaseFieldName" + } + } + message_type: { + name: "HappyDayResponse" + field: { + name: "isHappyDay" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_BOOL + json_name: "isHappyDay" + } + field: { + name: "reason" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "reason" + } + field: { + name: "formattedDate" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "formattedDate" + } + field: { + name: "err" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "err" + } + } + message_type: { + name: "MiscInfo" + field: { + name: "weatherOfPastFewDays" + number: 1 + label: LABEL_REPEATED + type: TYPE_STRING + json_name: "weatherOfPastFewDays" + } + field: { + name: "fooString" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + oneof_index: 0 + json_name: "fooString" + } + field: { + name: "fooEnum" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".happyday.Foo" + oneof_index: 0 + json_name: "fooEnum" + } + oneof_decl: { + name: "alternative" + } + } + enum_type: { + name: "Foo" + value: { + name: "BAR" + number: 0 + } + value: { + name: "BAZ" + number: 1 + } + value: { + name: "FAZ" + number: 2 + } + } + syntax: "proto3" +} +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] +=========================== Request Text =========================== >>> +includeReason: true +=========================== Request Binary =========================== >>> +00000000 10 01 |..| +Found curl: /usr/bin/curl +Invoking curl http request. +Understood additional curl args: [] +Total curl args: + -s + -X + POST + --data-binary + @ + --output + + --dump-header + + -H + Content-Type: application/x-protobuf + http://localhost:8080/happy-day/verify +=========================== Response Headers =========================== <<< +HTTP/1.1 200 OK +Content-Type: application/x-protobuf +Date: Tue, 17 May 2022 21:49:46 GMT +Connection: keep-alive +Keep-Alive: timeout=5 +Content-Length: 65 +=========================== Response Binary =========================== <<< +00000000 08 01 12 1c 54 68 75 72 73 64 61 79 20 69 73 20 |....Thursday is | +00000010 61 20 48 61 70 70 79 20 44 61 79 21 20 e2 ad 90 |a Happy Day! ...| +00000020 1a 1d 54 68 75 2c 20 30 31 20 4a 61 6e 20 31 39 |..Thu, 01 Jan 19| +00000030 37 30 20 30 30 3a 30 30 3a 30 30 20 47 4d 54 22 |70 00:00:00 GMT"| +00000040 00 |.| +Searching for message with base name: HappyDayResponse +Resolved message package-paths for name HappyDayResponse: [happyday.HappyDayResponse] +=========================== Response Text =========================== <<< +isHappyDay: true +reason: "Thursday is a Happy Day! ⭐" +formattedDate: "Thu, 01 Jan 1970 00:00:00 GMT" +######### STDERR ######### +######### EXIT 0 ######### diff --git a/test/results/text-in-json-output-expected.txt b/test/results/text-in-json-output-expected.txt index 70c0d41..c631083 100644 --- a/test/results/text-in-json-output-expected.txt +++ b/test/results/text-in-json-output-expected.txt @@ -13,6 +13,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true, date: { seconds: 1648044939, nanos: 152000000 }", "InTextType": "text", "OutTextType": "json", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" @@ -259,7 +260,7 @@ Total curl args: =========================== Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:33:33 GMT +Date: Mon, 16 May 2022 22:08:56 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 68 diff --git a/test/results/unknown-message-as-json-expected.txt b/test/results/unknown-message-as-json-expected.txt new file mode 100644 index 0000000..ae6f485 --- /dev/null +++ b/test/results/unknown-message-as-json-expected.txt @@ -0,0 +1,4 @@ +######### STDOUT ######### +######### STDERR ######### +Error: Decoding of raw messages is not supported with output format json. Please use text instead. +######### EXIT 1 ######### diff --git a/test/results/unknown-message-as-text-expected.txt b/test/results/unknown-message-as-text-expected.txt new file mode 100644 index 0000000..8dc9223 --- /dev/null +++ b/test/results/unknown-message-as-text-expected.txt @@ -0,0 +1,10 @@ +######### STDOUT ######### +=========================== Request Text =========================== >>> +includeReason: true +=========================== Response Text =========================== <<< +1: 1 +2: "Thursday is a Happy Day! ⭐" +3: "Thu, 01 Jan 1970 00:00:00 GMT" +4: "" +######### STDERR ######### +######### EXIT 0 ######### diff --git a/test/results/verbose-custom-headers-expected.txt b/test/results/verbose-custom-headers-expected.txt index 0871b11..c89e9c5 100644 --- a/test/results/verbose-custom-headers-expected.txt +++ b/test/results/verbose-custom-headers-expected.txt @@ -13,6 +13,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true, date: { seconds: 1642044939, nanos: 152000000 }", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf", @@ -265,7 +266,7 @@ Total curl args: =========================== Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:34:08 GMT +Date: Mon, 16 May 2022 22:09:03 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/verbose-expected.txt b/test/results/verbose-expected.txt index 7cfca0b..0100623 100644 --- a/test/results/verbose-expected.txt +++ b/test/results/verbose-expected.txt @@ -12,6 +12,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true, date: { seconds: 1642044939, nanos: 152000000 }", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" @@ -255,7 +256,7 @@ Total curl args: =========================== Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:33:59 GMT +Date: Mon, 16 May 2022 22:09:01 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/verbose-long-args-equals-args-expected.txt b/test/results/verbose-long-args-equals-args-expected.txt index d87ba2e..8e929ec 100644 --- a/test/results/verbose-long-args-equals-args-expected.txt +++ b/test/results/verbose-long-args-equals-args-expected.txt @@ -12,6 +12,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true, date: { seconds: 1642044939, nanos: 152000000 }", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" @@ -255,7 +256,7 @@ Total curl args: =========================== Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:34:05 GMT +Date: Mon, 16 May 2022 22:09:02 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/verbose-missing-curl-expected.txt b/test/results/verbose-missing-curl-expected.txt index 893a61d..c7865f2 100644 --- a/test/results/verbose-missing-curl-expected.txt +++ b/test/results/verbose-missing-curl-expected.txt @@ -13,6 +13,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true, date: { seconds: 1642044939, nanos: 152000000 }", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" @@ -247,7 +248,7 @@ HTTP/1.1 200 OK Content-Length: 65 Connection: keep-alive Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:34:13 GMT +Date: Mon, 16 May 2022 22:09:04 GMT Keep-Alive: timeout=5 =========================== Response Binary =========================== <<< 00000000 08 01 12 1c 54 68 75 72 73 64 61 79 20 69 73 20 |....Thursday is | diff --git a/test/results/verbose-no-curl-expected.txt b/test/results/verbose-no-curl-expected.txt index 84b71fa..3667904 100644 --- a/test/results/verbose-no-curl-expected.txt +++ b/test/results/verbose-no-curl-expected.txt @@ -12,6 +12,7 @@ Invoked with following default & parsed arguments: "DataText": "includeReason: true, date: { seconds: 1642044939, nanos: 152000000 }", "InTextType": "text", "OutTextType": "text", + "DecodeRawResponse": false, "DisplayBinaryAndHttp": true, "RequestHeaders": [ "Content-Type: application/x-protobuf" @@ -243,7 +244,7 @@ HTTP/1.1 200 OK Content-Length: 65 Connection: keep-alive Content-Type: application/x-protobuf -Date: Tue, 26 Apr 2022 22:34:02 GMT +Date: Mon, 16 May 2022 22:09:02 GMT Keep-Alive: timeout=5 =========================== Response Binary =========================== <<< 00000000 08 01 12 1c 54 68 75 72 73 64 61 79 20 69 73 20 |....Thursday is | diff --git a/test/suite/test.sh b/test/suite/test.sh index 7d6201c..3e5de93 100755 --- a/test/suite/test.sh +++ b/test/suite/test.sh @@ -4,6 +4,11 @@ set -e WORKING_DIR="$1" +if [[ "$WORKING_DIR" == "" ]]; then + echo "Please provide the working directory as a a docker-mount friendly path." + exit 1 +fi + export RUN_CLIENT="docker run --rm -v $WORKING_DIR/test/proto:/proto --network host \ -v /bin/bash:/bin/bash:ro \ -v /bin/mkdir:/bin/mkdir:ro \ diff --git a/test/suite/testcases.json b/test/suite/testcases.json index c982ccf..cbe9660 100644 --- a/test/suite/testcases.json +++ b/test/suite/testcases.json @@ -75,6 +75,35 @@ "-d \"includeReason: true\"" ] }, + { + "filename": "unknown-message-as-text", + "args": [ + "-F -i ..HappyDayRequest -u http://localhost:8080/happy-day/verify", + "-d \"includeReason: true\"" + ], + "comment": "The field presence is also shown in the output, since the server sets the err field to the empty string." + }, + { + "filename": "unknown-message-as-json", + "args": [ + "-F -i ..HappyDayRequest --out json -u http://localhost:8080/happy-day/verify", + "-d \"includeReason: true\"" + ] + }, + { + "filename": "response-type-arg-inferred-decode-raw", + "args": [ + "-v -F -i ..HappyDayRequest -u http://localhost:8080/happy-day/verify", + "-d \"includeReason: true\"" + ] + }, + { + "filename": "response-type-arg-overidden-decode-raw", + "args": [ + "-v -F -i ..HappyDayRequest -o ..HappyDayResponse --decode-raw -u http://localhost:8080/happy-day/verify", + "-d \"includeReason: true\"" + ] + }, { "filename": "inferred-message-package-path-nested-subdir", "beforeTestBash": "mkdir -p /copy && cp -r /proto /copy/proto && cd /copy/proto && rm -f happyday.proto && mkdir -p subdir && mv nameClashTest.proto.inactive subdir/nameClashTest.proto && sed -i 's/otherPackage/subdir.otherPackage/g' subdir/nameClashTest.proto && cd /protocurl",