@voxgig/sdkgen 4.35.3 → 4.36.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.
Files changed (256) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/cmp/ReadmeTop.js +1 -1
  3. package/dist/cmp/ReadmeTop.js.map +1 -1
  4. package/dist/helpers/opExample.d.ts +4 -1
  5. package/dist/helpers/opExample.js +11 -1
  6. package/dist/helpers/opExample.js.map +1 -1
  7. package/dist/helpers/opShape.d.ts +2 -1
  8. package/dist/helpers/opShape.js +53 -26
  9. package/dist/helpers/opShape.js.map +1 -1
  10. package/dist/helpers/pointPath.d.ts +2 -1
  11. package/dist/helpers/pointPath.js +17 -0
  12. package/dist/helpers/pointPath.js.map +1 -1
  13. package/dist/helpers/testPolicy.d.ts +48 -2
  14. package/dist/helpers/testPolicy.js +265 -0
  15. package/dist/helpers/testPolicy.js.map +1 -1
  16. package/dist/sdkgen.d.ts +7 -7
  17. package/dist/sdkgen.js +26 -4
  18. package/dist/sdkgen.js.map +1 -1
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/package.json +1 -1
  21. package/project/.sdk/src/cmp/c/PrepareAuth_c.ts +10 -4
  22. package/project/.sdk/src/cmp/c/ReadmeEntity_c.ts +2 -2
  23. package/project/.sdk/src/cmp/c/ReadmeHowto_c.ts +2 -2
  24. package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +6 -5
  25. package/project/.sdk/src/cmp/c/ReadmeRef_c.ts +3 -3
  26. package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +2 -2
  27. package/project/.sdk/src/cmp/c/ReadmeTopTest_c.ts +2 -2
  28. package/project/.sdk/src/cmp/c/TestDirect_c.ts +2 -6
  29. package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +2 -2
  30. package/project/.sdk/src/cmp/clojure/ReadmeHowto_clojure.ts +2 -2
  31. package/project/.sdk/src/cmp/clojure/ReadmeQuick_clojure.ts +4 -4
  32. package/project/.sdk/src/cmp/clojure/ReadmeRef_clojure.ts +3 -3
  33. package/project/.sdk/src/cmp/clojure/ReadmeTopQuick_clojure.ts +2 -2
  34. package/project/.sdk/src/cmp/clojure/ReadmeTopTest_clojure.ts +2 -2
  35. package/project/.sdk/src/cmp/cpp/ReadmeEntity_cpp.ts +2 -2
  36. package/project/.sdk/src/cmp/cpp/ReadmeHowto_cpp.ts +2 -2
  37. package/project/.sdk/src/cmp/cpp/ReadmeQuick_cpp.ts +4 -4
  38. package/project/.sdk/src/cmp/cpp/ReadmeRef_cpp.ts +3 -3
  39. package/project/.sdk/src/cmp/cpp/ReadmeTopQuick_cpp.ts +2 -2
  40. package/project/.sdk/src/cmp/cpp/ReadmeTopTest_cpp.ts +2 -2
  41. package/project/.sdk/src/cmp/cpp/TestDirect_cpp.ts +2 -6
  42. package/project/.sdk/src/cmp/cpp/TestEntity_cpp.ts +51 -3
  43. package/project/.sdk/src/cmp/csharp/ReadmeEntity_csharp.ts +2 -2
  44. package/project/.sdk/src/cmp/csharp/ReadmeHowto_csharp.ts +2 -2
  45. package/project/.sdk/src/cmp/csharp/ReadmeQuick_csharp.ts +5 -5
  46. package/project/.sdk/src/cmp/csharp/ReadmeRef_csharp.ts +3 -3
  47. package/project/.sdk/src/cmp/csharp/ReadmeTopQuick_csharp.ts +3 -3
  48. package/project/.sdk/src/cmp/csharp/ReadmeTopTest_csharp.ts +2 -2
  49. package/project/.sdk/src/cmp/csharp/TestDirect_csharp.ts +41 -19
  50. package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +105 -27
  51. package/project/.sdk/src/cmp/elixir/ReadmeEntity_elixir.ts +2 -2
  52. package/project/.sdk/src/cmp/elixir/ReadmeHowto_elixir.ts +2 -2
  53. package/project/.sdk/src/cmp/elixir/ReadmeQuick_elixir.ts +4 -4
  54. package/project/.sdk/src/cmp/elixir/ReadmeRef_elixir.ts +3 -3
  55. package/project/.sdk/src/cmp/elixir/ReadmeTopQuick_elixir.ts +2 -2
  56. package/project/.sdk/src/cmp/elixir/ReadmeTopTest_elixir.ts +2 -2
  57. package/project/.sdk/src/cmp/go/EntityOperation_go.ts +2 -2
  58. package/project/.sdk/src/cmp/go/Entity_go.ts +4 -3
  59. package/project/.sdk/src/cmp/go/Main_go.ts +2 -2
  60. package/project/.sdk/src/cmp/go/PrepareAuth_go.ts +24 -15
  61. package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +2 -2
  62. package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +2 -2
  63. package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +4 -4
  64. package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +3 -3
  65. package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +2 -2
  66. package/project/.sdk/src/cmp/go/TestDirect_go.ts +61 -26
  67. package/project/.sdk/src/cmp/go/TestEntity_go.ts +115 -32
  68. package/project/.sdk/src/cmp/java/ReadmeEntity_java.ts +2 -2
  69. package/project/.sdk/src/cmp/java/ReadmeHowto_java.ts +2 -2
  70. package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +5 -5
  71. package/project/.sdk/src/cmp/java/ReadmeRef_java.ts +3 -3
  72. package/project/.sdk/src/cmp/java/ReadmeTopQuick_java.ts +3 -3
  73. package/project/.sdk/src/cmp/java/ReadmeTopTest_java.ts +2 -2
  74. package/project/.sdk/src/cmp/java/TestDirect_java.ts +40 -20
  75. package/project/.sdk/src/cmp/java/TestEntity_java.ts +107 -26
  76. package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +2 -2
  77. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +2 -2
  78. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +4 -4
  79. package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +3 -3
  80. package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +2 -2
  81. package/project/.sdk/src/cmp/js/TestDirect_js.ts +68 -13
  82. package/project/.sdk/src/cmp/js/TestEntity_js.ts +46 -4
  83. package/project/.sdk/src/cmp/kotlin/ReadmeEntity_kotlin.ts +2 -2
  84. package/project/.sdk/src/cmp/kotlin/ReadmeHowto_kotlin.ts +2 -2
  85. package/project/.sdk/src/cmp/kotlin/ReadmeQuick_kotlin.ts +5 -5
  86. package/project/.sdk/src/cmp/kotlin/ReadmeRef_kotlin.ts +3 -3
  87. package/project/.sdk/src/cmp/kotlin/ReadmeTopQuick_kotlin.ts +3 -3
  88. package/project/.sdk/src/cmp/kotlin/ReadmeTopTest_kotlin.ts +2 -2
  89. package/project/.sdk/src/cmp/kotlin/TestDirect_kotlin.ts +41 -21
  90. package/project/.sdk/src/cmp/kotlin/TestEntity_kotlin.ts +99 -22
  91. package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +2 -2
  92. package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +2 -2
  93. package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +4 -4
  94. package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +3 -3
  95. package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +3 -3
  96. package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +2 -2
  97. package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +40 -16
  98. package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +108 -30
  99. package/project/.sdk/src/cmp/ocaml/ReadmeEntity_ocaml.ts +2 -2
  100. package/project/.sdk/src/cmp/ocaml/ReadmeHowto_ocaml.ts +2 -2
  101. package/project/.sdk/src/cmp/ocaml/ReadmeQuick_ocaml.ts +4 -4
  102. package/project/.sdk/src/cmp/ocaml/ReadmeRef_ocaml.ts +3 -3
  103. package/project/.sdk/src/cmp/ocaml/ReadmeTopQuick_ocaml.ts +2 -2
  104. package/project/.sdk/src/cmp/ocaml/ReadmeTopTest_ocaml.ts +2 -2
  105. package/project/.sdk/src/cmp/perl/ReadmeEntity_perl.ts +2 -2
  106. package/project/.sdk/src/cmp/perl/ReadmeHowto_perl.ts +2 -2
  107. package/project/.sdk/src/cmp/perl/ReadmeQuick_perl.ts +4 -4
  108. package/project/.sdk/src/cmp/perl/ReadmeRef_perl.ts +3 -3
  109. package/project/.sdk/src/cmp/perl/ReadmeTopQuick_perl.ts +2 -2
  110. package/project/.sdk/src/cmp/perl/ReadmeTopTest_perl.ts +2 -2
  111. package/project/.sdk/src/cmp/perl/TestDirect_perl.ts +35 -16
  112. package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +98 -22
  113. package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +2 -2
  114. package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +2 -2
  115. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +4 -4
  116. package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +3 -3
  117. package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +2 -2
  118. package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +2 -2
  119. package/project/.sdk/src/cmp/php/TestDirect_php.ts +33 -16
  120. package/project/.sdk/src/cmp/php/TestEntity_php.ts +98 -29
  121. package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +2 -2
  122. package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +2 -2
  123. package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +4 -4
  124. package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +3 -3
  125. package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +2 -2
  126. package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +2 -2
  127. package/project/.sdk/src/cmp/py/TestDirect_py.ts +39 -16
  128. package/project/.sdk/src/cmp/py/TestEntity_py.ts +90 -27
  129. package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +2 -2
  130. package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +2 -2
  131. package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +4 -4
  132. package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +3 -3
  133. package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +2 -2
  134. package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +2 -2
  135. package/project/.sdk/src/cmp/rb/TestClean_rb.ts +1 -1
  136. package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +33 -16
  137. package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +90 -25
  138. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +3 -3
  139. package/project/.sdk/src/cmp/rust/ReadmeEntity_rust.ts +2 -2
  140. package/project/.sdk/src/cmp/rust/ReadmeHowto_rust.ts +2 -2
  141. package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +4 -4
  142. package/project/.sdk/src/cmp/rust/ReadmeRef_rust.ts +3 -3
  143. package/project/.sdk/src/cmp/rust/ReadmeTopQuick_rust.ts +2 -2
  144. package/project/.sdk/src/cmp/rust/ReadmeTopTest_rust.ts +2 -2
  145. package/project/.sdk/src/cmp/rust/TestDirect_rust.ts +40 -12
  146. package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +108 -25
  147. package/project/.sdk/src/cmp/scala/ReadmeEntity_scala.ts +2 -2
  148. package/project/.sdk/src/cmp/scala/ReadmeHowto_scala.ts +2 -2
  149. package/project/.sdk/src/cmp/scala/ReadmeQuick_scala.ts +5 -5
  150. package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +3 -3
  151. package/project/.sdk/src/cmp/scala/ReadmeTopQuick_scala.ts +3 -3
  152. package/project/.sdk/src/cmp/scala/ReadmeTopTest_scala.ts +2 -2
  153. package/project/.sdk/src/cmp/scala/TestDirect_scala.ts +2 -6
  154. package/project/.sdk/src/cmp/scala/TestEntity_scala.ts +36 -7
  155. package/project/.sdk/src/cmp/swift/ReadmeEntity_swift.ts +2 -2
  156. package/project/.sdk/src/cmp/swift/ReadmeHowto_swift.ts +2 -2
  157. package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +5 -5
  158. package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -3
  159. package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -2
  160. package/project/.sdk/src/cmp/swift/ReadmeTopTest_swift.ts +2 -2
  161. package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +2 -2
  162. package/project/.sdk/src/cmp/ts/ReadmeExamplesTest_ts.ts +49 -19
  163. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +2 -2
  164. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +4 -4
  165. package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +3 -3
  166. package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +3 -3
  167. package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +54 -23
  168. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +49 -4
  169. package/project/.sdk/src/cmp/zig/ReadmeEntity_zig.ts +2 -2
  170. package/project/.sdk/src/cmp/zig/ReadmeHowto_zig.ts +2 -2
  171. package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +4 -4
  172. package/project/.sdk/src/cmp/zig/ReadmeRef_zig.ts +3 -3
  173. package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
  174. package/project/.sdk/src/cmp/zig/ReadmeTopTest_zig.ts +2 -2
  175. package/project/.sdk/tm/c/tests/primary_utility_test.c +37 -0
  176. package/project/.sdk/tm/c/utility/fetcher.c +31 -1
  177. package/project/.sdk/tm/c/utility/make_url.c +6 -2
  178. package/project/.sdk/tm/clojure/src/sdk/core.clj +21 -3
  179. package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +34 -0
  180. package/project/.sdk/tm/cpp/test/primary_utility_test.cpp +37 -0
  181. package/project/.sdk/tm/cpp/utility/pipeline.hpp +28 -2
  182. package/project/.sdk/tm/csharp/test/PrimaryUtilityTest.cs +40 -0
  183. package/project/.sdk/tm/csharp/utility/Fetcher.cs +27 -0
  184. package/project/.sdk/tm/csharp/utility/MakeUrl.cs +7 -2
  185. package/project/.sdk/tm/elixir/lib/projectname/utility.ex +30 -3
  186. package/project/.sdk/tm/elixir/test/pipeline_test.exs +23 -0
  187. package/project/.sdk/tm/go/test/feature_corpus_test.go +3 -4
  188. package/project/.sdk/tm/go/test/primary_utility_test.go +28 -0
  189. package/project/.sdk/tm/go/utility/fetcher.go +26 -0
  190. package/project/.sdk/tm/go/utility/make_url.go +5 -2
  191. package/project/.sdk/tm/java/test/FeatureCorpusTest.java +4 -5
  192. package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +49 -0
  193. package/project/.sdk/tm/java/utility/Fetcher.java +24 -0
  194. package/project/.sdk/tm/java/utility/MakeUrl.java +6 -2
  195. package/project/.sdk/tm/js/src/utility/FetcherUtility.js +24 -0
  196. package/project/.sdk/tm/js/src/utility/MakeUrlUtility.js +6 -2
  197. package/project/.sdk/tm/js/test/feature/Corpus.test.js +7 -6
  198. package/project/.sdk/tm/js/test/live-entity.js +18 -6
  199. package/project/.sdk/tm/js/test/live-runner.js +15 -3
  200. package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +25 -0
  201. package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +48 -0
  202. package/project/.sdk/tm/kotlin/utility/Fetcher.kt +20 -0
  203. package/project/.sdk/tm/kotlin/utility/MakeSpecUrl.kt +6 -2
  204. package/project/.sdk/tm/lua/test/pipeline_test.lua +27 -0
  205. package/project/.sdk/tm/lua/test/primary_utility_test.lua +36 -0
  206. package/project/.sdk/tm/lua/utility/fetcher.lua +31 -0
  207. package/project/.sdk/tm/lua/utility/make_url.lua +6 -2
  208. package/project/.sdk/tm/ocaml/Makefile +5 -1
  209. package/project/.sdk/tm/ocaml/sdk_runtime.ml +36 -4
  210. package/project/.sdk/tm/ocaml/test/t_pipeline.ml +22 -0
  211. package/project/.sdk/tm/perl/t/primary_utility.t +22 -0
  212. package/project/.sdk/tm/perl/utility/fetcher.pm +18 -0
  213. package/project/.sdk/tm/perl/utility/make_url.pm +4 -2
  214. package/project/.sdk/tm/php/test/FeatureCorpusTest.php +6 -5
  215. package/project/.sdk/tm/php/test/PipelineTest.php +31 -7
  216. package/project/.sdk/tm/php/utility/Fetcher.php +34 -27
  217. package/project/.sdk/tm/php/utility/MakeOptions.php +2 -1
  218. package/project/.sdk/tm/php/utility/MakeUrl.php +6 -2
  219. package/project/.sdk/tm/py/pkg/utility/fetcher.py +23 -0
  220. package/project/.sdk/tm/py/pkg/utility/make_url.py +5 -2
  221. package/project/.sdk/tm/py/test/test_feature_corpus.py +5 -5
  222. package/project/.sdk/tm/py/test/test_primary_utility.py +21 -0
  223. package/project/.sdk/tm/rb/core/context.rb +1 -1
  224. package/project/.sdk/tm/rb/core/error.rb +20 -1
  225. package/project/.sdk/tm/rb/test/feature_corpus_test.rb +4 -5
  226. package/project/.sdk/tm/rb/test/feature_test.rb +2 -2
  227. package/project/.sdk/tm/rb/test/omni.rb +1 -1
  228. package/project/.sdk/tm/rb/test/pipeline_test.rb +19 -2
  229. package/project/.sdk/tm/rb/test/primary_utility_test.rb +28 -1
  230. package/project/.sdk/tm/rb/utility/fetcher.rb +20 -1
  231. package/project/.sdk/tm/rb/utility/make_error.rb +1 -1
  232. package/project/.sdk/tm/rb/utility/make_url.rb +4 -2
  233. package/project/.sdk/tm/rust/tests/primary_utility_test.rs +34 -0
  234. package/project/.sdk/tm/rust/utility/fetcher.rs +27 -0
  235. package/project/.sdk/tm/rust/utility/make_url.rs +7 -2
  236. package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +51 -1
  237. package/project/.sdk/tm/scala/utility/Fetcher.scala +16 -0
  238. package/project/.sdk/tm/scala/utility/Make.scala +6 -2
  239. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +24 -0
  240. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Make.swift +6 -2
  241. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PrimaryUtilityTest.swift +34 -0
  242. package/project/.sdk/tm/ts/src/utility/FetcherUtility.ts +24 -0
  243. package/project/.sdk/tm/ts/src/utility/MakeUrlUtility.ts +6 -2
  244. package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +7 -6
  245. package/project/.sdk/tm/ts/test/live-entity.ts +20 -5
  246. package/project/.sdk/tm/ts/test/live-runner.ts +17 -3
  247. package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +25 -0
  248. package/project/.sdk/tm/zig/core/utility.zig +30 -3
  249. package/project/.sdk/tm/zig/test/primary_utility_test.zig +28 -0
  250. package/project/sdkgen-package.json +1 -1
  251. package/src/cmp/ReadmeTop.ts +3 -3
  252. package/src/helpers/opExample.ts +16 -1
  253. package/src/helpers/opShape.ts +64 -30
  254. package/src/helpers/pointPath.ts +19 -0
  255. package/src/helpers/testPolicy.ts +316 -2
  256. package/src/sdkgen.ts +37 -5
