@voxgig/sdkgen 4.35.3 → 4.37.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/cmp/ReadmeTop.js +1 -1
- package/dist/cmp/ReadmeTop.js.map +1 -1
- package/dist/helpers/opExample.d.ts +4 -1
- package/dist/helpers/opExample.js +11 -1
- package/dist/helpers/opExample.js.map +1 -1
- package/dist/helpers/opShape.d.ts +2 -1
- package/dist/helpers/opShape.js +53 -26
- package/dist/helpers/opShape.js.map +1 -1
- package/dist/helpers/pointPath.d.ts +2 -1
- package/dist/helpers/pointPath.js +17 -0
- package/dist/helpers/pointPath.js.map +1 -1
- package/dist/helpers/testPolicy.d.ts +48 -2
- package/dist/helpers/testPolicy.js +265 -0
- package/dist/helpers/testPolicy.js.map +1 -1
- package/dist/sdkgen.d.ts +7 -7
- package/dist/sdkgen.js +26 -4
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/c/PrepareAuth_c.ts +10 -4
- package/project/.sdk/src/cmp/c/ReadmeEntity_c.ts +2 -2
- package/project/.sdk/src/cmp/c/ReadmeHowto_c.ts +2 -2
- package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +6 -5
- package/project/.sdk/src/cmp/c/ReadmeRef_c.ts +3 -3
- package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +2 -2
- package/project/.sdk/src/cmp/c/ReadmeTopTest_c.ts +2 -2
- package/project/.sdk/src/cmp/c/TestDirect_c.ts +2 -6
- package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +2 -2
- package/project/.sdk/src/cmp/clojure/ReadmeHowto_clojure.ts +2 -2
- package/project/.sdk/src/cmp/clojure/ReadmeQuick_clojure.ts +4 -4
- package/project/.sdk/src/cmp/clojure/ReadmeRef_clojure.ts +3 -3
- package/project/.sdk/src/cmp/clojure/ReadmeTopQuick_clojure.ts +2 -2
- package/project/.sdk/src/cmp/clojure/ReadmeTopTest_clojure.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeEntity_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeHowto_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeQuick_cpp.ts +4 -4
- package/project/.sdk/src/cmp/cpp/ReadmeRef_cpp.ts +3 -3
- package/project/.sdk/src/cmp/cpp/ReadmeTopQuick_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/ReadmeTopTest_cpp.ts +2 -2
- package/project/.sdk/src/cmp/cpp/TestDirect_cpp.ts +2 -6
- package/project/.sdk/src/cmp/cpp/TestEntity_cpp.ts +51 -3
- package/project/.sdk/src/cmp/csharp/ReadmeEntity_csharp.ts +2 -2
- package/project/.sdk/src/cmp/csharp/ReadmeHowto_csharp.ts +2 -2
- package/project/.sdk/src/cmp/csharp/ReadmeQuick_csharp.ts +5 -5
- package/project/.sdk/src/cmp/csharp/ReadmeRef_csharp.ts +3 -3
- package/project/.sdk/src/cmp/csharp/ReadmeTopQuick_csharp.ts +3 -3
- package/project/.sdk/src/cmp/csharp/ReadmeTopTest_csharp.ts +2 -2
- package/project/.sdk/src/cmp/csharp/TestDirect_csharp.ts +41 -19
- package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +105 -27
- package/project/.sdk/src/cmp/elixir/ReadmeEntity_elixir.ts +2 -2
- package/project/.sdk/src/cmp/elixir/ReadmeHowto_elixir.ts +2 -2
- package/project/.sdk/src/cmp/elixir/ReadmeQuick_elixir.ts +4 -4
- package/project/.sdk/src/cmp/elixir/ReadmeRef_elixir.ts +3 -3
- package/project/.sdk/src/cmp/elixir/ReadmeTopQuick_elixir.ts +2 -2
- package/project/.sdk/src/cmp/elixir/ReadmeTopTest_elixir.ts +2 -2
- package/project/.sdk/src/cmp/go/EntityOperation_go.ts +2 -2
- package/project/.sdk/src/cmp/go/Entity_go.ts +5 -4
- package/project/.sdk/src/cmp/go/MainEntity_go.ts +1 -1
- package/project/.sdk/src/cmp/go/Main_go.ts +9 -5
- package/project/.sdk/src/cmp/go/PrepareAuth_go.ts +24 -15
- package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +2 -2
- package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +2 -2
- package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +3 -3
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +4 -4
- package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +4 -4
- package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +2 -2
- package/project/.sdk/src/cmp/go/TestDirect_go.ts +61 -26
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +115 -32
- package/project/.sdk/src/cmp/go-cli/fragment/words.fragment.go +1 -1
- package/project/.sdk/src/cmp/go-mcp/fragment/tools.fragment.go +1 -1
- package/project/.sdk/src/cmp/java/ReadmeEntity_java.ts +2 -2
- package/project/.sdk/src/cmp/java/ReadmeHowto_java.ts +2 -2
- package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +5 -5
- package/project/.sdk/src/cmp/java/ReadmeRef_java.ts +3 -3
- package/project/.sdk/src/cmp/java/ReadmeTopQuick_java.ts +3 -3
- package/project/.sdk/src/cmp/java/ReadmeTopTest_java.ts +2 -2
- package/project/.sdk/src/cmp/java/TestDirect_java.ts +40 -20
- package/project/.sdk/src/cmp/java/TestEntity_java.ts +107 -26
- package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +2 -2
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +2 -2
- package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +4 -4
- package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +3 -3
- package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +2 -2
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +68 -13
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +46 -4
- package/project/.sdk/src/cmp/kotlin/ReadmeEntity_kotlin.ts +2 -2
- package/project/.sdk/src/cmp/kotlin/ReadmeHowto_kotlin.ts +2 -2
- package/project/.sdk/src/cmp/kotlin/ReadmeQuick_kotlin.ts +5 -5
- package/project/.sdk/src/cmp/kotlin/ReadmeRef_kotlin.ts +3 -3
- package/project/.sdk/src/cmp/kotlin/ReadmeTopQuick_kotlin.ts +3 -3
- package/project/.sdk/src/cmp/kotlin/ReadmeTopTest_kotlin.ts +2 -2
- package/project/.sdk/src/cmp/kotlin/TestDirect_kotlin.ts +41 -21
- package/project/.sdk/src/cmp/kotlin/TestEntity_kotlin.ts +99 -22
- package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +2 -2
- package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +2 -2
- package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +4 -4
- package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +3 -3
- package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +3 -3
- package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +2 -2
- package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +40 -16
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +108 -30
- package/project/.sdk/src/cmp/ocaml/ReadmeEntity_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/ocaml/ReadmeHowto_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/ocaml/ReadmeQuick_ocaml.ts +4 -4
- package/project/.sdk/src/cmp/ocaml/ReadmeRef_ocaml.ts +3 -3
- package/project/.sdk/src/cmp/ocaml/ReadmeTopQuick_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/ocaml/ReadmeTopTest_ocaml.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeEntity_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeHowto_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeQuick_perl.ts +4 -4
- package/project/.sdk/src/cmp/perl/ReadmeRef_perl.ts +3 -3
- package/project/.sdk/src/cmp/perl/ReadmeTopQuick_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/ReadmeTopTest_perl.ts +2 -2
- package/project/.sdk/src/cmp/perl/TestDirect_perl.ts +35 -16
- package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +98 -22
- package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +2 -2
- package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +2 -2
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +4 -4
- package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +3 -3
- package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +2 -2
- package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +2 -2
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +33 -16
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +98 -29
- package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +2 -2
- package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +2 -2
- package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +4 -4
- package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +3 -3
- package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +2 -2
- package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +2 -2
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +39 -16
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +90 -27
- package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +4 -4
- package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +3 -3
- package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +2 -2
- package/project/.sdk/src/cmp/rb/TestClean_rb.ts +1 -1
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +33 -16
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +90 -25
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +3 -3
- package/project/.sdk/src/cmp/rust/EntityOperation_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/Main_rust.ts +3 -1
- package/project/.sdk/src/cmp/rust/ReadmeEntity_rust.ts +2 -2
- package/project/.sdk/src/cmp/rust/ReadmeHowto_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/ReadmeModel_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +5 -5
- package/project/.sdk/src/cmp/rust/ReadmeRef_rust.ts +4 -4
- package/project/.sdk/src/cmp/rust/ReadmeTopQuick_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/ReadmeTopTest_rust.ts +3 -3
- package/project/.sdk/src/cmp/rust/TestClean_rust.ts +1 -1
- package/project/.sdk/src/cmp/rust/TestDirect_rust.ts +40 -12
- package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +109 -26
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +2 -2
- package/project/.sdk/src/cmp/scala/ReadmeEntity_scala.ts +2 -2
- package/project/.sdk/src/cmp/scala/ReadmeHowto_scala.ts +2 -2
- package/project/.sdk/src/cmp/scala/ReadmeQuick_scala.ts +5 -5
- package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +3 -3
- package/project/.sdk/src/cmp/scala/ReadmeTopQuick_scala.ts +3 -3
- package/project/.sdk/src/cmp/scala/ReadmeTopTest_scala.ts +2 -2
- package/project/.sdk/src/cmp/scala/TestDirect_scala.ts +2 -6
- package/project/.sdk/src/cmp/scala/TestEntity_scala.ts +36 -7
- package/project/.sdk/src/cmp/swift/ReadmeEntity_swift.ts +2 -2
- package/project/.sdk/src/cmp/swift/ReadmeHowto_swift.ts +2 -2
- package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +5 -5
- package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -3
- package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -2
- package/project/.sdk/src/cmp/swift/ReadmeTopTest_swift.ts +2 -2
- package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +2 -2
- package/project/.sdk/src/cmp/ts/ReadmeExamplesTest_ts.ts +49 -19
- package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +2 -2
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +4 -4
- package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +3 -3
- package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +3 -3
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +54 -23
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +49 -4
- package/project/.sdk/src/cmp/zig/ReadmeEntity_zig.ts +2 -2
- package/project/.sdk/src/cmp/zig/ReadmeHowto_zig.ts +2 -2
- package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +4 -4
- package/project/.sdk/src/cmp/zig/ReadmeRef_zig.ts +3 -3
- package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
- package/project/.sdk/src/cmp/zig/ReadmeTopTest_zig.ts +2 -2
- package/project/.sdk/tm/c/core/sdk.h +2 -2
- package/project/.sdk/tm/c/tests/primary_utility_test.c +37 -0
- package/project/.sdk/tm/c/utility/fetcher.c +31 -1
- package/project/.sdk/tm/c/utility/make_url.c +6 -2
- package/project/.sdk/tm/clojure/src/sdk/core.clj +21 -3
- package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +34 -0
- package/project/.sdk/tm/cpp/test/primary_utility_test.cpp +37 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +28 -2
- package/project/.sdk/tm/csharp/test/PrimaryUtilityTest.cs +40 -0
- package/project/.sdk/tm/csharp/utility/Fetcher.cs +27 -0
- package/project/.sdk/tm/csharp/utility/MakeUrl.cs +7 -2
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +30 -3
- package/project/.sdk/tm/elixir/test/pipeline_test.exs +23 -0
- package/project/.sdk/tm/go/core/helpers.go +1 -1
- package/project/.sdk/tm/go/core/types.go +9 -1
- package/project/.sdk/tm/go/test/feature_corpus_test.go +3 -4
- package/project/.sdk/tm/go/test/primary_utility_test.go +28 -0
- package/project/.sdk/tm/go/utility/fetcher.go +26 -0
- package/project/.sdk/tm/go/utility/make_url.go +5 -2
- package/project/.sdk/tm/java/test/FeatureCorpusTest.java +4 -5
- package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +49 -0
- package/project/.sdk/tm/java/utility/Fetcher.java +24 -0
- package/project/.sdk/tm/java/utility/MakeUrl.java +6 -2
- package/project/.sdk/tm/js/src/utility/FetcherUtility.js +24 -0
- package/project/.sdk/tm/js/src/utility/MakeUrlUtility.js +6 -2
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +7 -6
- package/project/.sdk/tm/js/test/live-entity.js +18 -6
- package/project/.sdk/tm/js/test/live-runner.js +15 -3
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +25 -0
- package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +48 -0
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +20 -0
- package/project/.sdk/tm/kotlin/utility/MakeSpecUrl.kt +6 -2
- package/project/.sdk/tm/lua/test/pipeline_test.lua +27 -0
- package/project/.sdk/tm/lua/test/primary_utility_test.lua +36 -0
- package/project/.sdk/tm/lua/utility/fetcher.lua +31 -0
- package/project/.sdk/tm/lua/utility/make_url.lua +6 -2
- package/project/.sdk/tm/ocaml/Makefile +5 -1
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +36 -4
- package/project/.sdk/tm/ocaml/test/t_pipeline.ml +22 -0
- package/project/.sdk/tm/perl/t/primary_utility.t +22 -0
- package/project/.sdk/tm/perl/utility/fetcher.pm +18 -0
- package/project/.sdk/tm/perl/utility/make_url.pm +4 -2
- package/project/.sdk/tm/php/test/FeatureCorpusTest.php +6 -5
- package/project/.sdk/tm/php/test/PipelineTest.php +31 -7
- package/project/.sdk/tm/php/utility/Fetcher.php +34 -27
- package/project/.sdk/tm/php/utility/MakeOptions.php +2 -1
- package/project/.sdk/tm/php/utility/MakeUrl.php +6 -2
- package/project/.sdk/tm/py/pkg/utility/fetcher.py +23 -0
- package/project/.sdk/tm/py/pkg/utility/make_url.py +5 -2
- package/project/.sdk/tm/py/test/test_feature_corpus.py +5 -5
- package/project/.sdk/tm/py/test/test_primary_utility.py +21 -0
- package/project/.sdk/tm/rb/core/context.rb +1 -1
- package/project/.sdk/tm/rb/core/error.rb +20 -1
- package/project/.sdk/tm/rb/test/feature_corpus_test.rb +4 -5
- package/project/.sdk/tm/rb/test/feature_test.rb +2 -2
- package/project/.sdk/tm/rb/test/omni.rb +1 -1
- package/project/.sdk/tm/rb/test/pipeline_test.rb +19 -2
- package/project/.sdk/tm/rb/test/primary_utility_test.rb +28 -1
- package/project/.sdk/tm/rb/utility/fetcher.rb +20 -1
- package/project/.sdk/tm/rb/utility/make_error.rb +1 -1
- package/project/.sdk/tm/rb/utility/make_url.rb +4 -2
- package/project/.sdk/tm/rust/core/helpers.rs +1 -1
- package/project/.sdk/tm/rust/core/types.rs +2 -2
- package/project/.sdk/tm/rust/tests/primary_utility_test.rs +34 -0
- package/project/.sdk/tm/rust/utility/fetcher.rs +27 -0
- package/project/.sdk/tm/rust/utility/make_url.rs +7 -2
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +51 -1
- package/project/.sdk/tm/scala/utility/Fetcher.scala +16 -0
- package/project/.sdk/tm/scala/utility/Make.scala +6 -2
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +24 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Make.swift +6 -2
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PrimaryUtilityTest.swift +34 -0
- package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +24 -0
- package/project/.sdk/tm/ts/src/utility/MakeUrlUtility.ts +6 -2
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +7 -6
- package/project/.sdk/tm/ts/test/live-entity.ts +20 -5
- package/project/.sdk/tm/ts/test/live-runner.ts +17 -3
- package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +25 -0
- package/project/.sdk/tm/zig/core/utility.zig +30 -3
- package/project/.sdk/tm/zig/test/primary_utility_test.zig +28 -0
- package/project/sdkgen-package.json +1 -1
- package/src/cmp/ReadmeTop.ts +3 -3
- package/src/helpers/opExample.ts +16 -1
- package/src/helpers/opShape.ts +64 -30
- package/src/helpers/pointPath.ts +19 -0
- package/src/helpers/testPolicy.ts +316 -2
- package/src/sdkgen.ts +37 -5
|
@@ -256,12 +256,11 @@ class FeatureCorpusTest < Minitest::Test
|
|
|
256
256
|
end
|
|
257
257
|
end
|
|
258
258
|
|
|
259
|
-
#
|
|
260
|
-
#
|
|
259
|
+
# With every operation needing an argument there is nothing to drive:
|
|
260
|
+
# skip and say so, as the clean test does, rather than fail.
|
|
261
261
|
def test_sdk_has_an_operation_the_corpus_can_drive
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
"corpus cannot exercise a feature without one"
|
|
262
|
+
skip("no declared operation completes against a plain 200 with no arguments (each needs a path parameter or a body); nothing for the corpus to drive") if usable_ops(2).empty?
|
|
263
|
+
refute_empty usable_ops(2)
|
|
265
264
|
end
|
|
266
265
|
|
|
267
266
|
def test_feature_corpus
|
|
@@ -412,7 +412,7 @@ class FeatureTest < Minitest::Test
|
|
|
412
412
|
skip_unless_feature("retry")
|
|
413
413
|
clock = H::Clock.new
|
|
414
414
|
server, calls = H.recording_server { |n, _fd|
|
|
415
|
-
n < 3 ? [nil, ProjectNameError.new("boom", "boom")] : [H.make_response(200, { "ok" => true }), nil]
|
|
415
|
+
n < 3 ? [nil, ProjectNameError.new("boom", code: "boom")] : [H.make_response(200, { "ok" => true }), nil]
|
|
416
416
|
}
|
|
417
417
|
h = harness([fspec("retry",
|
|
418
418
|
"retries" => 2, "minDelay" => 1, "jitter" => false, "sleep" => clock.sleeper)],
|
|
@@ -425,7 +425,7 @@ class FeatureTest < Minitest::Test
|
|
|
425
425
|
def test_retry_exhausted_transport_error_surfaces
|
|
426
426
|
skip_unless_feature("retry")
|
|
427
427
|
clock = H::Clock.new
|
|
428
|
-
server, calls = H.recording_server { |_n, _fd| [nil, ProjectNameError.new("boom", "boom")] }
|
|
428
|
+
server, calls = H.recording_server { |_n, _fd| [nil, ProjectNameError.new("boom", code: "boom")] }
|
|
429
429
|
h = harness([fspec("retry",
|
|
430
430
|
"retries" => 2, "minDelay" => 1, "jitter" => false, "sleep" => clock.sleeper)],
|
|
431
431
|
server: server)
|
|
@@ -301,7 +301,7 @@ module ProjectNameOmni
|
|
|
301
301
|
err_map = res_map['err']
|
|
302
302
|
if err_map.is_a?(::Hash) && err_map['message'].is_a?(::String) &&
|
|
303
303
|
!err_map['message'].empty?
|
|
304
|
-
ctx.result.err = ProjectNameError.new(
|
|
304
|
+
ctx.result.err = ProjectNameError.new(err_map['message'])
|
|
305
305
|
end
|
|
306
306
|
end
|
|
307
307
|
|
|
@@ -316,7 +316,7 @@ class PipelineTest < Minitest::Test
|
|
|
316
316
|
end
|
|
317
317
|
|
|
318
318
|
def test_make_request_a_transport_error_tuple_lands_on_the_response
|
|
319
|
-
boom = ProjectNameError.new("boom", "boom")
|
|
319
|
+
boom = ProjectNameError.new("boom", code: "boom")
|
|
320
320
|
u = util_with(->(_c, _u, _f) { [nil, boom] })
|
|
321
321
|
ctx = make_ctx(utility: u)
|
|
322
322
|
ctx.spec = request_spec
|
|
@@ -360,7 +360,7 @@ class PipelineTest < Minitest::Test
|
|
|
360
360
|
|
|
361
361
|
def test_make_request_a_fetchdef_error_surfaces_as_a_response_error
|
|
362
362
|
u = @client.get_utility
|
|
363
|
-
u.make_fetch_def = ->(ctx) { [nil, ProjectNameError.new("
|
|
363
|
+
u.make_fetch_def = ->(ctx) { [nil, ProjectNameError.new("boom", code: "fetchdef_boom")] }
|
|
364
364
|
ctx = make_ctx(utility: u)
|
|
365
365
|
ctx.spec = request_spec
|
|
366
366
|
response, err = u.make_request.call(ctx)
|
|
@@ -448,6 +448,23 @@ class PipelineTest < Minitest::Test
|
|
|
448
448
|
assert_equal "rbac_denied", err.code
|
|
449
449
|
end
|
|
450
450
|
|
|
451
|
+
# minitest reports an escaped error it cannot marshal as
|
|
452
|
+
# `e.class.new(e.message)`, so both forms must keep the message.
|
|
453
|
+
def test_make_error_survives_a_rebuild_and_a_marshal
|
|
454
|
+
ctx = make_ctx
|
|
455
|
+
ctx.result = ProjectNameResult.new({ "ok" => false, "status" => 429 })
|
|
456
|
+
err = assert_raises(ProjectNameError) {
|
|
457
|
+
@utility.make_error.call(ctx, ctx.make_error("request_status", "request: 429: Too Many Requests"))
|
|
458
|
+
}
|
|
459
|
+
refute_empty err.message
|
|
460
|
+
assert_equal err.message, err.class.new(err.message).message
|
|
461
|
+
|
|
462
|
+
copy = Marshal.load(Marshal.dump(err))
|
|
463
|
+
assert_equal [ProjectNameError, err.message, "request_status", 429, err.backtrace],
|
|
464
|
+
[copy.class, copy.message, copy.code, copy.status, copy.backtrace]
|
|
465
|
+
assert_nil copy.ctx
|
|
466
|
+
end
|
|
467
|
+
|
|
451
468
|
|
|
452
469
|
# === feature ordering ===
|
|
453
470
|
|
|
@@ -81,7 +81,7 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
81
81
|
return nil unless m.is_a?(Hash)
|
|
82
82
|
msg = m["message"]
|
|
83
83
|
return nil unless msg.is_a?(String) && !msg.empty?
|
|
84
|
-
ProjectNameError.new(m["code"] || ""
|
|
84
|
+
ProjectNameError.new(msg, code: m["code"] || "")
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
|
|
@@ -278,6 +278,33 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
278
278
|
assert_includes err.to_s.downcase, "blocked"
|
|
279
279
|
end
|
|
280
280
|
|
|
281
|
+
# Nothing listens on port 9: a request the guard let through fails there.
|
|
282
|
+
def test_fetcher_getonly_guard
|
|
283
|
+
live_client = ProjectNameSDK.new({ "base" => "http://127.0.0.1:9" })
|
|
284
|
+
live_utility = live_client.get_utility
|
|
285
|
+
ctx = live_utility.make_context.call({
|
|
286
|
+
"opname" => "create",
|
|
287
|
+
"client" => live_client,
|
|
288
|
+
"utility" => live_utility,
|
|
289
|
+
}, nil)
|
|
290
|
+
url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01"
|
|
291
|
+
prior = ENV["VOXGIG_GETONLY_GUARD"]
|
|
292
|
+
ENV["VOXGIG_GETONLY_GUARD"] = "TRUE"
|
|
293
|
+
begin
|
|
294
|
+
_, err = live_utility.fetcher.call(ctx, url, { "method" => "POST", "headers" => {} })
|
|
295
|
+
assert_kind_of ProjectNameError, err
|
|
296
|
+
assert_equal "fetch_getonly_block", err.code
|
|
297
|
+
assert_includes err.msg, "[GET-ONLY GUARD] blocked POST /planet/p1"
|
|
298
|
+
refute_includes err.msg, "GUARDKEY01"
|
|
299
|
+
|
|
300
|
+
_, geterr = live_utility.fetcher.call(ctx, url, { "method" => "GET", "headers" => {} })
|
|
301
|
+
assert geterr, "expected the GET to reach the closed port"
|
|
302
|
+
refute_kind_of ProjectNameError, geterr
|
|
303
|
+
ensure
|
|
304
|
+
ENV["VOXGIG_GETONLY_GUARD"] = prior
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
|
|
281
308
|
|
|
282
309
|
# === makeContext ===
|
|
283
310
|
|
|
@@ -41,6 +41,21 @@ module ProjectNameUtilities
|
|
|
41
41
|
nil
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
+
GETONLY_ENV = "VOXGIG_GETONLY_GUARD"
|
|
45
|
+
|
|
46
|
+
# A GET-only live run refuses any other method before it is sent. The error
|
|
47
|
+
# names the path alone: the query can carry a credential.
|
|
48
|
+
def self.getonly_refusal(ctx, fullurl, method)
|
|
49
|
+
method = method.to_s.upcase
|
|
50
|
+
method = "GET" if method.empty?
|
|
51
|
+
return nil if ENV[GETONLY_ENV] != "TRUE" || method == "GET"
|
|
52
|
+
rest = fullurl.to_s
|
|
53
|
+
rest = rest.split("://", 2)[1].sub(%r{\A[^/?#]*}, "") if rest.include?("://")
|
|
54
|
+
path = rest[/\A[^?#]*/]
|
|
55
|
+
path = "/" if path.empty?
|
|
56
|
+
ctx.make_error("fetch_getonly_block", "[GET-ONLY GUARD] blocked #{method} #{path}")
|
|
57
|
+
end
|
|
58
|
+
|
|
44
59
|
DefaultHttpFetch = ->(fullurl, fetchdef) {
|
|
45
60
|
method_str = fetchdef["method"] || "GET"
|
|
46
61
|
body_str = fetchdef["body"]
|
|
@@ -134,7 +149,11 @@ module ProjectNameUtilities
|
|
|
134
149
|
|
|
135
150
|
sys_fetch = VoxgigStruct.getpath(options, "system.fetch")
|
|
136
151
|
|
|
137
|
-
|
|
152
|
+
if sys_fetch.nil?
|
|
153
|
+
refused = ProjectNameUtilities.getonly_refusal(ctx, fullurl, fetchdef["method"])
|
|
154
|
+
return nil, refused if refused
|
|
155
|
+
return DefaultHttpFetch.call(fullurl, fetchdef)
|
|
156
|
+
end
|
|
138
157
|
return sys_fetch.call(fullurl, fetchdef) if sys_fetch.is_a?(Proc)
|
|
139
158
|
|
|
140
159
|
return nil, ctx.make_error("fetch_invalid", "system.fetch is not a valid function")
|
|
@@ -36,7 +36,7 @@ module ProjectNameUtilities
|
|
|
36
36
|
# The context stays reachable for a debugger (`err.ctx`) and is left out
|
|
37
37
|
# of every serialiser the error defines; result and spec are cleaned
|
|
38
38
|
# COPIES, so masking them never masks the pipeline's own objects.
|
|
39
|
-
sdk_err = ProjectNameError.new(
|
|
39
|
+
sdk_err = ProjectNameError.new(msg, ctx: ctx)
|
|
40
40
|
sdk_err.result = clean.call(ctx, result)
|
|
41
41
|
sdk_err.spec = clean.call(ctx, spec)
|
|
42
42
|
|
|
@@ -14,12 +14,14 @@ module ProjectNameUtilities
|
|
|
14
14
|
# Sent with the request, never recorded as the entity's match.
|
|
15
15
|
authquery = (spec.respond_to?(:authquery) ? spec.authquery : nil) || []
|
|
16
16
|
|
|
17
|
-
# A route the definition ends with a slash keeps it
|
|
18
|
-
#
|
|
17
|
+
# A route the definition ends with a slash keeps it, for a Django REST server,
|
|
18
|
+
# and a host with no path takes /, or luasocket reads a query as the host.
|
|
19
19
|
orig = ctx.point ? VoxgigStruct.getprop(ctx.point, "orig") : nil
|
|
20
20
|
if orig.is_a?(String) && orig.end_with?("/") && spec.suffix.to_s.empty? && !url.end_with?("/")
|
|
21
21
|
url += "/"
|
|
22
22
|
end
|
|
23
|
+
authority = url.index("://")
|
|
24
|
+
url += "/" if authority && 0 < authority && url[(authority + 3)..] !~ %r{[/?#]}
|
|
23
25
|
|
|
24
26
|
param_items = VoxgigStruct.items(spec.params)
|
|
25
27
|
if param_items
|
|
@@ -13,7 +13,7 @@ use crate::utility::voxgigstruct::major::Injection;
|
|
|
13
13
|
use vs::Value;
|
|
14
14
|
|
|
15
15
|
// UnsupportedOp is returned by entity stub methods for operations the
|
|
16
|
-
// underlying API spec doesn't define. The static
|
|
16
|
+
// underlying API spec doesn't define. The static ProjectNameEntityBase trait
|
|
17
17
|
// requires every CRUD method on every entity, so absent ops must still be
|
|
18
18
|
// callable — they error at runtime instead of failing to compile.
|
|
19
19
|
pub fn unsupported_op(opname: &str, entityname: &str) -> ProjectNameError {
|
|
@@ -76,9 +76,9 @@ pub trait Entity {
|
|
|
76
76
|
fn deleted(&self) -> bool;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
///
|
|
79
|
+
/// ProjectNameEntityBase: the full CRUD contract every generated entity
|
|
80
80
|
/// implements. Ops the API spec doesn't define are runtime-error stubs.
|
|
81
|
-
pub trait
|
|
81
|
+
pub trait ProjectNameEntityBase: Entity + Sized {
|
|
82
82
|
fn load(self: &Rc<Self>, reqmatch: Value, ctrl: Value) -> Result<Rc<Self>, ProjectNameError>;
|
|
83
83
|
fn list(self: &Rc<Self>, reqmatch: Value, ctrl: Value) -> Result<Vec<Rc<Self>>, ProjectNameError>;
|
|
84
84
|
fn create(self: &Rc<Self>, reqdata: Value, ctrl: Value) -> Result<Rc<Self>, ProjectNameError>;
|
|
@@ -376,6 +376,40 @@ fn primary_fetcher_blocked_test_mode() {
|
|
|
376
376
|
);
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
// Nothing listens on port 9: a request the guard let through fails there.
|
|
380
|
+
#[test]
|
|
381
|
+
fn primary_fetcher_getonly_guard() {
|
|
382
|
+
let live_client = ProjectNameSDK::new(jo(vec![("base", Value::str("http://127.0.0.1:9"))]));
|
|
383
|
+
let live_utility = live_client.get_utility();
|
|
384
|
+
let ctx = live_utility.make_context(
|
|
385
|
+
CtxSpec {
|
|
386
|
+
opname: Some("create".to_string()),
|
|
387
|
+
client: Some(live_client.clone()),
|
|
388
|
+
utility: Some(live_utility.clone()),
|
|
389
|
+
..Default::default()
|
|
390
|
+
},
|
|
391
|
+
None,
|
|
392
|
+
);
|
|
393
|
+
let url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01";
|
|
394
|
+
let def = |method: &str| jo(vec![("method", Value::str(method)), ("headers", Value::empty_map())]);
|
|
395
|
+
|
|
396
|
+
let prior = std::env::var("VOXGIG_GETONLY_GUARD").ok();
|
|
397
|
+
std::env::set_var("VOXGIG_GETONLY_GUARD", "TRUE");
|
|
398
|
+
let refused = live_utility.fetch(&ctx, url, &def("POST")).err();
|
|
399
|
+
let sent = live_utility.fetch(&ctx, url, &def("GET")).err();
|
|
400
|
+
match prior {
|
|
401
|
+
Some(v) => std::env::set_var("VOXGIG_GETONLY_GUARD", v),
|
|
402
|
+
None => std::env::remove_var("VOXGIG_GETONLY_GUARD"),
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
let refused = refused.expect("expected the POST to be refused");
|
|
406
|
+
assert_eq!(refused.code, "fetch_getonly_block");
|
|
407
|
+
assert!(refused.msg.contains("[GET-ONLY GUARD] blocked POST /planet/p1"), "{}", refused.msg);
|
|
408
|
+
assert!(!refused.msg.contains("GUARDKEY01"), "{}", refused.msg);
|
|
409
|
+
let sent = sent.expect("expected the GET to reach the closed port");
|
|
410
|
+
assert_ne!(sent.code, "fetch_getonly_block", "{}", sent.msg);
|
|
411
|
+
}
|
|
412
|
+
|
|
379
413
|
#[test]
|
|
380
414
|
fn primary_make_context_basic() {
|
|
381
415
|
let (client, utility) = base_client();
|
|
@@ -44,11 +44,38 @@ fn agent_for(fetchdef: &Value) -> ureq::Agent {
|
|
|
44
44
|
.clone()
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
const GETONLY_ENV: &str = "VOXGIG_GETONLY_GUARD";
|
|
48
|
+
|
|
49
|
+
// A GET-only live run refuses any other method before it is sent. The error
|
|
50
|
+
// names the path alone: the query can carry a credential.
|
|
51
|
+
fn getonly_refusal(fullurl: &str, method: &str) -> Option<ProjectNameError> {
|
|
52
|
+
let method = method.to_uppercase();
|
|
53
|
+
if std::env::var(GETONLY_ENV).ok().as_deref() != Some("TRUE") || method == "GET" {
|
|
54
|
+
return None;
|
|
55
|
+
}
|
|
56
|
+
let rest = match fullurl.find("://") {
|
|
57
|
+
Some(i) => {
|
|
58
|
+
let auth = &fullurl[i + 3..];
|
|
59
|
+
&auth[auth.find(|c| matches!(c, '/' | '?' | '#')).unwrap_or(auth.len())..]
|
|
60
|
+
}
|
|
61
|
+
None => fullurl,
|
|
62
|
+
};
|
|
63
|
+
let path = &rest[..rest.find(|c| matches!(c, '?' | '#')).unwrap_or(rest.len())];
|
|
64
|
+
let path = if path.is_empty() { "/" } else { path };
|
|
65
|
+
Some(ProjectNameError::new(
|
|
66
|
+
"fetch_getonly_block",
|
|
67
|
+
&format!("[GET-ONLY GUARD] blocked {} {}", method, path),
|
|
68
|
+
))
|
|
69
|
+
}
|
|
70
|
+
|
|
47
71
|
// Default live transport: ureq (blocking, minimal).
|
|
48
72
|
fn default_http_fetch(fullurl: &str, fetchdef: &Value) -> Result<Value, ProjectNameError> {
|
|
49
73
|
let method = get_str(fetchdef, "method")
|
|
50
74
|
.filter(|m| !m.is_empty())
|
|
51
75
|
.unwrap_or_else(|| "GET".to_string());
|
|
76
|
+
if let Some(refused) = getonly_refusal(fullurl, &method) {
|
|
77
|
+
return Err(refused);
|
|
78
|
+
}
|
|
52
79
|
|
|
53
80
|
let agent = agent_for(fetchdef);
|
|
54
81
|
let mut req = agent.request(&method, fullurl);
|
|
@@ -60,13 +60,18 @@ pub fn make_url_util(ctx: &Rc<Context>) -> Result<String, ProjectNameError> {
|
|
|
60
60
|
true,
|
|
61
61
|
);
|
|
62
62
|
|
|
63
|
-
// A route the definition ends with a slash keeps it
|
|
64
|
-
//
|
|
63
|
+
// A route the definition ends with a slash keeps it, for a Django REST server,
|
|
64
|
+
// and a host with no path takes /, or luasocket reads a query as the host.
|
|
65
65
|
if let Value::Str(orig) = getp(&ctx.point.borrow().clone(), "orig") {
|
|
66
66
|
if orig.ends_with('/') && suffixless && !url.ends_with('/') {
|
|
67
67
|
url.push('/');
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
if let Some(authority) = url.find("://") {
|
|
71
|
+
if 0 < authority && !url[authority + 3..].contains(|c| matches!(c, '/' | '?' | '#')) {
|
|
72
|
+
url.push('/');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
70
75
|
|
|
71
76
|
let resmatch = Value::empty_map();
|
|
72
77
|
|
|
@@ -706,6 +706,27 @@ object SdkTestMain {
|
|
|
706
706
|
// Small identity wrapper so IntConsumer/LongSupplier land in the map as-is.
|
|
707
707
|
private def f0(o: Object): Object = o
|
|
708
708
|
|
|
709
|
+
// Nothing listens on port 9: a request the guard let through fails there.
|
|
710
|
+
// A JVM cannot set its own environment, so the probe runs in a child JVM.
|
|
711
|
+
private def testGetOnlyGuard(): Unit = {
|
|
712
|
+
val out =
|
|
713
|
+
if ("TRUE" == System.getenv("VOXGIG_GETONLY_GUARD")) SdkGetOnlyProbe.probe()
|
|
714
|
+
else {
|
|
715
|
+
val pb = new ProcessBuilder(ProcessHandle.current().info().command().orElse("java"),
|
|
716
|
+
"-cp", System.getProperty("java.class.path"), "SdkGetOnlyProbe")
|
|
717
|
+
pb.environment().put("VOXGIG_GETONLY_GUARD", "TRUE")
|
|
718
|
+
pb.redirectErrorStream(true)
|
|
719
|
+
val proc = pb.start()
|
|
720
|
+
val text = new String(proc.getInputStream.readAllBytes(), "UTF-8")
|
|
721
|
+
eqI("getonly.exit", 0, proc.waitFor())
|
|
722
|
+
text
|
|
723
|
+
}
|
|
724
|
+
check("getonly.refused",
|
|
725
|
+
out.startsWith("fetch_getonly_block [GET-ONLY GUARD] blocked POST /planet/p1\n"), out)
|
|
726
|
+
check("getonly.get", out.trim.endsWith("\nsent"), out)
|
|
727
|
+
check("getonly.query", !out.contains("GUARDKEY01"), out)
|
|
728
|
+
}
|
|
729
|
+
|
|
709
730
|
def main(args: Array[String]): Unit = {
|
|
710
731
|
val suites: Seq[(String, () => Unit)] = Seq(
|
|
711
732
|
"netsim" -> testNetsim, "retry" -> testRetry, "timeout" -> testTimeout,
|
|
@@ -715,7 +736,7 @@ object SdkTestMain {
|
|
|
715
736
|
"paging" -> testPaging, "streaming" -> testStreaming, "proxy" -> testProxy,
|
|
716
737
|
"composition" -> testComposition, "featureAdd" -> testFeatureAdd,
|
|
717
738
|
"featureOrder" -> testFeatureOrder, "entityCrud" -> testEntityCrud,
|
|
718
|
-
"entityStream" -> testEntityStream)
|
|
739
|
+
"entityStream" -> testEntityStream, "getOnlyGuard" -> testGetOnlyGuard)
|
|
719
740
|
|
|
720
741
|
suites.foreach { case (name, fn) =>
|
|
721
742
|
try fn()
|
|
@@ -728,3 +749,32 @@ object SdkTestMain {
|
|
|
728
749
|
if (failures.size() > 0) System.exit(1)
|
|
729
750
|
}
|
|
730
751
|
}
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
// The GET-only guard test's child: a POST, then a GET, to a closed port.
|
|
755
|
+
object SdkGetOnlyProbe {
|
|
756
|
+
def probe(): String = {
|
|
757
|
+
val opts = new LinkedHashMap[String, Object]()
|
|
758
|
+
opts.put("base", "http://127.0.0.1:9")
|
|
759
|
+
val client = new ProjectNameSDK(opts)
|
|
760
|
+
val utility = client.getUtility()
|
|
761
|
+
val cm = new LinkedHashMap[String, Object]()
|
|
762
|
+
cm.put("opname", "create")
|
|
763
|
+
val ctx = utility.makeContext(cm, client.getRootCtx())
|
|
764
|
+
val url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01"
|
|
765
|
+
val out = new StringBuilder()
|
|
766
|
+
for (method <- Seq("POST", "GET")) {
|
|
767
|
+
val fetchdef = new LinkedHashMap[String, Object]()
|
|
768
|
+
fetchdef.put("method", method)
|
|
769
|
+
fetchdef.put("headers", new LinkedHashMap[String, Object]())
|
|
770
|
+
try { utility.fetcher(ctx, url, fetchdef); out.append("answered\n") }
|
|
771
|
+
catch {
|
|
772
|
+
case e: SdkError => out.append(e.code).append(' ').append(e.msg).append('\n')
|
|
773
|
+
case _: RuntimeException => out.append("sent\n")
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
out.toString
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
def main(args: Array[String]): Unit = print(probe())
|
|
780
|
+
}
|
|
@@ -41,9 +41,25 @@ object Fetcher {
|
|
|
41
41
|
})
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
val GETONLY_ENV = "VOXGIG_GETONLY_GUARD"
|
|
45
|
+
|
|
46
|
+
// A GET-only live run refuses any other method before it is sent. The error
|
|
47
|
+
// names the path alone: the query can carry a credential.
|
|
48
|
+
def getOnlyRefusal(fullurl: String, method: String): SdkError = {
|
|
49
|
+
val upper = method.toUpperCase(java.util.Locale.ROOT)
|
|
50
|
+
if ("TRUE" != System.getenv(GETONLY_ENV) || "GET" == upper) return null
|
|
51
|
+
val scheme = fullurl.indexOf("://")
|
|
52
|
+
val rest = if (scheme < 0) fullurl else fullurl.substring(scheme + 3).replaceFirst("^[^/?#]*", "")
|
|
53
|
+
val path = rest.split("[?#]", 2)(0)
|
|
54
|
+
new SdkError("fetch_getonly_block",
|
|
55
|
+
"[GET-ONLY GUARD] blocked " + upper + " " + (if (path.isEmpty) "/" else path), null)
|
|
56
|
+
}
|
|
57
|
+
|
|
44
58
|
def defaultHttpFetch(fullurl: String, fetchdef: JMap[String, Object]): JMap[String, Object] = {
|
|
45
59
|
var method = fetchdef.get("method") match { case s: String => s; case _ => "" }
|
|
46
60
|
if ("" == method) method = "GET"
|
|
61
|
+
val refused = getOnlyRefusal(fullurl, method)
|
|
62
|
+
if (refused != null) throw refused
|
|
47
63
|
|
|
48
64
|
var bodyPublisher = HttpRequest.BodyPublishers.noBody()
|
|
49
65
|
fetchdef.get("body") match {
|
|
@@ -678,14 +678,18 @@ object MakeUrl {
|
|
|
678
678
|
joinParts.add(spec.suffix)
|
|
679
679
|
var url = Struct.join(joinParts, "/", true)
|
|
680
680
|
|
|
681
|
-
// A route the definition ends with a slash keeps it
|
|
682
|
-
//
|
|
681
|
+
// A route the definition ends with a slash keeps it, for a Django REST server,
|
|
682
|
+
// and a host with no path takes /, or luasocket reads a query as the host.
|
|
683
683
|
val orig = if (ctx.point == null) null else Struct.getprop(ctx.point, "orig", null)
|
|
684
684
|
orig match {
|
|
685
685
|
case o: String if o.endsWith("/") && (spec.suffix == null || spec.suffix.isEmpty) && !url.endsWith("/") =>
|
|
686
686
|
url = url + "/"
|
|
687
687
|
case _ =>
|
|
688
688
|
}
|
|
689
|
+
val authority = url.indexOf("://")
|
|
690
|
+
if (0 < authority && !url.substring(authority + 3).exists(c => 0 <= "/?#".indexOf(c))) {
|
|
691
|
+
url = url + "/"
|
|
692
|
+
}
|
|
689
693
|
|
|
690
694
|
val resmatch = new LinkedHashMap[String, Object]()
|
|
691
695
|
|
|
@@ -42,7 +42,31 @@ private let manualRedirectSession = URLSession(
|
|
|
42
42
|
configuration: cookielessConfiguration(),
|
|
43
43
|
delegate: ManualRedirectDelegate(), delegateQueue: nil)
|
|
44
44
|
|
|
45
|
+
let getOnlyEnv = "VOXGIG_GETONLY_GUARD"
|
|
46
|
+
|
|
47
|
+
// A GET-only live run refuses any other method before it is sent. The error
|
|
48
|
+
// names the path alone: the query can carry a credential.
|
|
49
|
+
func getOnlyRefusal(_ fullurl: String, _ method: String) -> ProjectNameError? {
|
|
50
|
+
let upper = method.uppercased()
|
|
51
|
+
if ProcessInfo.processInfo.environment[getOnlyEnv] != "TRUE" || upper == "GET" {
|
|
52
|
+
return nil
|
|
53
|
+
}
|
|
54
|
+
var rest = Substring(fullurl)
|
|
55
|
+
if let scheme = rest.range(of: "://") {
|
|
56
|
+
rest = rest[scheme.upperBound...]
|
|
57
|
+
rest = rest[(rest.firstIndex(where: { "/?#".contains($0) }) ?? rest.endIndex)...]
|
|
58
|
+
}
|
|
59
|
+
let path = rest[..<(rest.firstIndex(where: { "?#".contains($0) }) ?? rest.endIndex)]
|
|
60
|
+
return ProjectNameError("fetch_getonly_block",
|
|
61
|
+
"[GET-ONLY GUARD] blocked \(upper) \(path.isEmpty ? "/" : String(path))", nil)
|
|
62
|
+
}
|
|
63
|
+
|
|
45
64
|
func defaultHttpFetch(_ fullurl: String, _ fetchdef: VMap) throws -> Value {
|
|
65
|
+
let method = gp(fetchdef, "method").asString ?? "GET"
|
|
66
|
+
if let refused = getOnlyRefusal(fullurl, method.isEmpty ? "GET" : method) {
|
|
67
|
+
throw refused
|
|
68
|
+
}
|
|
69
|
+
|
|
46
70
|
// A request that cannot be sent fails the operation.
|
|
47
71
|
guard let url = URL(string: fullurl) else {
|
|
48
72
|
throw ProjectNameError("fetch_transport", "the URL could not be parsed", nil)
|
|
@@ -266,12 +266,16 @@ func makeUrlUtil(_ ctx: Context) throws -> String {
|
|
|
266
266
|
// Sent with the request, never recorded as the entity's match.
|
|
267
267
|
let authquery = spec.authquery
|
|
268
268
|
|
|
269
|
-
// A route the definition ends with a slash keeps it
|
|
270
|
-
//
|
|
269
|
+
// A route the definition ends with a slash keeps it, for a Django REST server,
|
|
270
|
+
// and a host with no path takes /, or luasocket reads a query as the host.
|
|
271
271
|
if let orig = gp(ctx.point, "orig").asString, orig.hasSuffix("/"), spec.suffix.isEmpty,
|
|
272
272
|
!url.hasSuffix("/") {
|
|
273
273
|
url += "/"
|
|
274
274
|
}
|
|
275
|
+
if let authority = url.range(of: "://"), url.startIndex < authority.lowerBound,
|
|
276
|
+
!url[authority.upperBound...].contains(where: { "/?#".contains($0) }) {
|
|
277
|
+
url += "/"
|
|
278
|
+
}
|
|
275
279
|
|
|
276
280
|
for item in items(.map(spec.params)) {
|
|
277
281
|
let key = item[0].asString ?? ""
|
|
@@ -425,6 +425,40 @@ final class PrimaryUtilityTest: XCTestCase {
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
// Nothing listens on port 9: a request the guard let through fails there.
|
|
429
|
+
func testFetcherGetOnlyGuard() {
|
|
430
|
+
let opts = VMap()
|
|
431
|
+
opts.entries["base"] = .string("http://127.0.0.1:9")
|
|
432
|
+
let liveClient = ProjectNameSDK(opts)
|
|
433
|
+
let liveUtility = liveClient.getUtility()
|
|
434
|
+
let ctx = liveUtility.makeContext(
|
|
435
|
+
["opname": "create", "client": liveClient, "utility": liveUtility], nil)
|
|
436
|
+
let url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01"
|
|
437
|
+
func def(_ method: String) -> VMap {
|
|
438
|
+
let fetchdef = VMap()
|
|
439
|
+
fetchdef.entries["method"] = .string(method)
|
|
440
|
+
fetchdef.entries["headers"] = .map(VMap())
|
|
441
|
+
return fetchdef
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
let prior = ProcessInfo.processInfo.environment["VOXGIG_GETONLY_GUARD"]
|
|
445
|
+
setenv("VOXGIG_GETONLY_GUARD", "TRUE", 1)
|
|
446
|
+
defer {
|
|
447
|
+
if let prior = prior { setenv("VOXGIG_GETONLY_GUARD", prior, 1) }
|
|
448
|
+
else { unsetenv("VOXGIG_GETONLY_GUARD") }
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
XCTAssertThrowsError(try liveUtility.fetcher(ctx, url, def("POST"))) { error in
|
|
452
|
+
let refused = error as? ProjectNameError
|
|
453
|
+
XCTAssertEqual(refused?.code, "fetch_getonly_block")
|
|
454
|
+
XCTAssertTrue(errMessage(error).contains("[GET-ONLY GUARD] blocked POST /planet/p1"), errMessage(error))
|
|
455
|
+
XCTAssertFalse(errMessage(error).contains("GUARDKEY01"))
|
|
456
|
+
}
|
|
457
|
+
XCTAssertThrowsError(try liveUtility.fetcher(ctx, url, def("GET"))) { error in
|
|
458
|
+
XCTAssertNotEqual((error as? ProjectNameError)?.code, "fetch_getonly_block")
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
428
462
|
func testMakeContextBasic() {
|
|
429
463
|
runsection("makeContext") { args in
|
|
430
464
|
guard let inMap = args.first?.asMap else { return .noval }
|
|
@@ -21,6 +21,23 @@ function defaultUserAgent(fetchdef: Record<string, any>) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
const GETONLY_ENV = 'VOXGIG_GETONLY_GUARD'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// A GET-only live run refuses any other method before it is sent. The error
|
|
28
|
+
// names the path alone: the query can carry a credential.
|
|
29
|
+
function getOnlyRefusal(ctx: Context, fullurl: string, fetchdef: Record<string, any>) {
|
|
30
|
+
const method = String(fetchdef.method || 'GET').toUpperCase()
|
|
31
|
+
if ('TRUE' !== (globalThis as any).process?.env?.[GETONLY_ENV] || 'GET' === method) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
const scheme = fullurl.indexOf('://')
|
|
35
|
+
const rest = scheme < 0 ? fullurl : fullurl.slice(scheme + 3).replace(/^[^/?#]*/, '')
|
|
36
|
+
const path = rest.split(/[?#]/)[0] || '/'
|
|
37
|
+
return ctx.error('fetch_getonly_block', '[GET-ONLY GUARD] blocked ' + method + ' ' + path)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
24
41
|
// Make HTTP call using library. Replace this utility for mocking etc.
|
|
25
42
|
async function fetcher(
|
|
26
43
|
ctx: Context,
|
|
@@ -44,6 +61,13 @@ async function fetcher(
|
|
|
44
61
|
|
|
45
62
|
const fetch = options.system.fetch
|
|
46
63
|
|
|
64
|
+
// The platform's fetch is the SDK's own transport; a supplied one is the
|
|
65
|
+
// caller's, and a mock sends nothing.
|
|
66
|
+
const refused = fetch === globalThis.fetch ? getOnlyRefusal(ctx, fullurl, fetchdef) : undefined
|
|
67
|
+
if (refused) {
|
|
68
|
+
return refused
|
|
69
|
+
}
|
|
70
|
+
|
|
47
71
|
defaultUserAgent(fetchdef)
|
|
48
72
|
|
|
49
73
|
const response = await fetch(fullurl, fetchdef)
|
|
@@ -29,12 +29,16 @@ function makeUrl(ctx: Context): Error | string {
|
|
|
29
29
|
// Sent with the request, never recorded as the entity's match.
|
|
30
30
|
const authquery: string[] = spec.authquery || []
|
|
31
31
|
|
|
32
|
-
// A route the definition ends with a slash keeps it
|
|
33
|
-
//
|
|
32
|
+
// A route the definition ends with a slash keeps it, for a Django REST server,
|
|
33
|
+
// and a host with no path takes /, or luasocket reads a query as the host.
|
|
34
34
|
const orig = ctx.point?.orig
|
|
35
35
|
if ('string' === typeof orig && orig.endsWith('/') && !spec.suffix && !url.endsWith('/')) {
|
|
36
36
|
url += '/'
|
|
37
37
|
}
|
|
38
|
+
const authority = url.indexOf('://')
|
|
39
|
+
if (0 < authority && !/[/?#]/.test(url.slice(authority + 3))) {
|
|
40
|
+
url += '/'
|
|
41
|
+
}
|
|
38
42
|
|
|
39
43
|
const params = spec.params
|
|
40
44
|
|
|
@@ -196,12 +196,13 @@ describe('FeatureCorpus', () => {
|
|
|
196
196
|
})
|
|
197
197
|
|
|
198
198
|
|
|
199
|
-
//
|
|
200
|
-
//
|
|
201
|
-
test('this SDK has an operation the corpus can drive', () => {
|
|
202
|
-
|
|
203
|
-
'no declared operation
|
|
204
|
-
|
|
199
|
+
// With every operation needing an argument there is nothing to drive:
|
|
200
|
+
// skip and say so, as the clean test does, rather than fail.
|
|
201
|
+
test('this SDK has an operation the corpus can drive', (t) => {
|
|
202
|
+
if (0 === ops.length) {
|
|
203
|
+
return t.skip('no declared operation completes against a plain 200 with no arguments (each needs a path parameter or a body); nothing for the corpus to drive')
|
|
204
|
+
}
|
|
205
|
+
ok(0 < ops.length)
|
|
205
206
|
})
|
|
206
207
|
|
|
207
208
|
|