@voxgig/sdkgen 4.48.0 → 4.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/voxgig-sdkgen +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.js +9 -1
- package/dist/utility.js.map +1 -1
- package/package.json +1 -1
- package/project/.sdk/model/feature/secrets.aontu +3 -0
- package/project/.sdk/src/cmp/c/Config_c.ts +6 -1
- package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +0 -10
- package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +0 -9
- package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +0 -11
- package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +0 -7
- package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +0 -10
- package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +2 -11
- package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +0 -10
- package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +0 -11
- package/project/.sdk/src/cmp/ocaml/Entity_ocaml.ts +2 -10
- package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +0 -13
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +0 -10
- package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +0 -10
- package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +0 -10
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +0 -12
- package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +0 -10
- package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +0 -9
- package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +0 -7
- package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +1 -14
- package/project/.sdk/tm/c/feature/cache.c +16 -1
- package/project/.sdk/tm/c/feature/secrets.c +149 -18
- package/project/.sdk/tm/c/tests/feature/secrets/secrets_test.c +319 -70
- package/project/.sdk/tm/c/tests/feature_test.c +31 -0
- package/project/.sdk/tm/c/utility/make_spec.c +1 -1
- package/project/.sdk/tm/c/utility/prepare_body.c +64 -1
- package/project/.sdk/tm/c/utility/prepare_query.c +11 -6
- package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +74 -29
- package/project/.sdk/tm/clojure/src/sdk/core.clj +48 -10
- package/project/.sdk/tm/clojure/src/sdk/features.clj +16 -2
- package/project/.sdk/tm/clojure/test/sdk/test/feature/secrets.clj +191 -48
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +16 -0
- package/project/.sdk/tm/cpp/core/types.hpp +1 -11
- package/project/.sdk/tm/cpp/feature/cache.hpp +14 -1
- package/project/.sdk/tm/cpp/feature/secrets.hpp +133 -18
- package/project/.sdk/tm/cpp/test/feature/secrets/secrets_test.cpp +175 -8
- package/project/.sdk/tm/cpp/test/feature_test.cpp +27 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +52 -4
- package/project/.sdk/tm/csharp/core/Control.cs +0 -5
- package/project/.sdk/tm/csharp/core/Point.cs +6 -0
- package/project/.sdk/tm/csharp/feature/CacheFeature.cs +16 -0
- package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +77 -38
- package/project/.sdk/tm/csharp/test/FeatureTest.cs +29 -0
- package/project/.sdk/tm/csharp/test/feature/secrets/SecretsFeatureTest.cs +315 -68
- package/project/.sdk/tm/csharp/utility/MakeSpec.cs +2 -2
- package/project/.sdk/tm/csharp/utility/PrepareBody.cs +42 -0
- package/project/.sdk/tm/csharp/utility/PrepareQuery.cs +13 -2
- package/project/.sdk/tm/elixir/lib/projectname/entity_base.ex +0 -13
- package/project/.sdk/tm/elixir/lib/projectname/feature/cache.ex +32 -10
- package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +78 -22
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +62 -6
- package/project/.sdk/tm/elixir/test/feature/secrets/secrets_test.exs +178 -19
- package/project/.sdk/tm/elixir/test/feature_test.exs +20 -0
- package/project/.sdk/tm/go/core/target.go +8 -0
- package/project/.sdk/tm/go/feature/cache_feature.go +14 -1
- package/project/.sdk/tm/go/feature/secrets_feature.go +110 -15
- package/project/.sdk/tm/go/test/feature/secrets/secrets_feature_test.go +373 -87
- package/project/.sdk/tm/go/test/feature_test.go +32 -0
- package/project/.sdk/tm/go/utility/media.go +2 -2
- package/project/.sdk/tm/go/utility/prepare_body.go +37 -1
- package/project/.sdk/tm/go/utility/prepare_query.go +10 -1
- package/project/.sdk/tm/java/core/Control.java +0 -5
- package/project/.sdk/tm/java/core/Point.java +7 -0
- package/project/.sdk/tm/java/feature/CacheFeature.java +12 -0
- package/project/.sdk/tm/java/feature/SecretsFeature.java +104 -34
- package/project/.sdk/tm/java/test/FeatureTest.java +25 -0
- package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +39 -0
- package/project/.sdk/tm/java/test/feature/secrets/SecretsFeatureTest.java +267 -53
- package/project/.sdk/tm/java/utility/Fetcher.java +18 -2
- package/project/.sdk/tm/java/utility/MakeSpec.java +1 -1
- package/project/.sdk/tm/java/utility/Media.java +2 -2
- package/project/.sdk/tm/java/utility/PrepareBody.java +50 -0
- package/project/.sdk/tm/java/utility/PrepareQuery.java +11 -1
- package/project/.sdk/tm/js/src/Point.js +2 -0
- package/project/.sdk/tm/js/src/feature/cache/CacheFeature.js +13 -0
- package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +79 -29
- package/project/.sdk/tm/js/src/utility/MakeSpecUtility.js +1 -1
- package/project/.sdk/tm/js/src/utility/PrepareBodyUtility.js +29 -0
- package/project/.sdk/tm/js/src/utility/PrepareQueryUtility.js +5 -3
- package/project/.sdk/tm/js/test/feature/secrets/Secrets.test.js +282 -93
- package/project/.sdk/tm/js/test/feature.test.js +17 -0
- package/project/.sdk/tm/kotlin/core/Control.kt +0 -5
- package/project/.sdk/tm/kotlin/core/Point.kt +7 -0
- package/project/.sdk/tm/kotlin/feature/CacheFeature.kt +12 -0
- package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +84 -24
- package/project/.sdk/tm/kotlin/test/FeatureTest.kt +24 -0
- package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +35 -0
- package/project/.sdk/tm/kotlin/test/feature/secrets/SecretsTest.kt +236 -54
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +13 -1
- package/project/.sdk/tm/kotlin/utility/MakeSpecUrl.kt +1 -1
- package/project/.sdk/tm/kotlin/utility/Prepare.kt +40 -10
- package/project/.sdk/tm/lua/feature/cache_feature.lua +20 -0
- package/project/.sdk/tm/lua/feature/secrets_feature.lua +92 -15
- package/project/.sdk/tm/lua/test/feature/secrets/secrets_feature_test.lua +208 -43
- package/project/.sdk/tm/lua/test/feature_test.lua +18 -0
- package/project/.sdk/tm/lua/utility/clean.lua +1 -0
- package/project/.sdk/tm/lua/utility/make_spec.lua +1 -1
- package/project/.sdk/tm/lua/utility/prepare_body.lua +40 -0
- package/project/.sdk/tm/lua/utility/prepare_query.lua +11 -1
- package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +100 -14
- package/project/.sdk/tm/ocaml/sdk_features.ml +7 -1
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +40 -5
- package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +143 -7
- package/project/.sdk/tm/ocaml/test/t_feature.ml +15 -0
- package/project/.sdk/tm/perl/feature/cache_feature.pm +13 -0
- package/project/.sdk/tm/perl/feature/secrets_feature.pm +87 -32
- package/project/.sdk/tm/perl/t/feature/secrets/secrets.t +177 -24
- package/project/.sdk/tm/perl/t/feature.t +24 -0
- package/project/.sdk/tm/perl/utility/make_spec.pm +1 -1
- package/project/.sdk/tm/perl/utility/prepare_body.pm +38 -4
- package/project/.sdk/tm/perl/utility/prepare_query.pm +7 -1
- package/project/.sdk/tm/php/feature/CacheFeature.php +13 -0
- package/project/.sdk/tm/php/feature/SecretsFeature.php +79 -23
- package/project/.sdk/tm/php/test/FeatureTest.php +23 -0
- package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +258 -48
- package/project/.sdk/tm/php/utility/MakeSpec.php +2 -2
- package/project/.sdk/tm/php/utility/PrepareBody.php +31 -0
- package/project/.sdk/tm/php/utility/PrepareQuery.php +9 -2
- package/project/.sdk/tm/py/pkg/feature/cache_feature.py +7 -1
- package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +90 -29
- package/project/.sdk/tm/py/pkg/utility/make_spec.py +1 -1
- package/project/.sdk/tm/py/pkg/utility/prepare_body.py +26 -0
- package/project/.sdk/tm/py/pkg/utility/prepare_query.py +7 -2
- package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +313 -80
- package/project/.sdk/tm/py/test/test_feature.py +18 -0
- package/project/.sdk/tm/rb/feature/cache_feature.rb +12 -0
- package/project/.sdk/tm/rb/feature/secrets_feature.rb +68 -21
- package/project/.sdk/tm/rb/test/feature/secrets/secrets_feature_test.rb +214 -43
- package/project/.sdk/tm/rb/test/feature_test.rb +20 -0
- package/project/.sdk/tm/rb/utility/make_spec.rb +1 -1
- package/project/.sdk/tm/rb/utility/prepare_body.rb +31 -3
- package/project/.sdk/tm/rb/utility/prepare_query.rb +7 -1
- package/project/.sdk/tm/rust/feature/cache.rs +15 -1
- package/project/.sdk/tm/rust/feature/secrets.rs +103 -23
- package/project/.sdk/tm/rust/tests/feature/secrets/main.rs +357 -67
- package/project/.sdk/tm/rust/tests/feature_test.rs +41 -0
- package/project/.sdk/tm/rust/utility/prepare_body.rs +51 -0
- package/project/.sdk/tm/rust/utility/prepare_query.rs +12 -4
- package/project/.sdk/tm/scala/core/Control.scala +0 -5
- package/project/.sdk/tm/scala/core/Point.scala +3 -0
- package/project/.sdk/tm/scala/feature/CacheFeature.scala +12 -0
- package/project/.sdk/tm/scala/feature/SecretsFeature.scala +88 -22
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +61 -1
- package/project/.sdk/tm/scala/sdktest/feature/secrets/SecretsTestMain.scala +230 -73
- package/project/.sdk/tm/scala/utility/Fetcher.scala +13 -1
- package/project/.sdk/tm/scala/utility/MakeSpec.scala +1 -1
- package/project/.sdk/tm/scala/utility/Prepare.scala +53 -12
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Control.swift +0 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Point.swift +3 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CacheFeature.swift +11 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +76 -16
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Make.swift +1 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Prepare.swift +36 -1
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +21 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/feature/secrets/SecretsFeatureTest.swift +257 -73
- package/project/.sdk/tm/ts/src/Point.ts +3 -0
- package/project/.sdk/tm/ts/src/feature/cache/CacheFeature.ts +13 -0
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +77 -17
- package/project/.sdk/tm/ts/src/utility/PrepareBodyUtility.ts +29 -0
- package/project/.sdk/tm/ts/src/utility/PrepareQueryUtility.ts +5 -3
- package/project/.sdk/tm/ts/test/feature/secrets/Secrets.test.ts +282 -87
- package/project/.sdk/tm/ts/test/feature.test.ts +17 -0
- package/project/.sdk/tm/zig/core/utility.zig +47 -4
- package/project/.sdk/tm/zig/feature/cache.zig +15 -1
- package/project/.sdk/tm/zig/feature/secrets.zig +109 -32
- package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +232 -9
- package/project/.sdk/tm/zig/test/feature_test.zig +33 -0
- package/project/sdkgen-package.json +1 -1
- package/src/utility.ts +12 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
package secretstest
|
|
3
3
|
|
|
4
4
|
import (
|
|
5
|
+
"encoding/base64"
|
|
5
6
|
"encoding/json"
|
|
6
7
|
"fmt"
|
|
7
8
|
"io"
|
|
@@ -43,6 +44,21 @@ var credheader = func() string {
|
|
|
43
44
|
return "authorization"
|
|
44
45
|
}()
|
|
45
46
|
|
|
47
|
+
// credform is the form prepare_auth writes, from the DEFAULT client's auth:
|
|
48
|
+
// under Basic the token is the key half of the encoded pair, and a prefix is
|
|
49
|
+
// space-joined.
|
|
50
|
+
var credform = func() authform {
|
|
51
|
+
auth, _ := sdk.TestSDK(nil, nil).OptionsMap()["auth"].(map[string]any)
|
|
52
|
+
prefix, _ := auth["prefix"].(string)
|
|
53
|
+
basic, _ := auth["basic"].(bool)
|
|
54
|
+
return authform{prefix: prefix, basic: basic}
|
|
55
|
+
}()
|
|
56
|
+
|
|
57
|
+
type authform struct {
|
|
58
|
+
prefix string
|
|
59
|
+
basic bool
|
|
60
|
+
}
|
|
61
|
+
|
|
46
62
|
// ---------------------------------------------------------------------
|
|
47
63
|
// The recording transport: system.fetch for a LIVE client, scripting one
|
|
48
64
|
// status per API call (the last repeating) and a token endpoint for the
|
|
@@ -52,6 +68,7 @@ type wirecall struct {
|
|
|
52
68
|
url string
|
|
53
69
|
auth string
|
|
54
70
|
has bool
|
|
71
|
+
values string
|
|
55
72
|
body string
|
|
56
73
|
redirect string
|
|
57
74
|
}
|
|
@@ -82,16 +99,20 @@ func (w *wire) fetch(url string, fetchdef map[string]any) (map[string]any, error
|
|
|
82
99
|
|
|
83
100
|
auth := ""
|
|
84
101
|
has := false
|
|
102
|
+
values := ""
|
|
85
103
|
if headers, is := fetchdef["headers"].(map[string]any); is {
|
|
86
104
|
if v, found := headers[credheader]; found {
|
|
87
105
|
auth, _ = v.(string)
|
|
88
106
|
has = true
|
|
89
107
|
}
|
|
108
|
+
for _, v := range headers {
|
|
109
|
+
values += fmt.Sprint(v) + "\n"
|
|
110
|
+
}
|
|
90
111
|
}
|
|
91
112
|
body, _ := fetchdef["body"].(string)
|
|
92
113
|
redirect, _ := fetchdef["redirect"].(string)
|
|
93
114
|
w.calls = append(w.calls,
|
|
94
|
-
wirecall{url: url, auth: auth, has: has, body: body, redirect: redirect})
|
|
115
|
+
wirecall{url: url, auth: auth, has: has, values: values, body: body, redirect: redirect})
|
|
95
116
|
|
|
96
117
|
if strings.HasSuffix(url, "/"+w.tokenpath) {
|
|
97
118
|
token := w.tokens[min(w.issued, len(w.tokens)-1)]
|
|
@@ -149,13 +170,28 @@ func (w *wire) token() []wirecall {
|
|
|
149
170
|
// ---------------------------------------------------------------------
|
|
150
171
|
// Support.
|
|
151
172
|
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
|
|
173
|
+
// credential is the header value prepare_auth writes for a token.
|
|
174
|
+
func credential(token string, secret string) string {
|
|
175
|
+
value := token
|
|
176
|
+
if credform.basic {
|
|
177
|
+
value = base64.StdEncoding.EncodeToString([]byte(token + ":" + secret))
|
|
178
|
+
}
|
|
179
|
+
if "" == credform.prefix {
|
|
180
|
+
return value
|
|
181
|
+
}
|
|
182
|
+
return credform.prefix + " " + value
|
|
183
|
+
}
|
|
184
|
+
|
|
155
185
|
func credentialIs(t *testing.T, header string, token string) {
|
|
156
186
|
t.Helper()
|
|
157
|
-
|
|
158
|
-
|
|
187
|
+
pairedIs(t, header, token, "")
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
func pairedIs(t *testing.T, header string, token string, secret string) {
|
|
191
|
+
t.Helper()
|
|
192
|
+
if want := credential(token, secret); header != want {
|
|
193
|
+
t.Fatalf("expected the %s header to carry %s as %q, got: %q",
|
|
194
|
+
credheader, token, want, header)
|
|
159
195
|
}
|
|
160
196
|
}
|
|
161
197
|
|
|
@@ -426,6 +462,20 @@ func TestSecretsChain(t *testing.T) {
|
|
|
426
462
|
}
|
|
427
463
|
})
|
|
428
464
|
|
|
465
|
+
t.Run("a resolved key is placed as prepare_auth places it, the secret kept", func(t *testing.T) {
|
|
466
|
+
os.Setenv(envprefix+"APIKEY", "ENVKEY04")
|
|
467
|
+
defer os.Unsetenv(envprefix + "APIKEY")
|
|
468
|
+
|
|
469
|
+
w := makewire()
|
|
470
|
+
client := secretsClient(w, map[string]any{
|
|
471
|
+
"secret": "PASS01",
|
|
472
|
+
"feature": secretsOpts(nil),
|
|
473
|
+
})
|
|
474
|
+
|
|
475
|
+
driveEntityOp(t, client, w)
|
|
476
|
+
pairedIs(t, w.api()[0].auth, "ENVKEY04", "PASS01")
|
|
477
|
+
})
|
|
478
|
+
|
|
429
479
|
t.Run("custom provider objects are accepted verbatim", func(t *testing.T) {
|
|
430
480
|
asked := []string{}
|
|
431
481
|
w := makewire()
|
|
@@ -683,6 +733,31 @@ func TestSecretsExchange(t *testing.T) {
|
|
|
683
733
|
credentialIs(t, api[1].auth, "ACCESS02")
|
|
684
734
|
})
|
|
685
735
|
|
|
736
|
+
t.Run("a token bought on a refusal is placed as prepare_auth places it, the secret kept", func(t *testing.T) {
|
|
737
|
+
os.Setenv(envprefix+"REFRESH_TOKEN", "REFRESH01")
|
|
738
|
+
defer os.Unsetenv(envprefix + "REFRESH_TOKEN")
|
|
739
|
+
|
|
740
|
+
w := makewire()
|
|
741
|
+
w.apistatus = []int{401, 200}
|
|
742
|
+
|
|
743
|
+
client := secretsClient(w, map[string]any{
|
|
744
|
+
"secret": "PASS01",
|
|
745
|
+
"feature": secretsOpts(map[string]any{
|
|
746
|
+
"name": "refresh_token",
|
|
747
|
+
"exchange": map[string]any{"active": true},
|
|
748
|
+
}),
|
|
749
|
+
})
|
|
750
|
+
|
|
751
|
+
driveEntityOp(t, client, w)
|
|
752
|
+
|
|
753
|
+
api := w.api()
|
|
754
|
+
if 2 != len(api) {
|
|
755
|
+
t.Fatalf("expected the request to be retried exactly once, got %d calls", len(api))
|
|
756
|
+
}
|
|
757
|
+
pairedIs(t, api[0].auth, "ACCESS01", "PASS01")
|
|
758
|
+
pairedIs(t, api[1].auth, "ACCESS02", "PASS01")
|
|
759
|
+
})
|
|
760
|
+
|
|
686
761
|
t.Run("auth nil buys no token at all", func(t *testing.T) {
|
|
687
762
|
os.Setenv(envprefix+"REFRESH_TOKEN", "REFRESH01")
|
|
688
763
|
defer os.Unsetenv(envprefix + "REFRESH_TOKEN")
|
|
@@ -813,106 +888,210 @@ func TestSecretsExchangeRawFetch(t *testing.T) {
|
|
|
813
888
|
}
|
|
814
889
|
|
|
815
890
|
// Real listeners and the raw fallback transport: a stub follows nothing.
|
|
891
|
+
// redirectOrigins holds the real listeners: the origin answers the exchange
|
|
892
|
+
// as `status` and `location` say and records what else it gets.
|
|
893
|
+
type redirectOrigins struct {
|
|
894
|
+
mu sync.Mutex
|
|
895
|
+
elsewhere []string
|
|
896
|
+
followed []string
|
|
897
|
+
exchanged int
|
|
898
|
+
status int
|
|
899
|
+
location string
|
|
900
|
+
origin string
|
|
901
|
+
base string
|
|
902
|
+
away string
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
func withOrigins(run func(o *redirectOrigins)) {
|
|
906
|
+
o := &redirectOrigins{}
|
|
907
|
+
|
|
908
|
+
other := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
|
909
|
+
body, _ := io.ReadAll(req.Body)
|
|
910
|
+
o.mu.Lock()
|
|
911
|
+
o.elsewhere = append(o.elsewhere, req.Method+" "+req.URL.Path+" "+string(body))
|
|
912
|
+
o.mu.Unlock()
|
|
913
|
+
res.Header().Set("content-type", "application/json")
|
|
914
|
+
res.Write([]byte(`{"access_token":"ELSEWHERE01"}`))
|
|
915
|
+
}))
|
|
916
|
+
defer other.Close()
|
|
917
|
+
|
|
918
|
+
origin := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
|
919
|
+
body, _ := io.ReadAll(req.Body)
|
|
920
|
+
o.mu.Lock()
|
|
921
|
+
defer o.mu.Unlock()
|
|
922
|
+
if "/api/auth/token" == req.URL.Path && "" == req.URL.RawQuery {
|
|
923
|
+
o.exchanged++
|
|
924
|
+
res.Header().Set("location", o.location)
|
|
925
|
+
res.WriteHeader(o.status)
|
|
926
|
+
return
|
|
927
|
+
}
|
|
928
|
+
o.followed = append(o.followed,
|
|
929
|
+
strings.TrimSpace(req.Method+" "+req.URL.RequestURI()+" "+string(body)))
|
|
930
|
+
res.Header().Set("content-type", "application/json")
|
|
931
|
+
res.Write([]byte(`{"access_token":"MOVED01"}`))
|
|
932
|
+
}))
|
|
933
|
+
defer origin.Close()
|
|
934
|
+
|
|
935
|
+
o.origin = origin.URL
|
|
936
|
+
o.base = origin.URL + "/api"
|
|
937
|
+
o.away = other.URL + "/api/auth/token"
|
|
938
|
+
|
|
939
|
+
run(o)
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
func (o *redirectOrigins) answer(status int, location string) {
|
|
943
|
+
o.mu.Lock()
|
|
944
|
+
defer o.mu.Unlock()
|
|
945
|
+
o.status = status
|
|
946
|
+
o.location = location
|
|
947
|
+
o.followed = []string{}
|
|
948
|
+
o.exchanged = 0
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
func redirectClient(o *redirectOrigins, extra map[string]any) *sdk.ProjectNameSDK {
|
|
952
|
+
exchange := map[string]any{"active": true, "refresh": "REFRESH01"}
|
|
953
|
+
for k, v := range extra {
|
|
954
|
+
exchange[k] = v
|
|
955
|
+
}
|
|
956
|
+
return withSecrets(func(extend bool) *sdk.ProjectNameSDK {
|
|
957
|
+
opts := map[string]any{
|
|
958
|
+
"base": o.base,
|
|
959
|
+
"feature": map[string]any{"secrets": map[string]any{
|
|
960
|
+
"active": true,
|
|
961
|
+
"name": "refresh_token",
|
|
962
|
+
"exchange": exchange,
|
|
963
|
+
}},
|
|
964
|
+
}
|
|
965
|
+
if extend {
|
|
966
|
+
opts["extend"] = []any{feat.NewSecretsFeature()}
|
|
967
|
+
}
|
|
968
|
+
client, err := sdk.NewProjectNameSDK(opts)
|
|
969
|
+
if err != nil {
|
|
970
|
+
panic(err)
|
|
971
|
+
}
|
|
972
|
+
return client
|
|
973
|
+
})
|
|
974
|
+
}
|
|
975
|
+
|
|
816
976
|
func TestSecretsExchangeRedirectRefused(t *testing.T) {
|
|
817
977
|
skipWithoutAuth(t)
|
|
818
978
|
|
|
819
979
|
t.Run("a redirect answering the exchange is a failure, and nothing follows it", func(t *testing.T) {
|
|
820
980
|
entity, opname := routableOp(t)
|
|
821
981
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
location string
|
|
828
|
-
}{}
|
|
982
|
+
withOrigins(func(o *redirectOrigins) {
|
|
983
|
+
answers := []struct {
|
|
984
|
+
status int
|
|
985
|
+
location string
|
|
986
|
+
}{{307, o.away}, {308, o.away}, {302, o.away}, {307, "/api/moved/token"}}
|
|
829
987
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
mu.Lock()
|
|
833
|
-
elsewhere = append(elsewhere, req.Method+" "+req.URL.Path+" "+string(body))
|
|
834
|
-
mu.Unlock()
|
|
835
|
-
res.Header().Set("content-type", "application/json")
|
|
836
|
-
res.Write([]byte(`{"access_token":"ELSEWHERE01"}`))
|
|
837
|
-
}))
|
|
838
|
-
defer other.Close()
|
|
988
|
+
allowed := []string{}
|
|
989
|
+
refused := 0
|
|
839
990
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
991
|
+
for _, a := range answers {
|
|
992
|
+
o.answer(a.status, a.location)
|
|
993
|
+
|
|
994
|
+
message := fmt.Sprint(callNamedOp(redirectClient(o, nil), entity, opname))
|
|
995
|
+
if strings.Contains(message, "token exchange failed: "+
|
|
996
|
+
strconv.Itoa(a.status)+" from "+o.base+"/auth/token") {
|
|
997
|
+
refused++
|
|
998
|
+
} else {
|
|
999
|
+
allowed = append(allowed, fmt.Sprintf("%d to %s: %s", a.status, a.location, message))
|
|
1000
|
+
}
|
|
848
1001
|
}
|
|
849
|
-
followed = append(followed, req.Method+" "+req.URL.Path)
|
|
850
|
-
res.Header().Set("content-type", "application/json")
|
|
851
|
-
res.Write([]byte(`{"access_token":"MOVED01"}`))
|
|
852
|
-
}))
|
|
853
|
-
defer origin.Close()
|
|
854
1002
|
|
|
855
|
-
|
|
856
|
-
|
|
1003
|
+
o.mu.Lock()
|
|
1004
|
+
defer o.mu.Unlock()
|
|
1005
|
+
fmt.Printf("secrets: exchange refused %d redirect(s), %d followed\n",
|
|
1006
|
+
refused, len(o.elsewhere)+len(o.followed))
|
|
857
1007
|
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
1008
|
+
if 0 != len(o.elsewhere) {
|
|
1009
|
+
t.Errorf("the exchange reached another origin: %v", o.elsewhere)
|
|
1010
|
+
}
|
|
1011
|
+
if 0 != len(o.followed) {
|
|
1012
|
+
t.Errorf("a request followed a refused exchange: %v", o.followed)
|
|
1013
|
+
}
|
|
1014
|
+
if 0 != len(allowed) {
|
|
1015
|
+
t.Errorf("a redirect was not a failed exchange: %v", allowed)
|
|
1016
|
+
}
|
|
1017
|
+
if len(answers) != refused {
|
|
1018
|
+
t.Errorf("expected %d refused exchanges, got %d", len(answers), refused)
|
|
1019
|
+
}
|
|
1020
|
+
})
|
|
1021
|
+
})
|
|
862
1022
|
|
|
863
|
-
|
|
864
|
-
|
|
1023
|
+
t.Run("with the option, a redirect on the exchange's own origin is followed, and no other", func(t *testing.T) {
|
|
1024
|
+
entity, opname := routableOp(t)
|
|
865
1025
|
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
1026
|
+
withOrigins(func(o *redirectOrigins) {
|
|
1027
|
+
sent := ` {"refresh_token":"REFRESH01"}`
|
|
1028
|
+
// Each case: the status, the Location, and the path the exchange is
|
|
1029
|
+
// asked again at, or "" where the redirect is refused.
|
|
1030
|
+
cases := []struct {
|
|
1031
|
+
status int
|
|
1032
|
+
location string
|
|
1033
|
+
path string
|
|
1034
|
+
}{
|
|
1035
|
+
{307, "/api/moved/token", "/api/moved/token"},
|
|
1036
|
+
{308, o.origin + "/api/moved/token", "/api/moved/token"},
|
|
1037
|
+
// A Location of a query alone keeps the path that answered.
|
|
1038
|
+
{307, "?step=2", "/api/auth/token?step=2"},
|
|
1039
|
+
{307, o.away, ""},
|
|
1040
|
+
{302, "/api/moved/token", ""},
|
|
1041
|
+
{307, "/api/auth/token", ""},
|
|
1042
|
+
}
|
|
870
1043
|
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1044
|
+
wrong := []string{}
|
|
1045
|
+
followed, refused, looped := 0, 0, 0
|
|
1046
|
+
|
|
1047
|
+
for _, c := range cases {
|
|
1048
|
+
o.answer(c.status, c.location)
|
|
1049
|
+
|
|
1050
|
+
result := callNamedOp(redirectClient(o, map[string]any{"redirect": "same-origin"}),
|
|
1051
|
+
entity, opname)
|
|
1052
|
+
message := fmt.Sprint(result)
|
|
1053
|
+
|
|
1054
|
+
o.mu.Lock()
|
|
1055
|
+
seen := fmt.Sprintf("%d to %s: %s %v", c.status, c.location, message, o.followed)
|
|
1056
|
+
if "" != c.path {
|
|
1057
|
+
if nil == result && 2 == len(o.followed) && "POST "+c.path+sent == o.followed[0] {
|
|
1058
|
+
followed++
|
|
1059
|
+
} else {
|
|
1060
|
+
wrong = append(wrong, seen)
|
|
1061
|
+
}
|
|
1062
|
+
} else if 0 == len(o.followed) && strings.Contains(message,
|
|
1063
|
+
"token exchange failed: "+strconv.Itoa(c.status)+" from "+o.base+"/auth/token") {
|
|
1064
|
+
refused++
|
|
1065
|
+
} else {
|
|
1066
|
+
wrong = append(wrong, seen)
|
|
882
1067
|
}
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
panic(err)
|
|
1068
|
+
if "/api/auth/token" == c.location {
|
|
1069
|
+
looped = o.exchanged
|
|
886
1070
|
}
|
|
887
|
-
|
|
888
|
-
})
|
|
889
|
-
|
|
890
|
-
message := fmt.Sprint(callNamedOp(client, entity, opname))
|
|
891
|
-
if strings.Contains(message, "token exchange failed: "+
|
|
892
|
-
strconv.Itoa(a.status)+" from "+base+"/auth/token") {
|
|
893
|
-
refused++
|
|
894
|
-
} else {
|
|
895
|
-
allowed = append(allowed, fmt.Sprintf("%d to %s: %s", a.status, a.location, message))
|
|
1071
|
+
o.mu.Unlock()
|
|
896
1072
|
}
|
|
897
|
-
}
|
|
898
1073
|
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1074
|
+
o.mu.Lock()
|
|
1075
|
+
defer o.mu.Unlock()
|
|
1076
|
+
fmt.Printf("secrets: exchange opt-in followed %d redirect(s) on its own origin, refused %d, %d elsewhere\n",
|
|
1077
|
+
followed, refused, len(o.elsewhere))
|
|
903
1078
|
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
1079
|
+
if 0 != len(o.elsewhere) {
|
|
1080
|
+
t.Errorf("the exchange reached another origin: %v", o.elsewhere)
|
|
1081
|
+
}
|
|
1082
|
+
if 0 != len(wrong) {
|
|
1083
|
+
t.Errorf("unexpected outcomes: %v", wrong)
|
|
1084
|
+
}
|
|
1085
|
+
if 3 != followed {
|
|
1086
|
+
t.Errorf("expected 3 followed, got %d", followed)
|
|
1087
|
+
}
|
|
1088
|
+
if 3 != refused {
|
|
1089
|
+
t.Errorf("expected 3 refused, got %d", refused)
|
|
1090
|
+
}
|
|
1091
|
+
if 6 != looped {
|
|
1092
|
+
t.Errorf("expected the exchange asked 6 times, got %d", looped)
|
|
1093
|
+
}
|
|
1094
|
+
})
|
|
916
1095
|
})
|
|
917
1096
|
}
|
|
918
1097
|
|
|
@@ -1198,3 +1377,110 @@ func TestSecretsGateRecovery(t *testing.T) {
|
|
|
1198
1377
|
t.Fatalf("recovery must let both operations out, saw %d", len(w.api()))
|
|
1199
1378
|
}
|
|
1200
1379
|
}
|
|
1380
|
+
|
|
1381
|
+
// authoff is off by the config where it declares no auth, else by `auth:
|
|
1382
|
+
// nil`: either way the feature places no credential, buys no token and
|
|
1383
|
+
// retries nothing.
|
|
1384
|
+
func authoff() (string, map[string]any) {
|
|
1385
|
+
if options, _ := sdk.MakeConfig()["options"].(map[string]any); nil == options["auth"] {
|
|
1386
|
+
return "config", map[string]any{}
|
|
1387
|
+
}
|
|
1388
|
+
return "option", map[string]any{"auth": nil}
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
func TestAuthOff(t *testing.T) {
|
|
1392
|
+
by, off := authoff()
|
|
1393
|
+
secrets := []string{"OFFKEY01", "OFFKEY02", "OFFREFRESH01", "ACCESS01"}
|
|
1394
|
+
sent := []wirecall{}
|
|
1395
|
+
bought := 0
|
|
1396
|
+
|
|
1397
|
+
// The header prepare_auth writes, or any header holding one of the secrets.
|
|
1398
|
+
carries := func(call wirecall) bool {
|
|
1399
|
+
if call.has {
|
|
1400
|
+
return true
|
|
1401
|
+
}
|
|
1402
|
+
for _, secret := range secrets {
|
|
1403
|
+
if strings.Contains(call.values, secret) {
|
|
1404
|
+
return true
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
return false
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
offclient := func(w *wire, sdkopts map[string]any, fopts map[string]any) *sdk.ProjectNameSDK {
|
|
1411
|
+
opts := map[string]any{"feature": secretsOpts(fopts)}
|
|
1412
|
+
for k, v := range sdkopts {
|
|
1413
|
+
opts[k] = v
|
|
1414
|
+
}
|
|
1415
|
+
for k, v := range off {
|
|
1416
|
+
opts[k] = v
|
|
1417
|
+
}
|
|
1418
|
+
return secretsClient(w, opts)
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
record := func(w *wire) {
|
|
1422
|
+
sent = append(sent, w.api()...)
|
|
1423
|
+
bought += len(w.token())
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
t.Run("a key the chain resolves is not placed", func(t *testing.T) {
|
|
1427
|
+
os.Setenv(envprefix+"APIKEY", "OFFKEY01")
|
|
1428
|
+
defer os.Unsetenv(envprefix + "APIKEY")
|
|
1429
|
+
|
|
1430
|
+
w := makewire()
|
|
1431
|
+
client := offclient(w, nil, nil)
|
|
1432
|
+
driveEntityOp(t, client, w)
|
|
1433
|
+
record(w)
|
|
1434
|
+
|
|
1435
|
+
if carries(w.api()[0]) {
|
|
1436
|
+
t.Fatalf("a credential was sent with auth off: %q", w.api()[0].values)
|
|
1437
|
+
}
|
|
1438
|
+
if v := secretsFeatureOf(client).Credential(); "" != v {
|
|
1439
|
+
t.Fatalf("the feature resolved a credential with auth off: %q", v)
|
|
1440
|
+
}
|
|
1441
|
+
})
|
|
1442
|
+
|
|
1443
|
+
t.Run("an explicit apikey is not placed", func(t *testing.T) {
|
|
1444
|
+
w := makewire()
|
|
1445
|
+
client := offclient(w, map[string]any{"apikey": "OFFKEY02"}, nil)
|
|
1446
|
+
driveEntityOp(t, client, w)
|
|
1447
|
+
record(w)
|
|
1448
|
+
|
|
1449
|
+
if carries(w.api()[0]) {
|
|
1450
|
+
t.Fatalf("a credential was sent with auth off: %q", w.api()[0].values)
|
|
1451
|
+
}
|
|
1452
|
+
})
|
|
1453
|
+
|
|
1454
|
+
t.Run("a refusal buys no token and is not retried", func(t *testing.T) {
|
|
1455
|
+
os.Setenv(envprefix+"REFRESH_TOKEN", "OFFREFRESH01")
|
|
1456
|
+
defer os.Unsetenv(envprefix + "REFRESH_TOKEN")
|
|
1457
|
+
|
|
1458
|
+
w := makewire()
|
|
1459
|
+
w.apistatus = []int{401}
|
|
1460
|
+
client := offclient(w, nil, map[string]any{
|
|
1461
|
+
"name": "refresh_token",
|
|
1462
|
+
"exchange": map[string]any{"active": true},
|
|
1463
|
+
})
|
|
1464
|
+
driveEntityOp(t, client, w)
|
|
1465
|
+
record(w)
|
|
1466
|
+
|
|
1467
|
+
if 0 != len(w.token()) {
|
|
1468
|
+
t.Fatalf("a token was bought with auth off (%d purchases)", len(w.token()))
|
|
1469
|
+
}
|
|
1470
|
+
if 1 != len(w.api()) {
|
|
1471
|
+
t.Fatalf("a refusal was retried with auth off (%d calls)", len(w.api()))
|
|
1472
|
+
}
|
|
1473
|
+
if carries(w.api()[0]) {
|
|
1474
|
+
t.Fatalf("a credential was sent with auth off: %q", w.api()[0].values)
|
|
1475
|
+
}
|
|
1476
|
+
})
|
|
1477
|
+
|
|
1478
|
+
credentials := 0
|
|
1479
|
+
for _, call := range sent {
|
|
1480
|
+
if carries(call) {
|
|
1481
|
+
credentials++
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
fmt.Printf("secrets: auth off by %s: %d request(s), %d credential(s), %d token(s)\n",
|
|
1485
|
+
by, len(sent), credentials, bought)
|
|
1486
|
+
}
|
|
@@ -588,6 +588,38 @@ func TestFeatureCache(t *testing.T) {
|
|
|
588
588
|
}
|
|
589
589
|
})
|
|
590
590
|
|
|
591
|
+
t.Run("a-body-that-declares-another-type-than-json-passes-by-unread", func(t *testing.T) {
|
|
592
|
+
sent := []map[string]any{}
|
|
593
|
+
rec := &fhRecorder{reply: func(_ int, _ map[string]any) (any, error) {
|
|
594
|
+
res := fhResponse(200, nil, map[string]any{"content-type": "audio/wav"})
|
|
595
|
+
res["body"] = "RIFF"
|
|
596
|
+
sent = append(sent, res)
|
|
597
|
+
return res, nil
|
|
598
|
+
}}
|
|
599
|
+
f := feat.NewCacheFeature()
|
|
600
|
+
h := fhMake(rec.fetch, fhF(f, nil))
|
|
601
|
+
handed := []any{}
|
|
602
|
+
cached := h.utility.Fetcher
|
|
603
|
+
h.utility.Fetcher = func(ctx *sdk.Context, url string, fetchdef map[string]any) (any, error) {
|
|
604
|
+
res, err := cached(ctx, url, fetchdef)
|
|
605
|
+
handed = append(handed, res)
|
|
606
|
+
return res, err
|
|
607
|
+
}
|
|
608
|
+
h.op(fhOpSpec{op: "load", path: "/w/1/audio"})
|
|
609
|
+
h.op(fhOpSpec{op: "load", path: "/w/1/audio"})
|
|
610
|
+
if len(rec.calls) != 2 {
|
|
611
|
+
t.Fatalf("the body was stored: expected 2 calls, got %d", len(rec.calls))
|
|
612
|
+
}
|
|
613
|
+
for i := range sent {
|
|
614
|
+
if reflect.ValueOf(handed[i]).Pointer() != reflect.ValueOf(sent[i]).Pointer() {
|
|
615
|
+
t.Errorf("read %d: the cache handed on a copy it had read", i)
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
if f.Bypass != 2 {
|
|
619
|
+
t.Errorf("expected 2 bypasses, got %d", f.Bypass)
|
|
620
|
+
}
|
|
621
|
+
})
|
|
622
|
+
|
|
591
623
|
t.Run("refetches-after-ttl", func(t *testing.T) {
|
|
592
624
|
clock := &fhClock{}
|
|
593
625
|
rec := &fhRecorder{}
|
|
@@ -13,7 +13,7 @@ import (
|
|
|
13
13
|
// The data key of a raw request body; like `$action`, never an argument name.
|
|
14
14
|
const rawBodyKey = "$body"
|
|
15
15
|
|
|
16
|
-
func
|
|
16
|
+
func IsJSONMedia(media string) bool {
|
|
17
17
|
m := strings.ToLower(strings.TrimSpace(strings.SplitN(media, ";", 2)[0]))
|
|
18
18
|
return "application/json" == m || "text/json" == m || strings.HasSuffix(m, "+json")
|
|
19
19
|
}
|
|
@@ -81,7 +81,7 @@ func mediaHeaders(point map[string]any, headers map[string]any) map[string]any {
|
|
|
81
81
|
media, _ := vs.GetProp(body, "media").(string)
|
|
82
82
|
if ("raw" == kind || "json" == kind) && "" != media {
|
|
83
83
|
for key, val := range headers {
|
|
84
|
-
if sv, ok := val.(string); ok && "content-type" == strings.ToLower(key) &&
|
|
84
|
+
if sv, ok := val.(string); ok && "content-type" == strings.ToLower(key) && IsJSONMedia(sv) {
|
|
85
85
|
delete(headers, key)
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
package utility
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import (
|
|
4
|
+
vs "github.com/voxgig/struct"
|
|
5
|
+
|
|
6
|
+
"GOMODULE/core"
|
|
7
|
+
)
|
|
4
8
|
|
|
5
9
|
func prepareBodyUtil(ctx *core.Context) any {
|
|
6
10
|
op := ctx.Op
|
|
@@ -13,5 +17,37 @@ func prepareBodyUtil(ctx *core.Context) any {
|
|
|
13
17
|
return body
|
|
14
18
|
}
|
|
15
19
|
|
|
20
|
+
if fields, ok := vs.GetProp(ctx.Point, "fields").([]any); ok && 0 < len(fields) {
|
|
21
|
+
return matchBody(ctx, fields)
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
return nil
|
|
17
25
|
}
|
|
26
|
+
|
|
27
|
+
// A list, load or remove routed to a method with a body sends the match
|
|
28
|
+
// fields that body declares, never a path parameter, and never a header,
|
|
29
|
+
// cookie or query argument the body does not also declare as a field.
|
|
30
|
+
func matchBody(ctx *core.Context, fields []any) map[string]any {
|
|
31
|
+
routed := []any{}
|
|
32
|
+
if pl, ok := vs.GetProp(ctx.Point, "params").([]any); ok {
|
|
33
|
+
routed = append(routed, pl...)
|
|
34
|
+
}
|
|
35
|
+
for _, kind := range []string{"params", "header", "cookie", "query"} {
|
|
36
|
+
al, _ := vs.GetPath(ctx.Point, []any{"args", kind}).([]any)
|
|
37
|
+
for _, ad := range al {
|
|
38
|
+
if "params" == kind || true != vs.GetProp(ad, "field") {
|
|
39
|
+
routed = append(routed, vs.GetProp(ad, "name"))
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
body := map[string]any{}
|
|
45
|
+
for _, field := range fields {
|
|
46
|
+
name, _ := field.(string)
|
|
47
|
+
val := vs.GetProp(ctx.Reqmatch, name)
|
|
48
|
+
if val != nil && "" != name && "$action" != name && !containsStr(routed, name) {
|
|
49
|
+
body[name] = val
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return body
|
|
53
|
+
}
|
|
@@ -38,7 +38,9 @@ func prepareQueryUtil(ctx *core.Context) map[string]any {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// A header or cookie parameter travels in the headers, which prepareHeaders
|
|
41
|
-
// fills,
|
|
41
|
+
// fills, and a field the point's body declares travels in the body, which
|
|
42
|
+
// prepareBody fills, unless a query parameter shares its name: then both
|
|
43
|
+
// are sent.
|
|
42
44
|
if point != nil {
|
|
43
45
|
declared := map[string]bool{}
|
|
44
46
|
if ql, ok := vs.GetPath(point, []any{"args", "query"}).([]any); ok {
|
|
@@ -62,6 +64,13 @@ func prepareQueryUtil(ctx *core.Context) map[string]any {
|
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
}
|
|
67
|
+
if fl, ok := vs.GetProp(point, "fields").([]any); ok {
|
|
68
|
+
for _, field := range fl {
|
|
69
|
+
if name, ok := field.(string); ok && !declared[name] {
|
|
70
|
+
params = append(params, name)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
// A query parameter travels under the name the definition gives it, its
|
|
@@ -15,9 +15,4 @@ public class Control {
|
|
|
15
15
|
public String actor = "";
|
|
16
16
|
|
|
17
17
|
public Map<String, Object> paging;
|
|
18
|
-
|
|
19
|
-
// Outbound streaming marker: the entity `stream` method sets this to the
|
|
20
|
-
// caller-supplied streamable payload so the request builder / transport
|
|
21
|
-
// can stream it as the request body.
|
|
22
|
-
public Object streamOut;
|
|
23
18
|
}
|