@voxgig/sdkgen 4.8.2 → 4.8.3
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/action/doctor.d.ts +1 -0
- package/dist/action/doctor.js +50 -2
- package/dist/action/doctor.js.map +1 -1
- package/dist/helpers/naming.js +4 -2
- package/dist/helpers/naming.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/model/sdkgen.aon +21 -0
- package/package.json +1 -1
- package/project/.sdk/model/feature/secrets.aon +120 -18
- package/project/.sdk/model/target/c.aon +10 -0
- package/project/.sdk/model/target/clojure.aon +13 -0
- package/project/.sdk/model/target/cpp.aon +10 -0
- package/project/.sdk/model/target/csharp.aon +9 -0
- package/project/.sdk/model/target/dart.aon +10 -0
- package/project/.sdk/model/target/elixir.aon +9 -0
- package/project/.sdk/model/target/go.aon +13 -0
- package/project/.sdk/model/target/java.aon +9 -0
- package/project/.sdk/model/target/js.aon +7 -0
- package/project/.sdk/model/target/kotlin.aon +9 -0
- package/project/.sdk/model/target/lean.aon +17 -0
- package/project/.sdk/model/target/lua.aon +8 -0
- package/project/.sdk/model/target/ocaml.aon +9 -0
- package/project/.sdk/model/target/perl.aon +8 -0
- package/project/.sdk/model/target/php.aon +8 -0
- package/project/.sdk/model/target/py.aon +13 -0
- package/project/.sdk/model/target/rb.aon +8 -0
- package/project/.sdk/model/target/rust.aon +10 -0
- package/project/.sdk/model/target/scala.aon +21 -2
- package/project/.sdk/model/target/swift.aon +18 -0
- package/project/.sdk/model/target/ts.aon +13 -0
- package/project/.sdk/src/cmp/clojure/Package_clojure.ts +9 -2
- package/project/.sdk/src/cmp/cpp/Gitignore_cpp.ts +3 -0
- package/project/.sdk/src/cmp/dart/Test_dart.ts +2 -0
- package/project/.sdk/src/cmp/elixir/Package_elixir.ts +4 -1
- package/project/.sdk/src/cmp/go/Config_go.ts +59 -2
- package/project/.sdk/src/cmp/go/Main_go.ts +8 -2
- package/project/.sdk/src/cmp/java/Test_java.ts +6 -5
- package/project/.sdk/src/cmp/kotlin/Test_kotlin.ts +6 -5
- package/project/.sdk/src/cmp/lean/Package_lean.ts +23 -0
- package/project/.sdk/src/cmp/lean/ReadmeInstall_lean.ts +1 -0
- package/project/.sdk/src/cmp/lean/ReadmeTopTest_lean.ts +1 -0
- package/project/.sdk/src/cmp/ocaml/Gitignore_ocaml.ts +1 -0
- package/project/.sdk/src/cmp/ocaml/Main_ocaml.ts +7 -3
- package/project/.sdk/src/cmp/py/Config_py.ts +82 -1
- package/project/.sdk/src/cmp/py/Main_py.ts +44 -0
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +2 -0
- package/project/.sdk/src/cmp/swift/Main_swift.ts +10 -0
- package/project/.sdk/src/cmp/swift/Package_swift.ts +13 -1
- package/project/.sdk/src/cmp/ts/Config_ts.ts +42 -17
- package/project/.sdk/src/cmp/ts/fragment/Config.data.fragment.ts +13 -1
- package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +13 -1
- package/project/.sdk/tm/c/Makefile +38 -3
- package/project/.sdk/tm/c/tests/omni_resolver.h +361 -0
- package/project/.sdk/tm/c/tests/omni_smoke_test.c +237 -0
- package/project/.sdk/tm/c/tests/primary_corpus_test.c +205 -284
- package/project/.sdk/tm/c/tests/struct_corpus_test.c +292 -212
- package/project/.sdk/tm/c/tests/vendor/omni/json.c +811 -0
- package/project/.sdk/tm/c/tests/vendor/omni/omni.h +240 -0
- package/project/.sdk/tm/c/tests/vendor/omni/runner.c +940 -0
- package/project/.sdk/tm/c/tests/vendor/omni/util.c +351 -0
- package/project/.sdk/tm/c/utility/struct/utility.c +7 -2
- package/project/.sdk/tm/clojure/test/sdk/test/omni.clj +401 -0
- package/project/.sdk/tm/clojure/test/sdk/test/omni_smoke.clj +81 -0
- package/project/.sdk/tm/clojure/test/sdk/test/primary.clj +92 -58
- package/project/.sdk/tm/clojure/test/sdk/test/struct_corpus.clj +122 -149
- package/project/.sdk/tm/clojure/test/sdk/test_runner.clj +8 -3
- package/project/.sdk/tm/clojure/test/vendor/omni/voxgig/omni/json.clj +145 -0
- package/project/.sdk/tm/clojure/test/vendor/omni/voxgig/omni/runner.clj +445 -0
- package/project/.sdk/tm/clojure/test/vendor/omni/voxgig/omni/util.clj +145 -0
- package/project/.sdk/tm/cpp/Makefile +5 -1
- package/project/.sdk/tm/cpp/test/omni_resolver.hpp +473 -0
- package/project/.sdk/tm/cpp/test/omni_smoke_test.cpp +209 -0
- package/project/.sdk/tm/cpp/test/primary_utility_test.cpp +243 -184
- package/project/.sdk/tm/cpp/test/runner_support.hpp +68 -181
- package/project/.sdk/tm/cpp/test/struct_corpus_test.cpp +183 -56
- package/project/.sdk/tm/cpp/test/vendor/omni/json.hpp +406 -0
- package/project/.sdk/tm/cpp/test/vendor/omni/omni.hpp +751 -0
- package/project/.sdk/tm/cpp/test/vendor/omni/util.hpp +256 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +7 -1
- package/project/.sdk/tm/csharp/test/OmniResolver.cs +491 -0
- package/project/.sdk/tm/csharp/test/OmniSmokeTest.cs +106 -0
- package/project/.sdk/tm/csharp/test/PrimaryUtilityTest.cs +299 -316
- package/project/.sdk/tm/csharp/test/Runner.cs +104 -269
- package/project/.sdk/tm/csharp/test/StructUtilityTest.cs +535 -724
- package/project/.sdk/tm/csharp/test/vendor/omni/Runner.cs +864 -0
- package/project/.sdk/tm/csharp/test/vendor/omni/Util.cs +347 -0
- package/project/.sdk/tm/csharp/utility/MakeSpec.cs +3 -1
- package/project/.sdk/tm/csharp/utility/PrepareMethod.cs +6 -1
- package/project/.sdk/tm/csharp/utility/struct/Struct.cs +21 -5
- package/project/.sdk/tm/dart/test/omni.dart +520 -0
- package/project/.sdk/tm/dart/test/omni_smoke_test.dart +143 -0
- package/project/.sdk/tm/dart/test/primary_test.dart +86 -28
- package/project/.sdk/tm/dart/test/struct_test.dart +438 -11
- package/project/.sdk/tm/dart/test/vendor/omni/omni.dart +7 -0
- package/project/.sdk/tm/dart/test/vendor/omni/runner.dart +653 -0
- package/project/.sdk/tm/dart/test/vendor/omni/util.dart +232 -0
- package/project/.sdk/tm/elixir/Makefile +11 -3
- package/project/.sdk/tm/elixir/test/omni_smoke_test.exs +117 -0
- package/project/.sdk/tm/elixir/test/primary_utility_test.exs +341 -16
- package/project/.sdk/tm/elixir/test/struct_corpus_test.exs +554 -9
- package/project/.sdk/tm/elixir/test/support/omni.ex +377 -0
- package/project/.sdk/tm/elixir/test/vendor/omni/json.ex +122 -0
- package/project/.sdk/tm/elixir/test/vendor/omni/runner.ex +623 -0
- package/project/.sdk/tm/elixir/test/vendor/omni/util.ex +187 -0
- package/project/.sdk/tm/go/core/context.go +32 -16
- package/project/.sdk/tm/go/feature/secrets/plugin/capability.go +261 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/catalog.go +78 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/config.go +652 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/depend.go +250 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/env.go +194 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/export.go +80 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/graph.go +238 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/host.go +1575 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/order.go +248 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/point.go +184 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/ref.go +123 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/resolve.go +79 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/types.go +296 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/util.go +87 -0
- package/project/.sdk/tm/go/feature/secrets/plugin/version.go +161 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/aws/aws.go +292 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/aws/sigv4.go +201 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/azuresecrets/azuresecrets.go +187 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/boru/boru.go +184 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/doppler/doppler.go +114 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/gcpsecrets/gcpsecrets.go +156 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/hashicorp/hashicorp.go +209 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/httpjson/httpjson.go +241 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/infisical/infisical.go +151 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/onepassword/onepassword.go +152 -0
- package/project/.sdk/tm/go/feature/secrets/plugins/secretspec/secretspec.go +143 -0
- package/project/.sdk/tm/go/feature/secrets/sekreto/addr.go +120 -0
- package/project/.sdk/tm/go/feature/secrets/sekreto/providers.go +439 -0
- package/project/.sdk/tm/go/feature/secrets/sekreto/sekreto.go +685 -0
- package/project/.sdk/tm/go/feature/secrets_feature.go +675 -0
- package/project/.sdk/tm/go/src/feature/secrets/.gitkeep +0 -0
- package/project/.sdk/tm/go/test/feature/secrets/secrets_feature_test.go +799 -0
- package/project/.sdk/tm/go/test/omni/omni.go +897 -0
- package/project/.sdk/tm/go/test/omni/util.go +360 -0
- package/project/.sdk/tm/go/test/omniresolver_test.go +748 -0
- package/project/.sdk/tm/go/test/omnismoke_test.go +112 -0
- package/project/.sdk/tm/go/test/primary_utility_test.go +123 -191
- package/project/.sdk/tm/go/test/struct_utility_test.go +323 -16
- package/project/.sdk/tm/go/test/testsupport_test.go +294 -0
- package/project/.sdk/tm/go/utility/make_options.go +8 -1
- package/project/.sdk/tm/go/utility/prepare_method.go +5 -1
- package/project/.sdk/tm/go/utility/struct/voxgigstruct.go +2 -2
- package/project/.sdk/tm/java/test/OmniResolver.java +355 -0
- package/project/.sdk/tm/java/test/OmniSmokeTest.java +99 -0
- package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +254 -280
- package/project/.sdk/tm/java/test/RunnerSupport.java +9 -194
- package/project/.sdk/tm/java/test/StructCorpusTest.java +119 -42
- package/project/.sdk/tm/java/test/vendor/omni/Json.java +287 -0
- package/project/.sdk/tm/java/test/vendor/omni/Runner.java +851 -0
- package/project/.sdk/tm/java/test/vendor/omni/Util.java +322 -0
- package/project/.sdk/tm/java/utility/MakeSpec.java +3 -1
- package/project/.sdk/tm/java/utility/PrepareMethod.java +5 -5
- package/project/.sdk/tm/java/utility/struct/Struct.java +17 -4
- package/project/.sdk/tm/js/src/utility/StructUtility.js +3 -3
- package/project/.sdk/tm/js/test/omni.js +251 -0
- package/project/.sdk/tm/js/test/omni.test.js +105 -0
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +6 -2
- package/project/.sdk/tm/js/test/utility/StructUtility.test.js +27 -2
- package/project/.sdk/tm/js/test/vendor/omni/index.js +77 -0
- package/project/.sdk/tm/js/test/vendor/omni/runner.js +613 -0
- package/project/.sdk/tm/js/test/vendor/omni/util.js +212 -0
- package/project/.sdk/tm/kotlin/core/Utility.kt +1 -1
- package/project/.sdk/tm/kotlin/test/OmniResolver.kt +343 -0
- package/project/.sdk/tm/kotlin/test/OmniSmokeTest.kt +100 -0
- package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +244 -262
- package/project/.sdk/tm/kotlin/test/RunnerSupport.kt +9 -178
- package/project/.sdk/tm/kotlin/test/StructCorpusTest.kt +121 -32
- package/project/.sdk/tm/kotlin/test/vendor/omni/Json.kt +264 -0
- package/project/.sdk/tm/kotlin/test/vendor/omni/Runner.kt +615 -0
- package/project/.sdk/tm/kotlin/test/vendor/omni/Util.kt +139 -0
- package/project/.sdk/tm/kotlin/utility/MakeSpecUrl.kt +6 -3
- package/project/.sdk/tm/kotlin/utility/Prepare.kt +6 -6
- package/project/.sdk/tm/kotlin/utility/struct/Struct.kt +18 -2
- package/project/.sdk/tm/lean/Makefile +12 -5
- package/project/.sdk/tm/lean/src/SdkUtility.lean +14 -1
- package/project/.sdk/tm/lean/test/OmniResolver.lean +358 -0
- package/project/.sdk/tm/lean/test/OmniSmoke.lean +174 -0
- package/project/.sdk/tm/lean/test/StructCorpus.lean +245 -574
- package/project/.sdk/tm/lean/test/TPrimaryUtility.lean +155 -291
- package/project/.sdk/tm/lean/test/vendor/omni/Omni.lean +997 -0
- package/project/.sdk/tm/lua/test/omni.lua +456 -0
- package/project/.sdk/tm/lua/test/omni_smoke_test.lua +103 -0
- package/project/.sdk/tm/lua/test/primary_utility_test.lua +250 -509
- package/project/.sdk/tm/lua/test/struct_utility_test.lua +161 -70
- package/project/.sdk/tm/lua/test/vendor/omni/json.lua +268 -0
- package/project/.sdk/tm/lua/test/vendor/omni/regex.lua +385 -0
- package/project/.sdk/tm/lua/test/vendor/omni/runner.lua +641 -0
- package/project/.sdk/tm/lua/test/vendor/omni/util.lua +282 -0
- package/project/.sdk/tm/lua/utility/prepare_method.lua +5 -1
- package/project/.sdk/tm/lua/utility/struct/regex.lua +663 -0
- package/project/.sdk/tm/lua/utility/struct/struct.lua +660 -420
- package/project/.sdk/tm/ocaml/Makefile +37 -12
- package/project/.sdk/tm/ocaml/test/omni_resolver.ml +284 -0
- package/project/.sdk/tm/ocaml/test/omni_smoke_test.ml +169 -0
- package/project/.sdk/tm/ocaml/test/primary_utility_test.ml +84 -100
- package/project/.sdk/tm/ocaml/test/struct_corpus.ml +225 -201
- package/project/.sdk/tm/ocaml/test/vendor/omni/omni.ml +1157 -0
- package/project/.sdk/tm/perl/lib/Voxgig/Struct.pm +88 -12
- package/project/.sdk/tm/perl/t/omni.pm +647 -0
- package/project/.sdk/tm/perl/t/omni_smoke.t +87 -0
- package/project/.sdk/tm/perl/t/primary_utility.t +189 -487
- package/project/.sdk/tm/perl/t/struct_utility.t +455 -389
- package/project/.sdk/tm/perl/t/vendor/omni/Voxgig/Omni/Runner.pm +649 -0
- package/project/.sdk/tm/perl/t/vendor/omni/Voxgig/Omni/Util.pm +253 -0
- package/project/.sdk/tm/perl/t/vendor/omni/Voxgig/Omni.pm +24 -0
- package/project/.sdk/tm/perl/utility/prepare_method.pm +7 -2
- package/project/.sdk/tm/php/test/Omni.php +691 -0
- package/project/.sdk/tm/php/test/OmniSmokeTest.php +93 -0
- package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +210 -571
- package/project/.sdk/tm/php/test/StructUtilityTest.php +320 -342
- package/project/.sdk/tm/php/test/vendor/omni/Runner.php +644 -0
- package/project/.sdk/tm/php/test/vendor/omni/Util.php +283 -0
- package/project/.sdk/tm/php/utility/MakeSpec.php +10 -3
- package/project/.sdk/tm/php/utility/PrepareBody.php +7 -1
- package/project/.sdk/tm/php/utility/PrepareMethod.php +6 -2
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/__init__.py +36 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/capability.py +141 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/catalog.py +50 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/config.py +333 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/depend.py +198 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/env.py +147 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/export.py +52 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/graph.py +139 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/host.py +1053 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/order.py +171 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/point.py +95 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/ref.py +116 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/resolve.py +59 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/types.py +87 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_plugin/version.py +112 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/__init__.py +74 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/addr.py +116 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/aws.py +192 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/azuresecrets.py +120 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/boru.py +140 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/doppler.py +62 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/gcpsecrets.py +101 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/hashicorp.py +152 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/httpjson.py +115 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/infisical.py +92 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/onepassword.py +101 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/secretspec.py +119 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/plugins/sigv4.py +125 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/providers.py +211 -0
- package/project/.sdk/tm/py/pkg/feature/secrets/voxgig_sekreto/sekreto.py +455 -0
- package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +467 -0
- package/project/.sdk/tm/py/pkg/utility/prepare_method.py +5 -1
- package/project/.sdk/tm/py/pkg/utility/voxgig_struct/__init__.py +0 -2
- package/project/.sdk/tm/py/pkg/utility/voxgig_struct/voxgig_struct.py +780 -529
- package/project/.sdk/tm/py/src/feature/secrets/.gitkeep +0 -0
- package/project/.sdk/tm/py/test/feature/__init__.py +0 -0
- package/project/.sdk/tm/py/test/feature/secrets/__init__.py +0 -0
- package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +337 -0
- package/project/.sdk/tm/py/test/omni.py +415 -0
- package/project/.sdk/tm/py/test/test_omni_smoke.py +74 -0
- package/project/.sdk/tm/py/test/test_primary_utility.py +144 -668
- package/project/.sdk/tm/py/test/test_struct_utility.py +74 -27
- package/project/.sdk/tm/py/test/voxgig_omni/__init__.py +62 -0
- package/project/.sdk/tm/py/test/voxgig_omni/runner.py +566 -0
- package/project/.sdk/tm/py/test/voxgig_omni/util.py +237 -0
- package/project/.sdk/tm/rb/test/omni.rb +505 -0
- package/project/.sdk/tm/rb/test/omni_smoke_test.rb +72 -0
- package/project/.sdk/tm/rb/test/primary_utility_test.rb +174 -560
- package/project/.sdk/tm/rb/test/struct_utility_test.rb +13 -7
- package/project/.sdk/tm/rb/test/vendor/omni/runner.rb +493 -0
- package/project/.sdk/tm/rb/test/vendor/omni/util.rb +199 -0
- package/project/.sdk/tm/rb/test/vendor/omni/voxgig_omni.rb +15 -0
- package/project/.sdk/tm/rb/utility/prepare_method.rb +5 -1
- package/project/.sdk/tm/rust/tests/common/mod.rs +19 -242
- package/project/.sdk/tm/rust/tests/omni_resolver/mod.rs +888 -0
- package/project/.sdk/tm/rust/tests/omni_smoke_test.rs +286 -0
- package/project/.sdk/tm/rust/tests/primary_utility_test.rs +318 -312
- package/project/.sdk/tm/rust/tests/struct_utility_test.rs +66 -28
- package/project/.sdk/tm/rust/tests/vendor/omni/json.rs +412 -0
- package/project/.sdk/tm/rust/tests/vendor/omni/mod.rs +38 -0
- package/project/.sdk/tm/rust/tests/vendor/omni/regex.rs +392 -0
- package/project/.sdk/tm/rust/tests/vendor/omni/runner.rs +1001 -0
- package/project/.sdk/tm/rust/tests/vendor/omni/util.rs +161 -0
- package/project/.sdk/tm/rust/utility/prepare_method.rs +5 -1
- package/project/.sdk/tm/scala/Makefile +16 -6
- package/project/.sdk/tm/scala/sdktest/OmniResolver.scala +497 -0
- package/project/.sdk/tm/scala/sdktest/OmniSmoke.scala +192 -0
- package/project/.sdk/tm/scala/sdktest/PrimaryCorpus.scala +47 -19
- package/project/.sdk/tm/scala/sdktest/StructCorpus.scala +0 -0
- package/project/.sdk/tm/scala/sdktest/vendor/omni/Json.scala +229 -0
- package/project/.sdk/tm/scala/sdktest/vendor/omni/Runner.scala +552 -0
- package/project/.sdk/tm/scala/sdktest/vendor/omni/Util.scala +104 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Constants.swift +10 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Inject.swift +28 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Injection.swift +5 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Minor.swift +4 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/Struct/Validate.swift +15 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Prepare.swift +6 -1
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/OmniResolver.swift +474 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/OmniSmokeTest.swift +107 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PrimaryUtilityTest.swift +141 -178
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/Runner.swift +17 -113
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/StructUtilityTest.swift +295 -446
- package/project/.sdk/tm/swift/Tests/vendor/omni/Json.swift +364 -0
- package/project/.sdk/tm/swift/Tests/vendor/omni/Runner.swift +730 -0
- package/project/.sdk/tm/swift/Tests/vendor/omni/Util.swift +162 -0
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +7 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Capability.ts +148 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Catalog.ts +55 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Config.ts +344 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Depend.ts +205 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Env.ts +138 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Export.ts +46 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/FeatureHost.ts +349 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Graph.ts +181 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Host.ts +1132 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Order.ts +177 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Point.ts +119 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Ref.ts +102 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Resolve.ts +61 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Types.ts +112 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/Version.ts +100 -0
- package/project/.sdk/tm/ts/src/feature/secrets/plugin/index.ts +37 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/Sekreto.ts +163 -30
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/index.ts +27 -22
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/aws.ts +26 -36
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/azuresecrets.ts +19 -21
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/boru.ts +36 -17
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/doppler.ts +14 -21
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/gcpsecrets.ts +27 -27
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/hashicorp.ts +25 -39
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/plugins/httpjson.ts +99 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/infisical.ts +14 -16
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{provider → plugins}/onepassword.ts +15 -22
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/plugins/secretspec.ts +98 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/{Sigv4.ts → plugins/sigv4.ts} +7 -6
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/addr.ts +97 -23
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/builtin.ts +37 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/dotenv.ts +4 -17
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/env.ts +4 -16
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/file.ts +11 -25
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/memory.ts +6 -23
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/support.ts +106 -39
- package/project/.sdk/tm/ts/src/utility/StructUtility.ts +3 -3
- package/project/.sdk/tm/ts/test/omni.ts +104 -32
- package/project/.sdk/tm/ts/test/utility/StructUtility.test.ts +27 -0
- package/project/.sdk/tm/ts/test/vendor/omni/Runner.ts +32 -5
- package/project/.sdk/tm/ts/test/vendor/omni/Util.ts +2 -2
- package/project/.sdk/tm/ts/test/vendor/omni/index.ts +2 -2
- package/project/.sdk/tm/zig/test/primary_utility_test.zig +1 -1
- package/project/.sdk/tm/zig/test/struct_runner.zig +5 -4
- package/project/sdkgen-package.json +1 -1
- package/src/action/doctor.ts +66 -2
- package/src/helpers/naming.ts +4 -2
- package/project/.sdk/tm/c/tests/runner.h +0 -274
- package/project/.sdk/tm/cpp/test/struct_runner.hpp +0 -314
- package/project/.sdk/tm/csharp/test/StructRunner.cs +0 -276
- package/project/.sdk/tm/dart/test/runner.dart +0 -406
- package/project/.sdk/tm/dart/test/struct_corpus.dart +0 -531
- package/project/.sdk/tm/elixir/test/support/struct_corpus.ex +0 -1088
- package/project/.sdk/tm/go/test/runner_test.go +0 -629
- package/project/.sdk/tm/go/test/struct_runner_test.go +0 -1094
- package/project/.sdk/tm/java/test/StructRunner.java +0 -281
- package/project/.sdk/tm/js/test/runner.js +0 -387
- package/project/.sdk/tm/kotlin/test/StructRunner.kt +0 -177
- package/project/.sdk/tm/lua/test/struct_runner.lua +0 -602
- package/project/.sdk/tm/ocaml/test/corpus_runner.ml +0 -185
- package/project/.sdk/tm/perl/t/struct_runner.pm +0 -275
- package/project/.sdk/tm/php/test/StructRunner.php +0 -275
- package/project/.sdk/tm/py/test/struct_runner.py +0 -411
- package/project/.sdk/tm/rb/test/struct_runner.rb +0 -309
- package/project/.sdk/tm/rust/tests/struct_runner/mod.rs +0 -424
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/Registry.ts +0 -90
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/http.ts +0 -66
- package/project/.sdk/tm/ts/test/vendor/omni/compat.ts +0 -188
|
@@ -1,21 +1,89 @@
|
|
|
1
1
|
# ProjectName SDK primary utility test
|
|
2
|
+
#
|
|
3
|
+
# Corpus sections run through the vendored omni runner, via the resolver
|
|
4
|
+
# in test/omni.rb (struct-runner shape over native voxgig_omni). The
|
|
5
|
+
# inline corpus engine this file used to carry is retired: omni resolves
|
|
6
|
+
# arguments, applies the null rules, and enforces out/err/match - the
|
|
7
|
+
# subjects below only adapt each utility's calling convention.
|
|
8
|
+
#
|
|
9
|
+
# Two conventions to know when adding a section:
|
|
10
|
+
#
|
|
11
|
+
# - Utilities that answer as a `return value, err` TUPLE go through
|
|
12
|
+
# `unwrap`, which raises the err so omni can match it against `err:`
|
|
13
|
+
# expectations. Utilities that answer bare values (or raise) are passed
|
|
14
|
+
# straight in.
|
|
15
|
+
#
|
|
16
|
+
# - `match: {ctx: ...}` assertions read the LIVE context after the
|
|
17
|
+
# subject ran - the resolver's ObjView takes care of presenting the
|
|
18
|
+
# context object as the map omni walks, camelCase keys included.
|
|
2
19
|
|
|
3
20
|
require "minitest/autorun"
|
|
4
21
|
require "json"
|
|
5
22
|
require_relative "../ProjectName_sdk"
|
|
6
|
-
require_relative "
|
|
23
|
+
require_relative "omni"
|
|
7
24
|
|
|
8
25
|
class PrimaryUtilityTest < Minitest::Test
|
|
9
26
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
27
|
+
# Resolved against test/omni.rb's own directory, so the suite works
|
|
28
|
+
# from any working directory.
|
|
29
|
+
TEST_JSON_FILE = "../../.sdk/test/test.json"
|
|
30
|
+
|
|
31
|
+
# Sections deliberately left empty in the shared corpus
|
|
32
|
+
# (.sdk/test/primary/<name>.aon carries a PENDING header). Everything
|
|
33
|
+
# else MUST contribute cases.
|
|
34
|
+
PENDING = %w[
|
|
35
|
+
fetcher makeFetchDef makeResult
|
|
36
|
+
featureAdd featureHook featureInit
|
|
37
|
+
].freeze
|
|
14
38
|
|
|
15
|
-
|
|
39
|
+
def setup
|
|
40
|
+
@runner = ProjectNameOmni.make_runner(TEST_JSON_FILE, ProjectNameSDK.test(nil, nil))
|
|
41
|
+
@run = @runner.call("primary")
|
|
42
|
+
|
|
43
|
+
@spec = @run[:spec]
|
|
44
|
+
@runset = @run[:runset]
|
|
45
|
+
@runsetflags = @run[:runsetflags]
|
|
46
|
+
|
|
47
|
+
# Under the old inline runner the suite drove the SDK directly; under
|
|
48
|
+
# omni the runpack's client is the provider wrapping it. This suite
|
|
49
|
+
# treats the client as the SDK - so unwrap the real instance
|
|
50
|
+
# (mirrors ts).
|
|
51
|
+
@client = @run[:client][:sdk]
|
|
16
52
|
@utility = @client.get_utility
|
|
17
53
|
end
|
|
18
54
|
|
|
55
|
+
# Run one corpus section, failing loudly when it would run ZERO cases.
|
|
56
|
+
# A renamed section or a fixture that compiled to an empty `set` used
|
|
57
|
+
# to pass silently, which defeats the point of a shared oracle. EVERY
|
|
58
|
+
# corpus-backed test goes through here (mirrors ts).
|
|
59
|
+
def runsection(name, subject)
|
|
60
|
+
section = @spec.is_a?(Hash) ? @spec[name] : nil
|
|
61
|
+
refute_nil section,
|
|
62
|
+
"test corpus section '#{name}' missing - check the name against .sdk/test/primary/"
|
|
63
|
+
basic = section.is_a?(Hash) ? section["basic"] : nil
|
|
64
|
+
assert basic.is_a?(Hash) && basic["set"].is_a?(Array),
|
|
65
|
+
"test corpus section '#{name}' has no basic.set list"
|
|
66
|
+
if basic["set"].empty? && !PENDING.include?(name)
|
|
67
|
+
flunk "test corpus section '#{name}' is EMPTY - zero cases would run; " \
|
|
68
|
+
"add cases, or mark the fixture PENDING in .sdk/test/primary/"
|
|
69
|
+
end
|
|
70
|
+
@runset.call(basic, subject)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# `return value, err` tuple convention -> value-or-raise, omni's shape.
|
|
74
|
+
def unwrap(pair)
|
|
75
|
+
value, err = pair
|
|
76
|
+
raise err unless err.nil?
|
|
77
|
+
value
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def err_from_map(m)
|
|
81
|
+
return nil unless m.is_a?(Hash)
|
|
82
|
+
msg = m["message"]
|
|
83
|
+
return nil unless msg.is_a?(String) && !msg.empty?
|
|
84
|
+
ProjectNameError.new(m["code"] || "", msg)
|
|
85
|
+
end
|
|
86
|
+
|
|
19
87
|
|
|
20
88
|
# === exists ===
|
|
21
89
|
|
|
@@ -58,39 +126,28 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
58
126
|
ctx = make_test_ctx(@client, @utility, nil)
|
|
59
127
|
val = { "key" => "secret123", "name" => "test" }
|
|
60
128
|
cleaned = @utility.clean.call(ctx, val)
|
|
61
|
-
assert cleaned, "
|
|
129
|
+
assert cleaned, "clean should return a value"
|
|
62
130
|
end
|
|
63
131
|
|
|
64
132
|
|
|
65
133
|
# === done ===
|
|
66
134
|
|
|
67
135
|
def test_done_basic
|
|
68
|
-
|
|
69
|
-
ctxmap = entry["ctx"] || {}
|
|
70
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
71
|
-
fixctx(ctx, @client)
|
|
72
|
-
@utility.done.call(ctx)
|
|
73
|
-
end
|
|
136
|
+
runsection("done", ->(ctx) { @utility.done.call(ctx) })
|
|
74
137
|
end
|
|
75
138
|
|
|
76
139
|
|
|
77
140
|
# === makeError ===
|
|
78
141
|
|
|
79
142
|
def test_make_error_basic
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
85
|
-
fixctx(ctx, @client)
|
|
86
|
-
|
|
87
|
-
err = nil
|
|
88
|
-
if args.length > 1 && args[1].is_a?(Hash)
|
|
89
|
-
err = err_from_map(args[1])
|
|
90
|
-
end
|
|
91
|
-
|
|
143
|
+
subject = lambda do |ctx, errmap = nil|
|
|
144
|
+
err = errmap.is_a?(Hash) ? err_from_map(errmap) : nil
|
|
145
|
+
# make_error raises the constructed exception on the default
|
|
146
|
+
# (throw) path; omni matches it against the entry's err.
|
|
92
147
|
@utility.make_error.call(ctx, err)
|
|
93
148
|
end
|
|
149
|
+
|
|
150
|
+
runsection("makeError", subject)
|
|
94
151
|
end
|
|
95
152
|
|
|
96
153
|
def test_make_error_no_throw
|
|
@@ -101,10 +158,11 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
101
158
|
"resdata" => { "id" => "safe01" },
|
|
102
159
|
})
|
|
103
160
|
|
|
104
|
-
#
|
|
161
|
+
# throw_err is false: make_error returns the bare result data instead
|
|
162
|
+
# of raising (the result-object / no-throw escape hatch).
|
|
105
163
|
out = @utility.make_error.call(ctx, ctx.make_error("test_code", "test message"))
|
|
106
|
-
assert out.is_a?(Hash)
|
|
107
|
-
assert_equal "safe01", out["id"]
|
|
164
|
+
assert out.is_a?(Hash)
|
|
165
|
+
assert_equal "safe01", out["id"]
|
|
108
166
|
end
|
|
109
167
|
|
|
110
168
|
|
|
@@ -117,8 +175,7 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
117
175
|
feature = ProjectNameBaseFeature.new
|
|
118
176
|
@utility.feature_add.call(ctx, feature)
|
|
119
177
|
|
|
120
|
-
assert_equal start_len + 1, @client.features.length
|
|
121
|
-
"expected #{start_len + 1} features, got #{@client.features.length}"
|
|
178
|
+
assert_equal start_len + 1, @client.features.length
|
|
122
179
|
end
|
|
123
180
|
|
|
124
181
|
|
|
@@ -134,7 +191,7 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
134
191
|
hook_client.features = [hook_feature]
|
|
135
192
|
|
|
136
193
|
hook_utility.feature_hook.call(ctx, "TestHook")
|
|
137
|
-
assert called, "
|
|
194
|
+
assert called, "hook should have been called"
|
|
138
195
|
end
|
|
139
196
|
|
|
140
197
|
|
|
@@ -148,11 +205,10 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
148
205
|
"initfeat" => { "active" => true },
|
|
149
206
|
}
|
|
150
207
|
|
|
151
|
-
|
|
152
|
-
feature = TestInitFeature.new("initfeat", true) {
|
|
153
|
-
|
|
208
|
+
called = false
|
|
209
|
+
feature = TestInitFeature.new("initfeat", true) { called = true }
|
|
154
210
|
init_utility.feature_init.call(ctx, feature)
|
|
155
|
-
assert
|
|
211
|
+
assert called, "init should have been called"
|
|
156
212
|
end
|
|
157
213
|
|
|
158
214
|
def test_feature_init_inactive
|
|
@@ -163,11 +219,10 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
163
219
|
"nofeat" => { "active" => false },
|
|
164
220
|
}
|
|
165
221
|
|
|
166
|
-
|
|
167
|
-
feature = TestInitFeature.new("nofeat", false) {
|
|
168
|
-
|
|
222
|
+
called = false
|
|
223
|
+
feature = TestInitFeature.new("nofeat", false) { called = true }
|
|
169
224
|
init_utility.feature_init.call(ctx, feature)
|
|
170
|
-
|
|
225
|
+
assert_equal false, called, "init should not have been called"
|
|
171
226
|
end
|
|
172
227
|
|
|
173
228
|
|
|
@@ -176,13 +231,14 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
176
231
|
def test_fetcher_live
|
|
177
232
|
calls = []
|
|
178
233
|
live_client = ProjectNameSDK.new({
|
|
179
|
-
# Concrete base: a live construction must satisfy any server
|
|
180
|
-
# a templated base URL declares; a literal base sidesteps
|
|
234
|
+
# Concrete base: a live construction must satisfy any server
|
|
235
|
+
# variables a templated base URL declares; a literal base sidesteps
|
|
236
|
+
# the requirement.
|
|
181
237
|
"base" => "http://localhost:8080",
|
|
182
238
|
"system" => {
|
|
183
|
-
"fetch" =>
|
|
239
|
+
"fetch" => lambda { |url, fetchdef|
|
|
184
240
|
calls << { "url" => url, "init" => fetchdef }
|
|
185
|
-
|
|
241
|
+
[{ "status" => 200, "statusText" => "OK" }, nil]
|
|
186
242
|
},
|
|
187
243
|
},
|
|
188
244
|
})
|
|
@@ -195,8 +251,8 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
195
251
|
|
|
196
252
|
fetchdef = { "method" => "GET", "headers" => {} }
|
|
197
253
|
_, err = live_utility.fetcher.call(ctx, "http://example.com/test", fetchdef)
|
|
198
|
-
assert_nil err
|
|
199
|
-
assert_equal 1, calls.length
|
|
254
|
+
assert_nil err
|
|
255
|
+
assert_equal 1, calls.length
|
|
200
256
|
assert_equal "http://example.com/test", calls[0]["url"]
|
|
201
257
|
end
|
|
202
258
|
|
|
@@ -204,9 +260,7 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
204
260
|
blocked_client = ProjectNameSDK.new({
|
|
205
261
|
"base" => "http://localhost:8080",
|
|
206
262
|
"system" => {
|
|
207
|
-
"fetch" =>
|
|
208
|
-
return {}, nil
|
|
209
|
-
},
|
|
263
|
+
"fetch" => lambda { |_url, _fetchdef| [{}, nil] },
|
|
210
264
|
},
|
|
211
265
|
})
|
|
212
266
|
blocked_client.mode = "test"
|
|
@@ -220,28 +274,29 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
220
274
|
|
|
221
275
|
fetchdef = { "method" => "GET", "headers" => {} }
|
|
222
276
|
_, err = blocked_utility.fetcher.call(ctx, "http://example.com/test", fetchdef)
|
|
223
|
-
assert err, "expected error
|
|
224
|
-
|
|
277
|
+
assert err, "expected blocked error"
|
|
278
|
+
assert_includes err.to_s.downcase, "blocked"
|
|
225
279
|
end
|
|
226
280
|
|
|
227
281
|
|
|
228
282
|
# === makeContext ===
|
|
229
283
|
|
|
230
284
|
def test_make_context_basic
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
end
|
|
242
|
-
out
|
|
285
|
+
subject = lambda do |vin|
|
|
286
|
+
next nil unless vin.is_a?(Hash)
|
|
287
|
+
|
|
288
|
+
ctx = @utility.make_context.call(vin, nil)
|
|
289
|
+
out = { "id" => ctx.id }
|
|
290
|
+
if ctx.op
|
|
291
|
+
out["op"] = {
|
|
292
|
+
"name" => ctx.op.name,
|
|
293
|
+
"input" => ctx.op.input,
|
|
294
|
+
}
|
|
243
295
|
end
|
|
296
|
+
out
|
|
244
297
|
end
|
|
298
|
+
|
|
299
|
+
runsection("makeContext", subject)
|
|
245
300
|
end
|
|
246
301
|
|
|
247
302
|
|
|
@@ -299,67 +354,32 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
299
354
|
# === makeOptions ===
|
|
300
355
|
|
|
301
356
|
def test_make_options_basic
|
|
302
|
-
|
|
303
|
-
|
|
357
|
+
subject = lambda do |vin|
|
|
358
|
+
vin = {} unless vin.is_a?(Hash)
|
|
304
359
|
ctx = @utility.make_context.call({
|
|
305
|
-
"options" =>
|
|
306
|
-
"config" =>
|
|
360
|
+
"options" => vin["options"],
|
|
361
|
+
"config" => vin["config"],
|
|
307
362
|
}, nil)
|
|
308
363
|
ctx.client = @client
|
|
309
364
|
ctx.utility = @utility
|
|
310
365
|
@utility.make_options.call(ctx)
|
|
311
366
|
end
|
|
367
|
+
|
|
368
|
+
runsection("makeOptions", subject)
|
|
312
369
|
end
|
|
313
370
|
|
|
314
371
|
|
|
315
372
|
# === makeRequest ===
|
|
316
373
|
|
|
317
374
|
def test_make_request_basic
|
|
318
|
-
|
|
319
|
-
ctxmap = entry["ctx"] || {}
|
|
320
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
321
|
-
ctx.options = @client.options_map
|
|
322
|
-
|
|
323
|
-
_, err = @utility.make_request.call(ctx)
|
|
324
|
-
raise err if err
|
|
325
|
-
|
|
326
|
-
# Update entry ctx for match checking
|
|
327
|
-
entry_ctx = entry["ctx"]
|
|
328
|
-
if entry_ctx.is_a?(Hash)
|
|
329
|
-
entry_ctx["response"] = "exists" if ctx.response
|
|
330
|
-
entry_ctx["result"] = "exists" if ctx.result
|
|
331
|
-
end
|
|
332
|
-
|
|
333
|
-
nil
|
|
334
|
-
end
|
|
375
|
+
runsection("makeRequest", ->(ctx) { unwrap(@utility.make_request.call(ctx)) })
|
|
335
376
|
end
|
|
336
377
|
|
|
337
378
|
|
|
338
379
|
# === makeResponse ===
|
|
339
380
|
|
|
340
381
|
def test_make_response_basic
|
|
341
|
-
|
|
342
|
-
ctxmap = entry["ctx"] || {}
|
|
343
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
344
|
-
fixctx(ctx, @client)
|
|
345
|
-
|
|
346
|
-
_, err = @utility.make_response.call(ctx)
|
|
347
|
-
raise err if err
|
|
348
|
-
|
|
349
|
-
# Update entry ctx for match checking with result data
|
|
350
|
-
entry_ctx = entry["ctx"]
|
|
351
|
-
if entry_ctx.is_a?(Hash) && ctx.result
|
|
352
|
-
entry_ctx["result"] = {
|
|
353
|
-
"ok" => ctx.result.ok,
|
|
354
|
-
"status" => ctx.result.status,
|
|
355
|
-
"statusText" => ctx.result.status_text,
|
|
356
|
-
"headers" => ctx.result.headers,
|
|
357
|
-
"body" => ctx.result.body,
|
|
358
|
-
}
|
|
359
|
-
end
|
|
360
|
-
|
|
361
|
-
nil
|
|
362
|
-
end
|
|
382
|
+
runsection("makeResponse", ->(ctx) { unwrap(@utility.make_response.call(ctx)) })
|
|
363
383
|
end
|
|
364
384
|
|
|
365
385
|
|
|
@@ -418,41 +438,35 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
418
438
|
# === makeSpec ===
|
|
419
439
|
|
|
420
440
|
def test_make_spec_basic
|
|
421
|
-
setup_opts =
|
|
441
|
+
setup_opts = @spec.dig("makeSpec", "DEF", "setup", "a")
|
|
422
442
|
spec_client = ProjectNameSDK.test(nil, setup_opts)
|
|
423
|
-
spec_utility = spec_client.get_utility
|
|
424
443
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
ctx = make_ctx_from_map(ctxmap, spec_client, spec_utility)
|
|
444
|
+
subject = lambda do |ctx|
|
|
445
|
+
ctx.client = spec_client
|
|
428
446
|
ctx.options = spec_client.options_map
|
|
429
|
-
|
|
430
|
-
_, err = @utility.make_spec.call(ctx)
|
|
431
|
-
raise err if err
|
|
432
|
-
|
|
433
|
-
# Update entry ctx for match
|
|
434
|
-
entry_ctx = entry["ctx"]
|
|
435
|
-
if entry_ctx.is_a?(Hash) && ctx.spec
|
|
436
|
-
entry_ctx["spec"] = {
|
|
437
|
-
"base" => ctx.spec.base,
|
|
438
|
-
"prefix" => ctx.spec.prefix,
|
|
439
|
-
"suffix" => ctx.spec.suffix,
|
|
440
|
-
"method" => ctx.spec.method,
|
|
441
|
-
"params" => ctx.spec.params,
|
|
442
|
-
"query" => ctx.spec.query,
|
|
443
|
-
"headers" => ctx.spec.headers,
|
|
444
|
-
"step" => ctx.spec.step,
|
|
445
|
-
}
|
|
446
|
-
end
|
|
447
|
-
|
|
448
|
-
nil
|
|
447
|
+
unwrap(@utility.make_spec.call(ctx))
|
|
449
448
|
end
|
|
449
|
+
|
|
450
|
+
runsection("makeSpec", subject)
|
|
450
451
|
end
|
|
451
452
|
|
|
452
453
|
|
|
453
454
|
# === makePoint ===
|
|
454
455
|
|
|
455
456
|
def test_make_point_basic
|
|
457
|
+
# Driven from the corpus like every other section. The corpus asserts
|
|
458
|
+
# refusals by code (`match: {out: {code: ...}}`), so an error is the
|
|
459
|
+
# RESULT here - answered as its attribute map, because the vendored
|
|
460
|
+
# runner's own errify keeps only {name,message} (see test/omni.rb).
|
|
461
|
+
subject = lambda do |ctx|
|
|
462
|
+
point, err = @utility.make_point.call(ctx)
|
|
463
|
+
err.nil? ? point : ProjectNameOmni.errify(err)
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
runsection("makePoint", subject)
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
def test_make_point_single
|
|
456
470
|
ctx = make_test_ctx(@client, @utility, nil)
|
|
457
471
|
point = {
|
|
458
472
|
"parts" => ["items", "{id}"],
|
|
@@ -474,21 +488,21 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
474
488
|
# === makeUrl ===
|
|
475
489
|
|
|
476
490
|
def test_make_url_basic
|
|
477
|
-
|
|
478
|
-
ctxmap = entry["ctx"] || {}
|
|
479
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
491
|
+
subject = lambda do |ctx|
|
|
480
492
|
ctx.result = ProjectNameResult.new({}) unless ctx.result
|
|
481
|
-
@utility.make_url.call(ctx)
|
|
493
|
+
unwrap(@utility.make_url.call(ctx))
|
|
482
494
|
end
|
|
495
|
+
|
|
496
|
+
runsection("makeUrl", subject)
|
|
483
497
|
end
|
|
484
498
|
|
|
485
499
|
|
|
486
500
|
# === operator ===
|
|
487
501
|
|
|
488
502
|
def test_operator_basic
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
op = ProjectNameOperation.new(
|
|
503
|
+
subject = lambda do |vin|
|
|
504
|
+
vin = {} unless vin.is_a?(Hash)
|
|
505
|
+
op = ProjectNameOperation.new(vin)
|
|
492
506
|
{
|
|
493
507
|
"entity" => op.entity,
|
|
494
508
|
"name" => op.name,
|
|
@@ -496,131 +510,65 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
496
510
|
"points" => op.points,
|
|
497
511
|
}
|
|
498
512
|
end
|
|
513
|
+
|
|
514
|
+
runsection("operator", subject)
|
|
499
515
|
end
|
|
500
516
|
|
|
501
517
|
|
|
502
518
|
# === param ===
|
|
503
519
|
|
|
504
520
|
def test_param_basic
|
|
505
|
-
|
|
506
|
-
args = entry["args"] || []
|
|
507
|
-
next nil if args.length < 2
|
|
508
|
-
|
|
509
|
-
ctxmap = args[0].is_a?(Hash) ? args[0] : {}
|
|
510
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
511
|
-
paramdef = args[1]
|
|
512
|
-
|
|
513
|
-
result = @utility.param.call(ctx, paramdef)
|
|
514
|
-
|
|
515
|
-
# Update entry ctx for match
|
|
516
|
-
if entry["match"].is_a?(Hash)
|
|
517
|
-
ctx_match = entry["match"]["ctx"]
|
|
518
|
-
if ctx_match.is_a?(Hash)
|
|
519
|
-
entry_ctx = entry["ctx"]
|
|
520
|
-
if entry_ctx.nil?
|
|
521
|
-
entry_ctx = {}
|
|
522
|
-
entry["ctx"] = entry_ctx
|
|
523
|
-
end
|
|
524
|
-
spec_match = ctx_match["spec"]
|
|
525
|
-
if spec_match.is_a?(Hash) && ctx.spec
|
|
526
|
-
entry_ctx["spec"] = {} unless entry_ctx["spec"]
|
|
527
|
-
if spec_match["alias"]
|
|
528
|
-
entry_ctx["spec"] = {
|
|
529
|
-
"alias" => ctx.spec.alias_map,
|
|
530
|
-
}
|
|
531
|
-
end
|
|
532
|
-
end
|
|
533
|
-
end
|
|
534
|
-
end
|
|
535
|
-
|
|
536
|
-
result
|
|
537
|
-
end
|
|
521
|
+
runsection("param", ->(ctx, name = nil) { @utility.param.call(ctx, name) })
|
|
538
522
|
end
|
|
539
523
|
|
|
540
524
|
|
|
541
525
|
# === prepareAuth ===
|
|
542
526
|
|
|
543
527
|
def test_prepare_auth_basic
|
|
544
|
-
setup_opts =
|
|
528
|
+
setup_opts = @spec.dig("prepareAuth", "DEF", "setup", "a")
|
|
545
529
|
auth_client = ProjectNameSDK.test(nil, setup_opts)
|
|
546
|
-
auth_utility = auth_client.get_utility
|
|
547
|
-
|
|
548
|
-
runset(get_spec(@primary, "prepareAuth", "basic")) do |entry|
|
|
549
|
-
ctxmap = entry["ctx"] || {}
|
|
550
|
-
ctx = make_ctx_from_map(ctxmap, auth_client, auth_utility)
|
|
551
|
-
fixctx(ctx, auth_client)
|
|
552
|
-
|
|
553
|
-
_, err = @utility.prepare_auth.call(ctx)
|
|
554
|
-
raise err if err
|
|
555
|
-
|
|
556
|
-
# Update entry ctx for match
|
|
557
|
-
entry_ctx = entry["ctx"]
|
|
558
|
-
if entry_ctx.is_a?(Hash) && ctx.spec
|
|
559
|
-
entry_ctx["spec"] = {
|
|
560
|
-
"headers" => ctx.spec.headers,
|
|
561
|
-
}
|
|
562
|
-
end
|
|
563
530
|
|
|
564
|
-
|
|
531
|
+
subject = lambda do |ctx|
|
|
532
|
+
ctx.client = auth_client
|
|
533
|
+
unwrap(@utility.prepare_auth.call(ctx))
|
|
565
534
|
end
|
|
535
|
+
|
|
536
|
+
runsection("prepareAuth", subject)
|
|
566
537
|
end
|
|
567
538
|
|
|
568
539
|
|
|
569
540
|
# === prepareBody ===
|
|
570
541
|
|
|
571
542
|
def test_prepare_body_basic
|
|
572
|
-
|
|
573
|
-
ctxmap = entry["ctx"] || {}
|
|
574
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
575
|
-
fixctx(ctx, @client)
|
|
576
|
-
@utility.prepare_body.call(ctx)
|
|
577
|
-
end
|
|
543
|
+
runsection("prepareBody", ->(ctx) { @utility.prepare_body.call(ctx) })
|
|
578
544
|
end
|
|
579
545
|
|
|
580
546
|
|
|
581
547
|
# === prepareHeaders ===
|
|
582
548
|
|
|
583
549
|
def test_prepare_headers_basic
|
|
584
|
-
|
|
585
|
-
ctxmap = entry["ctx"] || {}
|
|
586
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
587
|
-
@utility.prepare_headers.call(ctx)
|
|
588
|
-
end
|
|
550
|
+
runsection("prepareHeaders", ->(ctx) { @utility.prepare_headers.call(ctx) })
|
|
589
551
|
end
|
|
590
552
|
|
|
591
553
|
|
|
592
554
|
# === prepareMethod ===
|
|
593
555
|
|
|
594
556
|
def test_prepare_method_basic
|
|
595
|
-
|
|
596
|
-
ctxmap = entry["ctx"] || {}
|
|
597
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
598
|
-
@utility.prepare_method.call(ctx)
|
|
599
|
-
end
|
|
557
|
+
runsection("prepareMethod", ->(ctx) { @utility.prepare_method.call(ctx) })
|
|
600
558
|
end
|
|
601
559
|
|
|
602
560
|
|
|
603
561
|
# === prepareParams ===
|
|
604
562
|
|
|
605
563
|
def test_prepare_params_basic
|
|
606
|
-
|
|
607
|
-
ctxmap = entry["ctx"] || {}
|
|
608
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
609
|
-
@utility.prepare_params.call(ctx)
|
|
610
|
-
end
|
|
564
|
+
runsection("prepareParams", ->(ctx) { @utility.prepare_params.call(ctx) })
|
|
611
565
|
end
|
|
612
566
|
|
|
613
567
|
|
|
614
568
|
# === preparePath ===
|
|
615
569
|
|
|
616
570
|
def test_prepare_path_basic
|
|
617
|
-
|
|
618
|
-
# (the preparePath fixture shipped as an empty `set: []`).
|
|
619
|
-
runset(get_spec(@primary, "preparePath", "basic")) do |entry|
|
|
620
|
-
ctxmap = entry["ctx"] || {}
|
|
621
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
622
|
-
@utility.prepare_path.call(ctx)
|
|
623
|
-
end
|
|
571
|
+
runsection("preparePath", ->(ctx) { @utility.prepare_path.call(ctx) })
|
|
624
572
|
end
|
|
625
573
|
|
|
626
574
|
def test_prepare_path_single
|
|
@@ -638,329 +586,57 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
638
586
|
# === prepareQuery ===
|
|
639
587
|
|
|
640
588
|
def test_prepare_query_basic
|
|
641
|
-
|
|
642
|
-
ctxmap = entry["ctx"] || {}
|
|
643
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
644
|
-
@utility.prepare_query.call(ctx)
|
|
645
|
-
end
|
|
589
|
+
runsection("prepareQuery", ->(ctx) { @utility.prepare_query.call(ctx) })
|
|
646
590
|
end
|
|
647
591
|
|
|
648
592
|
|
|
649
593
|
# === resultBasic ===
|
|
650
594
|
|
|
651
595
|
def test_result_basic_basic
|
|
652
|
-
|
|
653
|
-
ctxmap = entry["ctx"] || {}
|
|
654
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
655
|
-
fixctx(ctx, @client)
|
|
656
|
-
|
|
596
|
+
subject = lambda do |ctx|
|
|
657
597
|
result = @utility.result_basic.call(ctx)
|
|
658
|
-
|
|
659
598
|
out = {
|
|
660
599
|
"status" => result.status,
|
|
661
600
|
"statusText" => result.status_text,
|
|
662
601
|
}
|
|
663
|
-
if result.err
|
|
664
|
-
out["err"] = {
|
|
665
|
-
"message" => result.err.to_s,
|
|
666
|
-
}
|
|
667
|
-
end
|
|
668
|
-
|
|
602
|
+
out["err"] = { "message" => result.err.to_s } if result.err
|
|
669
603
|
out
|
|
670
604
|
end
|
|
605
|
+
|
|
606
|
+
runsection("resultBasic", subject)
|
|
671
607
|
end
|
|
672
608
|
|
|
673
609
|
|
|
674
610
|
# === resultBody ===
|
|
675
611
|
|
|
676
612
|
def test_result_body_basic
|
|
677
|
-
|
|
678
|
-
ctxmap = entry["ctx"] || {}
|
|
679
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
680
|
-
|
|
681
|
-
@utility.result_body.call(ctx)
|
|
682
|
-
|
|
683
|
-
# Update entry ctx for match
|
|
684
|
-
entry_ctx = entry["ctx"]
|
|
685
|
-
if entry_ctx.is_a?(Hash) && ctx.result
|
|
686
|
-
entry_ctx["result"] = {
|
|
687
|
-
"body" => ctx.result.body,
|
|
688
|
-
}
|
|
689
|
-
end
|
|
690
|
-
|
|
691
|
-
nil
|
|
692
|
-
end
|
|
613
|
+
runsection("resultBody", ->(ctx) { @utility.result_body.call(ctx) })
|
|
693
614
|
end
|
|
694
615
|
|
|
695
616
|
|
|
696
617
|
# === resultHeaders ===
|
|
697
618
|
|
|
698
619
|
def test_result_headers_basic
|
|
699
|
-
|
|
700
|
-
ctxmap = entry["ctx"] || {}
|
|
701
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
702
|
-
|
|
703
|
-
@utility.result_headers.call(ctx)
|
|
704
|
-
|
|
705
|
-
# Update entry ctx for match
|
|
706
|
-
entry_ctx = entry["ctx"]
|
|
707
|
-
if entry_ctx.is_a?(Hash) && ctx.result
|
|
708
|
-
entry_ctx["result"] = {
|
|
709
|
-
"headers" => ctx.result.headers,
|
|
710
|
-
}
|
|
711
|
-
end
|
|
712
|
-
|
|
713
|
-
nil
|
|
714
|
-
end
|
|
620
|
+
runsection("resultHeaders", ->(ctx) { @utility.result_headers.call(ctx) })
|
|
715
621
|
end
|
|
716
622
|
|
|
717
623
|
|
|
718
624
|
# === transformRequest ===
|
|
719
625
|
|
|
720
626
|
def test_transform_request_basic
|
|
721
|
-
|
|
722
|
-
ctxmap = entry["ctx"] || {}
|
|
723
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
724
|
-
|
|
725
|
-
result = @utility.transform_request.call(ctx)
|
|
726
|
-
|
|
727
|
-
# Update entry ctx for match (step changed)
|
|
728
|
-
entry_ctx = entry["ctx"]
|
|
729
|
-
if entry_ctx.is_a?(Hash) && ctx.spec
|
|
730
|
-
spec_map = entry_ctx["spec"]
|
|
731
|
-
spec_map["step"] = ctx.spec.step if spec_map.is_a?(Hash)
|
|
732
|
-
end
|
|
733
|
-
|
|
734
|
-
result
|
|
735
|
-
end
|
|
627
|
+
runsection("transformRequest", ->(ctx) { @utility.transform_request.call(ctx) })
|
|
736
628
|
end
|
|
737
629
|
|
|
738
630
|
|
|
739
631
|
# === transformResponse ===
|
|
740
632
|
|
|
741
633
|
def test_transform_response_basic
|
|
742
|
-
|
|
743
|
-
ctxmap = entry["ctx"] || {}
|
|
744
|
-
ctx = make_ctx_from_map(ctxmap, @client, @utility)
|
|
745
|
-
|
|
746
|
-
result = @utility.transform_response.call(ctx)
|
|
747
|
-
|
|
748
|
-
# Update entry ctx for match (step changed)
|
|
749
|
-
entry_ctx = entry["ctx"]
|
|
750
|
-
if entry_ctx.is_a?(Hash) && ctx.spec
|
|
751
|
-
spec_map = entry_ctx["spec"]
|
|
752
|
-
spec_map["step"] = ctx.spec.step if spec_map.is_a?(Hash)
|
|
753
|
-
end
|
|
754
|
-
|
|
755
|
-
result
|
|
756
|
-
end
|
|
634
|
+
runsection("transformResponse", ->(ctx) { @utility.transform_response.call(ctx) })
|
|
757
635
|
end
|
|
758
636
|
|
|
759
637
|
|
|
760
638
|
private
|
|
761
639
|
|
|
762
|
-
# === Helper: load test spec ===
|
|
763
|
-
def load_test_spec
|
|
764
|
-
path = File.join(__dir__, '../../.sdk/test/test.json')
|
|
765
|
-
data = File.read(path)
|
|
766
|
-
JSON.parse(data)
|
|
767
|
-
end
|
|
768
|
-
|
|
769
|
-
# === Helper: get nested spec ===
|
|
770
|
-
def get_spec(spec, *keys)
|
|
771
|
-
cur = spec
|
|
772
|
-
keys.each do |key|
|
|
773
|
-
return nil unless cur.is_a?(Hash)
|
|
774
|
-
cur = cur[key]
|
|
775
|
-
end
|
|
776
|
-
cur.is_a?(Hash) ? cur : nil
|
|
777
|
-
end
|
|
778
|
-
|
|
779
|
-
# === Helper: runset ===
|
|
780
|
-
def runset(testspec, &subject)
|
|
781
|
-
return unless testspec
|
|
782
|
-
set = testspec["set"]
|
|
783
|
-
return unless set.is_a?(Array)
|
|
784
|
-
|
|
785
|
-
set.each_with_index do |entry, i|
|
|
786
|
-
next unless entry.is_a?(Hash)
|
|
787
|
-
|
|
788
|
-
mark = entry["mark"] ? " (mark=#{entry["mark"]})" : ""
|
|
789
|
-
|
|
790
|
-
begin
|
|
791
|
-
result, err = subject.call(entry)
|
|
792
|
-
|
|
793
|
-
expected_err = entry["err"]
|
|
794
|
-
|
|
795
|
-
if err
|
|
796
|
-
if expected_err
|
|
797
|
-
err_msg = err.to_s
|
|
798
|
-
if expected_err.is_a?(String)
|
|
799
|
-
unless match_string(expected_err, err_msg)
|
|
800
|
-
flunk "entry #{i}#{mark}: error mismatch: got #{err_msg.inspect}, want contains #{expected_err.inspect}"
|
|
801
|
-
end
|
|
802
|
-
elsif expected_err == true
|
|
803
|
-
# err: true means any error is acceptable
|
|
804
|
-
end
|
|
805
|
-
if entry["match"].is_a?(Hash)
|
|
806
|
-
result_map = {
|
|
807
|
-
"in" => entry["in"],
|
|
808
|
-
"out" => json_normalize(result),
|
|
809
|
-
"err" => { "message" => err.to_s },
|
|
810
|
-
}
|
|
811
|
-
match_deep(i, mark, entry["match"], result_map, "")
|
|
812
|
-
end
|
|
813
|
-
next
|
|
814
|
-
end
|
|
815
|
-
flunk "entry #{i}#{mark}: unexpected error: #{err}"
|
|
816
|
-
next
|
|
817
|
-
end
|
|
818
|
-
|
|
819
|
-
if expected_err
|
|
820
|
-
flunk "entry #{i}#{mark}: expected error containing #{expected_err.inspect} but got result: #{json_str(result)}"
|
|
821
|
-
next
|
|
822
|
-
end
|
|
823
|
-
|
|
824
|
-
matched = false
|
|
825
|
-
if entry["match"].is_a?(Hash)
|
|
826
|
-
result_map = {
|
|
827
|
-
"in" => entry["in"],
|
|
828
|
-
"out" => json_normalize(result),
|
|
829
|
-
}
|
|
830
|
-
if entry["args"]
|
|
831
|
-
result_map["args"] = entry["args"]
|
|
832
|
-
elsif entry["in"]
|
|
833
|
-
result_map["args"] = [entry["in"]]
|
|
834
|
-
end
|
|
835
|
-
result_map["ctx"] = entry["ctx"] if entry["ctx"]
|
|
836
|
-
match_deep(i, mark, entry["match"], result_map, "")
|
|
837
|
-
matched = true
|
|
838
|
-
end
|
|
839
|
-
|
|
840
|
-
expected_out = entry["out"]
|
|
841
|
-
next if expected_out.nil? && matched
|
|
842
|
-
|
|
843
|
-
if expected_out
|
|
844
|
-
norm_result = json_normalize(result)
|
|
845
|
-
norm_expected = json_normalize(expected_out)
|
|
846
|
-
unless deep_equal(norm_result, norm_expected)
|
|
847
|
-
flunk "entry #{i}#{mark}: output mismatch:\n got: #{json_str(norm_result)}\n want: #{json_str(norm_expected)}"
|
|
848
|
-
end
|
|
849
|
-
end
|
|
850
|
-
|
|
851
|
-
rescue => e
|
|
852
|
-
expected_err = entry["err"]
|
|
853
|
-
if expected_err
|
|
854
|
-
err_msg = e.to_s
|
|
855
|
-
if expected_err.is_a?(String)
|
|
856
|
-
unless match_string(expected_err, err_msg)
|
|
857
|
-
flunk "entry #{i}#{mark}: error mismatch: got #{err_msg.inspect}, want contains #{expected_err.inspect}"
|
|
858
|
-
end
|
|
859
|
-
elsif expected_err == true
|
|
860
|
-
# err: true means any error is acceptable
|
|
861
|
-
end
|
|
862
|
-
if entry["match"].is_a?(Hash)
|
|
863
|
-
result_map = {
|
|
864
|
-
"in" => entry["in"],
|
|
865
|
-
"out" => json_normalize(nil),
|
|
866
|
-
"err" => { "message" => e.to_s },
|
|
867
|
-
}
|
|
868
|
-
match_deep(i, mark, entry["match"], result_map, "")
|
|
869
|
-
end
|
|
870
|
-
next
|
|
871
|
-
end
|
|
872
|
-
raise
|
|
873
|
-
end
|
|
874
|
-
end
|
|
875
|
-
end
|
|
876
|
-
|
|
877
|
-
# === Helper: json_normalize ===
|
|
878
|
-
def json_normalize(val)
|
|
879
|
-
return nil if val.nil?
|
|
880
|
-
j = JSON.generate(val)
|
|
881
|
-
JSON.parse(j)
|
|
882
|
-
rescue
|
|
883
|
-
val
|
|
884
|
-
end
|
|
885
|
-
|
|
886
|
-
# === Helper: json_str ===
|
|
887
|
-
def json_str(val)
|
|
888
|
-
JSON.generate(val)
|
|
889
|
-
rescue
|
|
890
|
-
val.to_s
|
|
891
|
-
end
|
|
892
|
-
|
|
893
|
-
# === Helper: match_deep ===
|
|
894
|
-
def match_deep(entry_idx, mark, check, base, path)
|
|
895
|
-
return if check.nil?
|
|
896
|
-
|
|
897
|
-
if check.is_a?(Hash)
|
|
898
|
-
check.each do |key, check_val|
|
|
899
|
-
child_path = "#{path}.#{key}"
|
|
900
|
-
base_val = base.is_a?(Hash) ? base[key] : nil
|
|
901
|
-
match_deep(entry_idx, mark, check_val, base_val, child_path)
|
|
902
|
-
end
|
|
903
|
-
elsif check.is_a?(Array)
|
|
904
|
-
check.each_with_index do |check_val, ci|
|
|
905
|
-
child_path = "#{path}[#{ci}]"
|
|
906
|
-
base_val = (base.is_a?(Array) && ci < base.length) ? base[ci] : nil
|
|
907
|
-
match_deep(entry_idx, mark, check_val, base_val, child_path)
|
|
908
|
-
end
|
|
909
|
-
else
|
|
910
|
-
if check.is_a?(String) && check == "__EXISTS__"
|
|
911
|
-
if base.nil?
|
|
912
|
-
flunk "entry #{entry_idx}#{mark}: match #{path}: expected value to exist but got nil"
|
|
913
|
-
end
|
|
914
|
-
return
|
|
915
|
-
end
|
|
916
|
-
if check.is_a?(String) && check == "__UNDEF__"
|
|
917
|
-
if base != nil
|
|
918
|
-
flunk "entry #{entry_idx}#{mark}: match #{path}: expected nil but got #{base.inspect}"
|
|
919
|
-
end
|
|
920
|
-
return
|
|
921
|
-
end
|
|
922
|
-
|
|
923
|
-
norm_check = json_normalize(check)
|
|
924
|
-
norm_base = json_normalize(base)
|
|
925
|
-
|
|
926
|
-
unless deep_equal(norm_check, norm_base)
|
|
927
|
-
if check.is_a?(String) && !check.empty?
|
|
928
|
-
base_str = base.nil? ? "" : base.to_s
|
|
929
|
-
return if match_string(check, base_str)
|
|
930
|
-
end
|
|
931
|
-
flunk "entry #{entry_idx}#{mark}: match #{path}: got #{json_str(norm_base)}, want #{json_str(norm_check)}"
|
|
932
|
-
end
|
|
933
|
-
end
|
|
934
|
-
end
|
|
935
|
-
|
|
936
|
-
# === Helper: match_string ===
|
|
937
|
-
def match_string(pattern, val)
|
|
938
|
-
if pattern.length >= 2 && pattern[0] == '/' && pattern[-1] == '/'
|
|
939
|
-
re = Regexp.new(pattern[1..-2])
|
|
940
|
-
return re.match?(val)
|
|
941
|
-
end
|
|
942
|
-
val.downcase.include?(pattern.downcase)
|
|
943
|
-
end
|
|
944
|
-
|
|
945
|
-
# === Helper: deep_equal ===
|
|
946
|
-
def deep_equal(a, b)
|
|
947
|
-
normalize = lambda { |v|
|
|
948
|
-
case v
|
|
949
|
-
when Hash
|
|
950
|
-
sorted = {}
|
|
951
|
-
v.keys.sort.each { |k| sorted[k] = normalize.call(v[k]) }
|
|
952
|
-
sorted
|
|
953
|
-
when Array
|
|
954
|
-
v.map { |e| normalize.call(e) }
|
|
955
|
-
else
|
|
956
|
-
v
|
|
957
|
-
end
|
|
958
|
-
}
|
|
959
|
-
JSON.generate(normalize.call(a)) == JSON.generate(normalize.call(b))
|
|
960
|
-
rescue
|
|
961
|
-
a == b
|
|
962
|
-
end
|
|
963
|
-
|
|
964
640
|
# === Helper: make_test_ctx ===
|
|
965
641
|
def make_test_ctx(client, utility, overrides)
|
|
966
642
|
ctxmap = {
|
|
@@ -990,68 +666,6 @@ class PrimaryUtilityTest < Minitest::Test
|
|
|
990
666
|
ctx.reqmatch = { "id" => "item01" }
|
|
991
667
|
ctx
|
|
992
668
|
end
|
|
993
|
-
|
|
994
|
-
# === Helper: make_ctx_from_map ===
|
|
995
|
-
def make_ctx_from_map(ctxmap, client, utility)
|
|
996
|
-
ctxmap = {} unless ctxmap.is_a?(Hash)
|
|
997
|
-
|
|
998
|
-
ctx = ProjectNameContext.new(ctxmap, nil)
|
|
999
|
-
|
|
1000
|
-
if client
|
|
1001
|
-
ctx.client = client
|
|
1002
|
-
ctx.utility = utility
|
|
1003
|
-
end
|
|
1004
|
-
if ctx.options.nil? && client
|
|
1005
|
-
ctx.options = client.options_map
|
|
1006
|
-
end
|
|
1007
|
-
|
|
1008
|
-
# Handle spec from JSON map
|
|
1009
|
-
if ctxmap["spec"].is_a?(Hash)
|
|
1010
|
-
ctx.spec = ProjectNameSpec.new(ctxmap["spec"])
|
|
1011
|
-
end
|
|
1012
|
-
|
|
1013
|
-
# Handle result from JSON map
|
|
1014
|
-
if ctxmap["result"].is_a?(Hash)
|
|
1015
|
-
res_map = ctxmap["result"]
|
|
1016
|
-
ctx.result = ProjectNameResult.new(res_map)
|
|
1017
|
-
if res_map["err"].is_a?(Hash) && res_map["err"]["message"].is_a?(String)
|
|
1018
|
-
ctx.result.err = ProjectNameError.new("", res_map["err"]["message"])
|
|
1019
|
-
end
|
|
1020
|
-
end
|
|
1021
|
-
|
|
1022
|
-
# Handle response from JSON map
|
|
1023
|
-
if ctxmap["response"].is_a?(Hash)
|
|
1024
|
-
resp_map = ctxmap["response"]
|
|
1025
|
-
ctx.response = ProjectNameResponse.new(resp_map)
|
|
1026
|
-
if resp_map["body"]
|
|
1027
|
-
body_copy = resp_map["body"]
|
|
1028
|
-
ctx.response.json_func = -> { body_copy }
|
|
1029
|
-
end
|
|
1030
|
-
if resp_map["headers"].is_a?(Hash)
|
|
1031
|
-
lower_headers = {}
|
|
1032
|
-
resp_map["headers"].each { |k, v| lower_headers[k.downcase] = v }
|
|
1033
|
-
ctx.response.headers = lower_headers
|
|
1034
|
-
end
|
|
1035
|
-
end
|
|
1036
|
-
|
|
1037
|
-
ctx
|
|
1038
|
-
end
|
|
1039
|
-
|
|
1040
|
-
# === Helper: fixctx ===
|
|
1041
|
-
def fixctx(ctx, client)
|
|
1042
|
-
if ctx && ctx.client && ctx.options.nil?
|
|
1043
|
-
ctx.options = ctx.client.options_map
|
|
1044
|
-
end
|
|
1045
|
-
end
|
|
1046
|
-
|
|
1047
|
-
# === Helper: err_from_map ===
|
|
1048
|
-
def err_from_map(m)
|
|
1049
|
-
return nil unless m.is_a?(Hash)
|
|
1050
|
-
msg = m["message"]
|
|
1051
|
-
return nil unless msg.is_a?(String) && !msg.empty?
|
|
1052
|
-
code = m["code"] || ""
|
|
1053
|
-
ProjectNameError.new(code, msg)
|
|
1054
|
-
end
|
|
1055
669
|
end
|
|
1056
670
|
|
|
1057
671
|
|