@@ -395,13 +395,12 @@ public class FeatureCorpusTest {
395
395
  assertNotNull(corpus().get("feature"));
396
396
  }
397
397
 
398
- // At least one operation, or every case below would skip and this suite
399
- // would report green having run nothing.
398
+ // With every operation needing an argument there is nothing to drive:
399
+ // skip and say so, as the clean test does, rather than fail.
400
400
  @Test
401
401
  public void sdkHasAnOperationTheCorpusCanDrive() {
402
- assertTrue(0 < usableOps(2).size(),
403
- "no declared operation completed against a plain 200 - the corpus "
404
- + "cannot exercise a feature without one");
402
+ org.junit.jupiter.api.Assumptions.assumeTrue(0 < usableOps(2).size(),
403
+ "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");
405
404
  }
406
405
 
407
406
  @Test
@@ -414,6 +414,55 @@ public class PrimaryUtilityTest {
414
414
  }
415
415
  }
416
416
 
417
+ // Nothing listens on port 9: a request the guard let through fails there.
418
+ // A JVM cannot set its own environment, so the probe runs in a child JVM.
419
+ @Test
420
+ public void fetcherGetOnlyGuard() throws Exception {
421
+ String out;
422
+ if ("TRUE".equals(System.getenv("VOXGIG_GETONLY_GUARD"))) {
423
+ out = getOnlyProbe();
424
+ }
425
+ else {
426
+ ProcessBuilder pb = new ProcessBuilder(
427
+ ProcessHandle.current().info().command().orElse("java"),
428
+ "-cp", System.getProperty("java.class.path"), PrimaryUtilityTest.class.getName());
429
+ pb.environment().put("VOXGIG_GETONLY_GUARD", "TRUE");
430
+ pb.redirectErrorStream(true);
431
+ Process proc = pb.start();
432
+ out = new String(proc.getInputStream().readAllBytes(), java.nio.charset.StandardCharsets.UTF_8);
433
+ assertEquals(0, proc.waitFor(), out);
434
+ }
435
+ assertTrue(out.startsWith("fetch_getonly_block [GET-ONLY GUARD] blocked POST /planet/p1\n"), out);
436
+ assertTrue(out.trim().endsWith("\nsent"), out);
437
+ assertFalse(out.contains("GUARDKEY01"), out);
438
+ }
439
+
440
+ public static void main(String[] args) {
441
+ System.out.print(getOnlyProbe());
442
+ }
443
+
444
+ static String getOnlyProbe() {
445
+ ProjectNameSDK liveClient = new ProjectNameSDK(fhMap("base", "http://127.0.0.1:9"));
446
+ Utility liveUtility = liveClient.getUtility();
447
+ Context ctx = liveUtility.makeContext.apply(fhMap(
448
+ "opname", "create", "client", liveClient, "utility", liveUtility), null);
449
+ String url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01";
450
+ StringBuilder out = new StringBuilder();
451
+ for (String method : new String[] {"POST", "GET"}) {
452
+ try {
453
+ liveUtility.fetcher.fetch(ctx, url, fhMap("method", method, "headers", new LinkedHashMap<>()));
454
+ out.append("answered\n");
455
+ }
456
+ catch (SdkError e) {
457
+ out.append(e.code).append(' ').append(e.msg).append('\n');
458
+ }
459
+ catch (RuntimeException e) {
460
+ out.append("sent\n");
461
+ }
462
+ }
463
+ return out.toString();
464
+ }
465
+
417
466
  @Test
418
467
  public void makeContextBasic() {
419
468
  runsection("makeContext", (args) -> {
@@ -15,6 +15,7 @@ import java.util.function.BiFunction;
15
15
  import java.util.function.Supplier;
16
16
 
17
17
  import JAVAPACKAGE.core.Context;
18
+ import JAVAPACKAGE.core.SdkError;
18
19
  import JAVAPACKAGE.utility.struct.Struct;
19
20
 
20
21
  @SuppressWarnings({"unchecked"})
@@ -56,12 +57,35 @@ final class Fetcher {
56
57
  });
57
58
  }
58
59
 
60
+ static final String GETONLY_ENV = "VOXGIG_GETONLY_GUARD";
61
+
62
+ // A GET-only live run refuses any other method before it is sent. The error
63
+ // names the path alone: the query can carry a credential.
64
+ static SdkError getOnlyRefusal(String fullurl, String method) {
65
+ method = method.toUpperCase(java.util.Locale.ROOT);
66
+ if (!"TRUE".equals(System.getenv(GETONLY_ENV)) || "GET".equals(method)) {
67
+ return null;
68
+ }
69
+ String rest = fullurl;
70
+ int scheme = rest.indexOf("://");
71
+ if (scheme >= 0) {
72
+ rest = rest.substring(scheme + 3).replaceFirst("^[^/?#]*", "");
73
+ }
74
+ String path = rest.split("[?#]", 2)[0];
75
+ return new SdkError("fetch_getonly_block",
76
+ "[GET-ONLY GUARD] blocked " + method + " " + ("".equals(path) ? "/" : path), null);
77
+ }
78
+
59
79
  static Map<String, Object> defaultHttpFetch(String fullurl, Map<String, Object> fetchdef) {
60
80
  String method = fetchdef.get("method") instanceof String
61
81
  ? (String) fetchdef.get("method") : "";
62
82
  if ("".equals(method)) {
63
83
  method = "GET";
64
84
  }
85
+ SdkError refused = getOnlyRefusal(fullurl, method);
86
+ if (refused != null) {
87
+ throw refused;
88
+ }
65
89
 
66
90
  HttpRequest.BodyPublisher bodyPublisher = HttpRequest.BodyPublishers.noBody();
67
91
  Object body = fetchdef.get("body");
@@ -37,13 +37,17 @@ final class MakeUrl {
37
37
  joinParts.add(spec.suffix);
38
38
  String url = Struct.join(joinParts, "/", true);
39
39
 
40
- // A route the definition ends with a slash keeps it: a server such as a
41
- // Django REST one redirects or refuses the route without it.
40
+ // A route the definition ends with a slash keeps it, for a Django REST server,
41
+ // and a host with no path takes /, or luasocket reads a query as the host.
42
42
  Object orig = ctx.point == null ? null : Struct.getprop(ctx.point, "orig", null);
43
43
  if (orig instanceof String && ((String) orig).endsWith("/") &&
44
44
  (spec.suffix == null || spec.suffix.isEmpty()) && !url.endsWith("/")) {
45
45
  url = url + "/";
46
46
  }
47
+ int authority = url.indexOf("://");
48
+ if (0 < authority && url.substring(authority + 3).chars().noneMatch(c -> 0 <= "/?#".indexOf(c))) {
49
+ url = url + "/";
50
+ }
47
51
 
48
52
  Map<String, Object> resmatch = new LinkedHashMap<>();
49
53
 
@@ -18,6 +18,23 @@ function defaultUserAgent(fetchdef) {
18
18
  }
19
19
 
20
20
 
21
+ const GETONLY_ENV = 'VOXGIG_GETONLY_GUARD'
22
+
23
+
24
+ // A GET-only live run refuses any other method before it is sent. The error
25
+ // names the path alone: the query can carry a credential.
26
+ function getOnlyRefusal(ctx, fullurl, fetchdef) {
27
+ const method = String(fetchdef.method || 'GET').toUpperCase()
28
+ if ('TRUE' !== globalThis.process?.env?.[GETONLY_ENV] || 'GET' === method) {
29
+ return
30
+ }
31
+ const scheme = fullurl.indexOf('://')
32
+ const rest = scheme < 0 ? fullurl : fullurl.slice(scheme + 3).replace(/^[^/?#]*/, '')
33
+ const path = rest.split(/[?#]/)[0] || '/'
34
+ return ctx.error('fetch_getonly_block', '[GET-ONLY GUARD] blocked ' + method + ' ' + path)
35
+ }
36
+
37
+
21
38
  // Make HTTP call using library. Replace this utility for mocking etc.
22
39
  async function fetcher(ctx, fullurl, fetchdef) {
23
40
 
@@ -37,6 +54,13 @@ async function fetcher(ctx, fullurl, fetchdef) {
37
54
 
38
55
  const fetch = options.system.fetch
39
56
 
57
+ // The platform's fetch is the SDK's own transport; a supplied one is the
58
+ // caller's, and a mock sends nothing.
59
+ const refused = fetch === globalThis.fetch ? getOnlyRefusal(ctx, fullurl, fetchdef) : undefined
60
+ if (refused) {
61
+ return refused
62
+ }
63
+
40
64
  defaultUserAgent(fetchdef)
41
65
 
42
66
  const response = await fetch(fullurl, fetchdef)
@@ -20,12 +20,16 @@ function makeUrl(ctx) {
20
20
 
21
21
  let url = join([spec.base, spec.prefix, spec.path, spec.suffix], '/', true)
22
22
 
23
- // A route the definition ends with a slash keeps it: a server such as a
24
- // Django REST one redirects or refuses the route without it.
23
+ // A route the definition ends with a slash keeps it, for a Django REST server,
24
+ // and a host with no path takes /, or luasocket reads a query as the host.
25
25
  const orig = ctx.point && ctx.point.orig
26
26
  if ('string' === typeof orig && orig.endsWith('/') && !spec.suffix && !url.endsWith('/')) {
27
27
  url += '/'
28
28
  }
29
+ const authority = url.indexOf('://')
30
+ if (0 < authority && !/[/?#]/.test(url.slice(authority + 3))) {
31
+ url += '/'
32
+ }
29
33
  let resmatch = {}
30
34
 
31
35
  // Sent with the request, never recorded as the entity's match.
@@ -244,12 +244,13 @@ describe('FeatureCorpus', () => {
244
244
  })
245
245
 
246
246
 
247
- // At least one operation, or every case below would skip and the whole
248
- // suite would report green having run nothing.
249
- test('this SDK has an operation the corpus can drive', () => {
250
- ok(0 < ops.length,
251
- 'no declared operation completed against a plain 200 — the corpus ' +
252
- 'cannot exercise a feature without one')
247
+ // With every operation needing an argument there is nothing to drive:
248
+ // skip and say so, as the clean test does, rather than fail.
249
+ test('this SDK has an operation the corpus can drive', (t) => {
250
+ if (0 === ops.length) {
251
+ 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')
252
+ }
253
+ ok(0 < ops.length)
253
254
  })
254
255
 
255
256
 
@@ -8,9 +8,12 @@ const strict_1 = __importDefault(require("node:assert/strict"));
8
8
  const live_contract_1 = require("./live-contract");
9
9
  const live_runner_1 = require("./live-runner");
10
10
  const utility_1 = require("./utility");
11
+ const routeOf = (point) => String(point.m).toUpperCase() + ' ' + point.o;
12
+ const scalarOf = (value) => ['string', 'number', 'boolean'].includes(typeof value) ? value : undefined;
11
13
  // The offline flow keeps its deterministic fixture assertions. Live flows
12
14
  // resolve real prerequisites per operation and collect failures until done.
13
- async function runLiveEntity(setup, entity, flow, accessor, facts = {}, settle = {}) {
15
+ // `excluded` names, by step id, the steps this run leaves out, and why.
16
+ async function runLiveEntity(setup, entity, flow, accessor, facts = {}, settle = {}, excluded = {}) {
14
17
  const { client, transport } = setup;
15
18
  // A step switched off only because the offline call reaches no route of
16
19
  // its operation still runs here, where each route's inputs are resolved.
@@ -28,11 +31,12 @@ async function runLiveEntity(setup, entity, flow, accessor, facts = {}, settle =
28
31
  const report = await (0, live_runner_1.runLiveSteps)(steps.map((step, index) => {
29
32
  const ref = step.i?.ref || entity.name + '_ref01';
30
33
  const op = step.o;
31
- const excluded = (0, utility_1.isControlSkipped)('entityOp', entity.name + '.' + op, 'live');
34
+ const id = entity.name + '.' + op + '.' + index;
35
+ const control = (0, utility_1.isControlSkipped)('entityOp', entity.name + '.' + op, 'live');
32
36
  return {
33
- id: entity.name + '.' + op + '.' + index,
37
+ id,
34
38
  cleanup: op === 'remove' || (step.v || []).some((v) => v.apply === 'ItemNotExists'),
35
- excluded: excluded.skip ? excluded.reason || 'Excluded by test control' : undefined,
39
+ excluded: control.skip ? control.reason || 'Excluded by test control' : excluded[id],
36
40
  run: async (context) => {
37
41
  transport.enter(context);
38
42
  const points = (entity.op?.[op]?.points || []).filter((point) => false !== point.a);
@@ -65,6 +69,14 @@ async function runLiveEntity(setup, entity, flow, accessor, facts = {}, settle =
65
69
  if (undefined !== id)
66
70
  input.id = id;
67
71
  }
72
+ // A load of a known record takes the route the offline flow takes,
73
+ // and the parameters that flow reads from the record.
74
+ for (const [name, field] of Object.entries(step.record || {})) {
75
+ const value = scalarOf(loaded?.[field]);
76
+ if (undefined !== value)
77
+ input[name] = value;
78
+ }
79
+ const ordered = null == step.route ? points : [...points].sort((a, b) => Number(step.route !== routeOf(a)) - Number(step.route !== routeOf(b)));
68
80
  // A nested route needing a parent id must not hide an available
69
81
  // parameter-free route for the same operation. Use the first viable
70
82
  // candidate. An action route is taken only when the step names its
@@ -73,7 +85,7 @@ async function runLiveEntity(setup, entity, flow, accessor, facts = {}, settle =
73
85
  let selected;
74
86
  const unusable = [];
75
87
  const actionOnly = points.every((point) => null != point.q?.$action);
76
- for (const point of points) {
88
+ for (const point of ordered) {
77
89
  const action = point.q?.$action;
78
90
  if (null == input.$action ? null != action && !actionOnly : action !== input.$action)
79
91
  continue;
@@ -85,7 +97,7 @@ async function runLiveEntity(setup, entity, flow, accessor, facts = {}, settle =
85
97
  if (undefined !== candidate[arg.n] && null !== candidate[arg.n])
86
98
  continue;
87
99
  const key = arg.n === 'id' ? entity.name + '01' : arg.n.replace(/_id$/, '') + '01';
88
- const value = setup.idmap[key] ?? setup.idmap[arg.n] ?? loaded?.[arg.n] ?? arg.ex;
100
+ const value = setup.idmap[key] ?? setup.idmap[arg.n] ?? scalarOf(loaded?.[arg.n]) ?? arg.ex;
89
101
  if (undefined !== value && null !== value)
90
102
  candidate[arg.n] = value;
91
103
  else if (arg.r !== false)
@@ -11,6 +11,8 @@ exports.createLiveTransport = createLiveTransport;
11
11
  class LiveBlocked extends Error {
12
12
  }
13
13
  exports.LiveBlocked = LiveBlocked;
14
+ // The SDK fetcher's code for a write a GET-only run refused unsent.
15
+ const GETONLY_CODE = 'fetch_getonly_block';
14
16
  // The account answered, but holds no record the step could act on.
15
17
  class LiveEmpty extends Error {
16
18
  }
@@ -73,10 +75,12 @@ async function runLiveSteps(steps, options = {}) {
73
75
  record({ id: step.id, state: 'passed', attempted, requests });
74
76
  }
75
77
  catch (error) {
78
+ const refused = GETONLY_CODE === error?.code;
76
79
  const state = error instanceof LiveEmpty ? 'empty'
77
- : error instanceof LiveBlocked ? 'blocked' : 'failed';
80
+ : error instanceof LiveBlocked || refused ? 'blocked' : 'failed';
78
81
  record({ id: step.id, state, attempted, requests,
79
- reason: 'failed' === state ? failureReason(error) : error.message });
82
+ reason: refused ? 'Refused by the GET-only guard' :
83
+ 'failed' === state ? failureReason(error) : error.message });
80
84
  }
81
85
  if (attempted && (options.delayMs || 0) > 0) {
82
86
  await new Promise(resolve => setTimeout(resolve, options.delayMs));
@@ -122,8 +126,12 @@ function assertLiveReport(report) {
122
126
  throw new Error('Live coverage incomplete: ' + JSON.stringify(report));
123
127
  }
124
128
  }
125
- // An account with no record for a step to read skips in either mode.
129
+ // An account with no record for a step to read skips in either mode, as
130
+ // does a run that leaves out every step.
126
131
  function settleLiveReport(report, settle = {}) {
132
+ if (0 < report.planned && report.excluded === report.planned && null != settle.t) {
133
+ return settle.t.skip('Live coverage incomplete: ' + liveSummary(report));
134
+ }
127
135
  if (liveIncomplete(report)) {
128
136
  if (false !== settle.strict || null == settle.t)
129
137
  return assertLiveReport(report);
@@ -148,6 +156,10 @@ function createLiveTransport(timeoutMs = 30000) {
148
156
  enter(next) { context = next; },
149
157
  fetch: async (input, init) => {
150
158
  const url = new URL(String(input));
159
+ const method = String(init?.method || 'GET').toUpperCase();
160
+ if ('TRUE' === process.env.VOXGIG_GETONLY_GUARD && 'GET' !== method) {
161
+ throw Object.assign(new Error('[GET-ONLY GUARD] blocked ' + method + ' ' + url.pathname), { code: GETONLY_CODE });
162
+ }
151
163
  // A credential can travel as the agent (auth.name), so only whether
152
164
  // the request carried one is recorded, never its value.
153
165
  const request = {
@@ -502,6 +502,31 @@ describe('PrimaryUtility', async () => {
502
502
  })
503
503
 
504
504
 
505
+ // Nothing listens on port 9: a request the guard let through fails there.
506
+ test('fetcher-getonly-guard', async () => {
507
+ const liveClient = new SDK({ base: 'http://127.0.0.1:9' })
508
+ const liveUtility = liveClient.utility()
509
+ const ctx = liveUtility.makeContext({ opname: 'create' }, liveClient._rootctx)
510
+ ctx.client = liveClient
511
+ const url = 'http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01'
512
+
513
+ const prior = process.env.VOXGIG_GETONLY_GUARD
514
+ process.env.VOXGIG_GETONLY_GUARD = 'TRUE'
515
+ try {
516
+ const refused = await liveUtility.fetcher(ctx, url, { method: 'POST', headers: {} })
517
+ equal(refused?.code, 'fetch_getonly_block')
518
+ ok(refused.message.includes('[GET-ONLY GUARD] blocked POST /planet/p1'), refused.message)
519
+ ok(!refused.message.includes('GUARDKEY01'))
520
+
521
+ await assert.rejects(liveUtility.fetcher(ctx, url, { method: 'GET', headers: {} }))
522
+ }
523
+ finally {
524
+ if (undefined === prior) delete process.env.VOXGIG_GETONLY_GUARD
525
+ else process.env.VOXGIG_GETONLY_GUARD = prior
526
+ }
527
+ })
528
+
529
+
505
530
  test('makeError-no-throw', () => {
506
531
  const ctx = makeFullCtx()
507
532
  ctx.ctrl.throw = false
@@ -74,6 +74,31 @@ class PrimaryUtilityTest {
74
74
  run()
75
75
  return UTILITY!!
76
76
  }
77
+
78
+ @JvmStatic
79
+ fun main(args: Array<String>) {
80
+ print(getOnlyProbe())
81
+ }
82
+
83
+ fun getOnlyProbe(): String {
84
+ val liveClient = ProjectNameSDK(fhMap("base", "http://127.0.0.1:9"))
85
+ val liveUtility = liveClient.getUtility()
86
+ val ctx = liveUtility.makeContext(
87
+ fhMap("opname", "create", "client", liveClient, "utility", liveUtility), null)
88
+ val url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01"
89
+ val out = StringBuilder()
90
+ for (method in listOf("POST", "GET")) {
91
+ try {
92
+ liveUtility.fetcher(ctx, url, fhMap("method", method, "headers", linkedMapOf<String, Any?>()))
93
+ out.append("answered\n")
94
+ } catch (e: SdkError) {
95
+ out.append(e.code).append(' ').append(e.msg).append('\n')
96
+ } catch (e: RuntimeException) {
97
+ out.append("sent\n")
98
+ }
99
+ }
100
+ return out.toString()
101
+ }
77
102
  }
78
103
 
79
104
  // Run one corpus section, failing loudly when it would run ZERO cases.
@@ -382,6 +407,29 @@ class PrimaryUtilityTest {
382
407
  }
383
408
  }
384
409
 
410
+ // Nothing listens on port 9: a request the guard let through fails there.
411
+ // A JVM cannot set its own environment, so the probe runs in a child JVM.
412
+ @Test
413
+ fun fetcherGetOnlyGuard() {
414
+ val out = if ("TRUE" == System.getenv("VOXGIG_GETONLY_GUARD")) {
415
+ getOnlyProbe()
416
+ } else {
417
+ val pb = ProcessBuilder(
418
+ ProcessHandle.current().info().command().orElse("java"),
419
+ "-cp", System.getProperty("java.class.path"), PrimaryUtilityTest::class.java.name,
420
+ )
421
+ pb.environment()["VOXGIG_GETONLY_GUARD"] = "TRUE"
422
+ pb.redirectErrorStream(true)
423
+ val proc = pb.start()
424
+ val text = proc.inputStream.readAllBytes().toString(Charsets.UTF_8)
425
+ assertEquals(0, proc.waitFor(), text)
426
+ text
427
+ }
428
+ assertTrue(out.startsWith("fetch_getonly_block [GET-ONLY GUARD] blocked POST /planet/p1\n"), out)
429
+ assertTrue(out.trim().endsWith("\nsent"), out)
430
+ assertFalse(out.contains("GUARDKEY01"), out)
431
+ }
432
+
385
433
  @Test
386
434
  fun makeContextBasic() {
387
435
  runsection("makeContext") { args ->
@@ -12,6 +12,7 @@ import java.util.function.BiFunction
12
12
  import java.util.function.Supplier
13
13
 
14
14
  import KOTLINPACKAGE.core.Context
15
+ import KOTLINPACKAGE.core.SdkError
15
16
  import KOTLINPACKAGE.utility.struct.Struct
16
17
 
17
18
  // Clients keyed by redirect policy and proxy. Each HttpClient owns a
@@ -45,12 +46,31 @@ private fun clientFor(fetchdef: MutableMap<String, Any?>): HttpClient {
45
46
  }
46
47
  }
47
48
 
49
+ internal const val GETONLY_ENV = "VOXGIG_GETONLY_GUARD"
50
+
51
+ // A GET-only live run refuses any other method before it is sent. The error
52
+ // names the path alone: the query can carry a credential.
53
+ internal fun getOnlyRefusal(fullurl: String, method: String): SdkError? {
54
+ val upper = method.uppercase()
55
+ if ("TRUE" != System.getenv(GETONLY_ENV) || "GET" == upper) {
56
+ return null
57
+ }
58
+ var rest = fullurl
59
+ val scheme = rest.indexOf("://")
60
+ if (scheme >= 0) {
61
+ rest = rest.substring(scheme + 3).replaceFirst(Regex("^[^/?#]*"), "")
62
+ }
63
+ val path = rest.split(Regex("[?#]"), 2)[0].ifEmpty { "/" }
64
+ return SdkError("fetch_getonly_block", "[GET-ONLY GUARD] blocked $upper $path", null)
65
+ }
66
+
48
67
  @Suppress("UNCHECKED_CAST")
49
68
  fun defaultHttpFetch(fullurl: String, fetchdef: MutableMap<String, Any?>): MutableMap<String, Any?> {
50
69
  var method = if (fetchdef["method"] is String) fetchdef["method"] as String else ""
51
70
  if ("" == method) {
52
71
  method = "GET"
53
72
  }
73
+ getOnlyRefusal(fullurl, method)?.let { throw it }
54
74
 
55
75
  var bodyPublisher: HttpRequest.BodyPublisher = HttpRequest.BodyPublishers.noBody()
56
76
  val body = fetchdef["body"]
@@ -114,13 +114,17 @@ fun makeUrl(ctx: Context): String {
114
114
  joinParts.add(spec.suffix)
115
115
  var url = Struct.join(joinParts, "/", true)
116
116
 
117
- // A route the definition ends with a slash keeps it: a server such as a
118
- // Django REST one redirects or refuses the route without it.
117
+ // A route the definition ends with a slash keeps it, for a Django REST server,
118
+ // and a host with no path takes /, or luasocket reads a query as the host.
119
119
  val point = ctx.point
120
120
  val orig = if (point == null) null else Struct.getprop(point, "orig", null)
121
121
  if (orig is String && orig.endsWith("/") && spec.suffix.isEmpty() && !url.endsWith("/")) {
122
122
  url += "/"
123
123
  }
124
+ val authority = url.indexOf("://")
125
+ if (0 < authority && url.substring(authority + 3).none { it in "/?#" }) {
126
+ url += "/"
127
+ }
124
128
 
125
129
  val resmatch = linkedMapOf<String, Any?>()
126
130
 
@@ -407,6 +407,33 @@ describe("pipeline", function()
407
407
  end)
408
408
 
409
409
 
410
+ describe("makeUrl", function()
411
+
412
+ -- luasocket takes everything up to the first / as the host. The mock
413
+ -- fetcher never parses the URL, so the built string is what is checked.
414
+ local function url_for(base, path, query)
415
+ local ctx = base_ctx({})
416
+ ctx.spec = Spec.new({ base = base, path = path, query = query })
417
+ ctx.result = Result.new({})
418
+ local url, err = ctx.utility.make_url(ctx)
419
+ assert.is_nil(err)
420
+ return url
421
+ end
422
+
423
+ it("gives a route at the server root the path /", function()
424
+ assert.are.equal("https://api.test/?name=michael", url_for("https://api.test", "", { name = "michael" }))
425
+ assert.are.equal("https://api.test/", url_for("https://api.test", ""))
426
+ assert.are.equal("https://api.test/", url_for("https://api.test/", "/"))
427
+ end)
428
+
429
+ it("leaves a URL with a path, or with no authority, as it is", function()
430
+ assert.are.equal("https://api.test/v1?name=michael", url_for("https://api.test/v1", "", { name = "michael" }))
431
+ assert.are.equal("https://api.test/pets", url_for("https://api.test", "pets"))
432
+ assert.are.equal("base-/p", url_for("base-", "p"))
433
+ end)
434
+ end)
435
+
436
+
410
437
  describe("makeError + done", function()
411
438
 
412
439
  it("done returns resdata on success", function()
@@ -504,6 +504,42 @@ describe("PrimaryUtility", function()
504
504
  end)
505
505
 
506
506
 
507
+ -- Nothing listens on port 9: a request the guard let through fails there.
508
+ -- Lua cannot set its own environment, so the test answers for os.getenv.
509
+ it("fetcher-getonly-guard", function()
510
+ local live_client = sdk.new({ base = "http://127.0.0.1:9" })
511
+ local live_utility = live_client:get_utility()
512
+ local ctx = live_utility.make_context({
513
+ opname = "create",
514
+ client = live_client,
515
+ utility = live_utility,
516
+ }, nil)
517
+ local url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01"
518
+
519
+ local getenv = os.getenv
520
+ os.getenv = function(name)
521
+ if name == "VOXGIG_GETONLY_GUARD" then
522
+ return "TRUE"
523
+ end
524
+ return getenv(name)
525
+ end
526
+ local passed, failure = pcall(function()
527
+ local _, err = live_utility.fetcher(ctx, url, { method = "POST", headers = {} })
528
+ assert.are.equal("fetch_getonly_block", type(err) == "table" and err.code or tostring(err))
529
+ assert.is_truthy(string.find(err.msg, "[GET-ONLY GUARD] blocked POST /planet/p1", 1, true))
530
+ assert.is_falsy(string.find(err.msg, "GUARDKEY01", 1, true))
531
+
532
+ local _, geterr = live_utility.fetcher(ctx, url, { method = "GET", headers = {} })
533
+ assert.is_not_nil(geterr)
534
+ assert.are_not.equal("fetch_getonly_block", type(geterr) == "table" and geterr.code or geterr)
535
+ end)
536
+ os.getenv = getenv
537
+ if not passed then
538
+ error(failure, 0)
539
+ end
540
+ end)
541
+
542
+
507
543
  it("makeContext-basic", function()
508
544
  runsection("makeContext", function(vin)
509
545
  if type(vin) ~= "table" then
@@ -2,8 +2,39 @@
2
2
 
3
3
  local vs = require("utility.struct.struct")
4
4
  local json = require("dkjson")
5
+ local ProjectNameError = require("core.error")
6
+
7
+ local GETONLY_ENV = "VOXGIG_GETONLY_GUARD"
8
+
9
+ -- A GET-only live run refuses any other method before it is sent. The error
10
+ -- names the path alone: the query can carry a credential.
11
+ local function getonly_refusal(fullurl, method)
12
+ method = string.upper(tostring(method or ""))
13
+ if method == "" then
14
+ method = "GET"
15
+ end
16
+ if os.getenv(GETONLY_ENV) ~= "TRUE" or method == "GET" then
17
+ return nil
18
+ end
19
+ local rest = fullurl
20
+ local scheme = string.find(rest, "://", 1, true)
21
+ if scheme then
22
+ rest = string.gsub(string.sub(rest, scheme + 3), "^[^/?#]*", "")
23
+ end
24
+ local path = string.match(rest, "^[^?#]*")
25
+ if path == "" then
26
+ path = "/"
27
+ end
28
+ return ProjectNameError.new("fetch_getonly_block",
29
+ "[GET-ONLY GUARD] blocked " .. method .. " " .. path)
30
+ end
5
31
 
6
32
  local function default_http_fetch(fullurl, fetchdef)
33
+ local refused = getonly_refusal(fullurl, fetchdef["method"])
34
+ if refused then
35
+ return nil, refused
36
+ end
37
+
7
38
  -- Use LuaSocket or similar for real HTTP requests.
8
39
  -- This is the default live implementation.
9
40
  local http_ok, http = pcall(require, "socket.http")
@@ -24,13 +24,17 @@ local function make_url_util(ctx)
24
24
  authquery[name] = true
25
25
  end
26
26
 
27
- -- A route the definition ends with a slash keeps it: a server such as a
28
- -- Django REST one redirects or refuses the route without it.
27
+ -- A route the definition ends with a slash keeps it, for a Django REST server,
28
+ -- and a host with no path takes /, or luasocket reads a query as the host.
29
29
  local orig = ctx.point ~= nil and vs.getprop(ctx.point, "orig") or nil
30
30
  if type(orig) == "string" and orig:sub(-1) == "/" and (spec.suffix == nil or spec.suffix == "")
31
31
  and url:sub(-1) ~= "/" then
32
32
  url = url .. "/"
33
33
  end
34
+ local authority = url:find("://", 1, true)
35
+ if authority ~= nil and 1 < authority and not url:find("[/?#]", authority + 3) then
36
+ url = url .. "/"
37
+ end
34
38
 
35
39
  local param_items = vs.items(spec.params)
36
40
  if param_items ~= nil then
@@ -142,11 +142,15 @@ test-primary: run_primary_corpus
142
142
  test-concurrency: run_concurrency_test
143
143
  ./run_concurrency_test
144
144
 
145
+ # The sdk suite sets the GET-only flag with Unix.putenv; a feature tier that
146
+ # links unix.cma already brings it.
147
+ SDK_UNIX = $(if $(filter unix.cma,$(FEATURE_LIB)),,unix.cma)
148
+
145
149
  # Every executable that links the RUNTIME links the gated feature tier with
146
150
  # it: library archives FIRST (an archive must precede the modules that use
147
151
  # it), stub objects and link flags LAST.
148
152
  run_sdk_test: $(SDK_TEST) $(FEATURE_OBJ)
149
- $(OCAMLC) $(INC) $(FEATURE_LIB) $(SDK_TEST) $(FEATURE_OBJ) $(FEATURE_LINK) -o run_sdk_test
153
+ $(OCAMLC) $(INC) -I +unix $(SDK_UNIX) $(FEATURE_LIB) $(SDK_TEST) $(FEATURE_OBJ) $(FEATURE_LINK) -o run_sdk_test
150
154
 
151
155
  run_omni_smoke: $(SMOKE_SRC)
152
156
  $(OCAMLC) $(INC) $(SMOKE_SRC) -o run_omni_smoke