@voxgig/sdkgen 4.34.6 → 4.34.7
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/package.json +1 -1
- package/project/.sdk/src/cmp/py-data/Main_py-data.ts +13 -5
- package/project/.sdk/src/cmp/zig/utility_zig.ts +19 -8
- package/project/.sdk/tm/cpp/test/pipeline_test.cpp +4 -4
- package/project/.sdk/tm/csharp/test/PipelineTest.cs +4 -4
- package/project/.sdk/tm/elixir/test/feature/secrets/secrets_test.exs +11 -1
- package/project/.sdk/tm/kotlin/test/PipelineTest.kt +4 -4
- package/project/.sdk/tm/kotlin/test/feature/secrets/SecretsTest.kt +1 -1
- package/project/.sdk/tm/lua/test/feature/secrets/secrets_feature_test.lua +6 -2
- package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +4 -3
- package/project/.sdk/tm/perl/t/feature/secrets/secrets.t +8 -0
- package/project/.sdk/tm/perl/t/runner.pm +6 -4
- package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +3 -1
- package/project/.sdk/tm/rust/tests/pipeline_test.rs +4 -4
- package/project/.sdk/tm/scala/sdktest/feature/secrets/SecretsTestMain.scala +7 -2
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PipelineTest.swift +4 -4
- package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +12 -8
- package/project/sdkgen-package.json +1 -1
package/bin/voxgig-sdkgen
CHANGED
package/package.json
CHANGED
|
@@ -486,6 +486,13 @@ const EntityFramesTest = cmp(function EntityFramesTest(props: any) {
|
|
|
486
486
|
const accessors = frameEnts.map((e: any) => pluralAccessor(e))
|
|
487
487
|
const singles = seriesEnts.map((e: any) => singularAccessor(e))
|
|
488
488
|
|
|
489
|
+
// The test-mode cases call an accessor with no match, so they need one whose
|
|
490
|
+
// list route names no parent.
|
|
491
|
+
const vals = (x: any): any[] => null == x ? [] : Array.isArray(x) ? x : Object.values(x)
|
|
492
|
+
const unrouted = frameEnts.find((e: any) => vals(e.op?.list?.points).some((pt: any) =>
|
|
493
|
+
null != pt && false !== pt.a && 0 === vals(pt.g?.params).filter((p: any) => null != p && false !== p.a).length))
|
|
494
|
+
const testAccessor = unrouted ? pluralAccessor(unrouted) : null
|
|
495
|
+
|
|
489
496
|
File({ name: 'test/test_entity_frames.py' }, () => Content(
|
|
490
497
|
`# Generated accessor tests.
|
|
491
498
|
#
|
|
@@ -503,6 +510,7 @@ from ${dataModule}.entity_frames import EntityFrames
|
|
|
503
510
|
|
|
504
511
|
FRAME_ACCESSORS = ${pyList(accessors)}
|
|
505
512
|
SERIES_ACCESSORS = ${pyList(singles)}
|
|
513
|
+
TEST_ACCESSOR = ${null == testAccessor ? 'None' : JSON.stringify(testAccessor)}
|
|
506
514
|
|
|
507
515
|
|
|
508
516
|
class TestAccessorSurface:
|
|
@@ -531,8 +539,8 @@ class TestAccessorSurface:
|
|
|
531
539
|
f"accessor {a} would shadow the client surface"
|
|
532
540
|
|
|
533
541
|
|
|
534
|
-
@pytest.mark.skipif(
|
|
535
|
-
reason="this API exposes no list
|
|
542
|
+
@pytest.mark.skipif(TEST_ACCESSOR is None,
|
|
543
|
+
reason="this API exposes no list operation without a parent")
|
|
536
544
|
class TestFramesAgainstTestMode:
|
|
537
545
|
|
|
538
546
|
def _client(self):
|
|
@@ -541,20 +549,20 @@ class TestFramesAgainstTestMode:
|
|
|
541
549
|
|
|
542
550
|
def test_first_frame_accessor_returns_a_dataframe(self):
|
|
543
551
|
ad = self._client()
|
|
544
|
-
df = getattr(ad,
|
|
552
|
+
df = getattr(ad, TEST_ACCESSOR)(quiet=True)
|
|
545
553
|
assert isinstance(df, pd.DataFrame)
|
|
546
554
|
|
|
547
555
|
def test_declared_columns_have_their_model_dtypes(self):
|
|
548
556
|
# Any column the model declared AND the API returned must carry the
|
|
549
557
|
# model's dtype — this is what makes groupby/merge behave.
|
|
550
558
|
ad = self._client()
|
|
551
|
-
df = getattr(ad,
|
|
559
|
+
df = getattr(ad, TEST_ACCESSOR)(quiet=True)
|
|
552
560
|
for col in df.columns:
|
|
553
561
|
assert str(df[col].dtype) != "float64" or True # dtypes applied
|
|
554
562
|
|
|
555
563
|
def test_limit_is_respected(self):
|
|
556
564
|
ad = self._client()
|
|
557
|
-
df = getattr(ad,
|
|
565
|
+
df = getattr(ad, TEST_ACCESSOR)(limit=1, quiet=True)
|
|
558
566
|
assert len(df) <= 1
|
|
559
567
|
`))
|
|
560
568
|
})
|
|
@@ -26,23 +26,34 @@ function zigVarName(name: string): string {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
// A name zig would refuse as too long keeps its head and gains a hash of the whole.
|
|
30
|
+
const ZIG_NAME_MAX = 32
|
|
31
|
+
|
|
32
|
+
|
|
29
33
|
function zigModuleName(model: any): string {
|
|
30
|
-
const
|
|
31
|
-
|
|
34
|
+
const snake = `${model.name}_sdk`.toLowerCase().replace(/[^a-z0-9_]/g, '_')
|
|
35
|
+
const name = /^[0-9]/.test(snake) ? '_' + snake : snake
|
|
36
|
+
return name.length <= ZIG_NAME_MAX ? name :
|
|
37
|
+
name.slice(0, ZIG_NAME_MAX - 9) + '_' + crc32(name).toString(16).padStart(8, '0')
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
// CRC-32 (IEEE 802.3, reflected, poly 0xEDB88320) — the one zig's
|
|
42
|
+
// std.hash.Crc32 and zlib both compute.
|
|
43
|
+
function crc32(text: string): number {
|
|
38
44
|
let crc = 0xffffffff
|
|
39
|
-
for (let i = 0; i <
|
|
40
|
-
crc ^=
|
|
45
|
+
for (let i = 0; i < text.length; i++) {
|
|
46
|
+
crc ^= text.charCodeAt(i) & 0xff
|
|
41
47
|
for (let b = 0; b < 8; b++) {
|
|
42
48
|
crc = (crc >>> 1) ^ (0xedb88320 & -(crc & 1))
|
|
43
49
|
}
|
|
44
50
|
}
|
|
45
|
-
|
|
51
|
+
return (crc ^ 0xffffffff) >>> 0
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
function zigPackageFingerprint(name: string): string {
|
|
56
|
+
const checksum = crc32(name)
|
|
46
57
|
|
|
47
58
|
// FNV-1a 32-bit, folded into the 1..0xfffffffe zig accepts.
|
|
48
59
|
let fnv = 0x811c9dc5
|
|
@@ -390,7 +390,7 @@ static void prepareAuth_guardsMissingSpec() {
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
static void prepareAuth_apikeyWithPrefixSpaceJoined() {
|
|
393
|
-
auto client = plClient(fhMap({{"apikey", Value("K")}, {"auth", fhMap({{"prefix", Value("Bearer")}})}}));
|
|
393
|
+
auto client = plClient(fhMap({{"apikey", Value("K")}, {"auth", fhMap({{"prefix", Value("Bearer")}, {"basic", Value(false)}})}}));
|
|
394
394
|
UtilityPtr utility = client->getUtility();
|
|
395
395
|
CtxPtr ctx = plCtx(client, utility, Value::undef());
|
|
396
396
|
ctx->spec = authSpec(Value::undef());
|
|
@@ -399,7 +399,7 @@ static void prepareAuth_apikeyWithPrefixSpaceJoined() {
|
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
static void prepareAuth_rawApikeyEmptyPrefixAsIs() {
|
|
402
|
-
auto client = plClient(fhMap({{"apikey", Value("K")}, {"auth", fhMap({{"prefix", Value("")}})}}));
|
|
402
|
+
auto client = plClient(fhMap({{"apikey", Value("K")}, {"auth", fhMap({{"prefix", Value("")}, {"basic", Value(false)}})}}));
|
|
403
403
|
UtilityPtr utility = client->getUtility();
|
|
404
404
|
CtxPtr ctx = plCtx(client, utility, Value::undef());
|
|
405
405
|
ctx->spec = authSpec(Value::undef());
|
|
@@ -408,7 +408,7 @@ static void prepareAuth_rawApikeyEmptyPrefixAsIs() {
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
static void prepareAuth_emptyApikeyDropsHeader() {
|
|
411
|
-
auto client = plClient(fhMap({{"apikey", Value("")}, {"auth", fhMap({{"prefix", Value("Bearer")}})}}));
|
|
411
|
+
auto client = plClient(fhMap({{"apikey", Value("")}, {"auth", fhMap({{"prefix", Value("Bearer")}, {"basic", Value(false)}})}}));
|
|
412
412
|
UtilityPtr utility = client->getUtility();
|
|
413
413
|
CtxPtr ctx = plCtx(client, utility, Value::undef());
|
|
414
414
|
ctx->spec = authSpec(fhMap({{"authorization", Value("stale")}}));
|
|
@@ -417,7 +417,7 @@ static void prepareAuth_emptyApikeyDropsHeader() {
|
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
static void prepareAuth_missingApikeyDropsHeader() {
|
|
420
|
-
auto client = plClient(fhMap({{"auth", fhMap({{"prefix", Value("Bearer")}})}}));
|
|
420
|
+
auto client = plClient(fhMap({{"auth", fhMap({{"prefix", Value("Bearer")}, {"basic", Value(false)}})}}));
|
|
421
421
|
Value options = client->optionsMap();
|
|
422
422
|
Value apikey = getp(options, "apikey");
|
|
423
423
|
if (apikey.is_string() && !apikey.as_string().empty()) {
|
|
@@ -559,7 +559,7 @@ public class PipelineTest
|
|
|
559
559
|
var (client, utility) = PlClient(new Dictionary<string, object?>
|
|
560
560
|
{
|
|
561
561
|
["apikey"] = "K",
|
|
562
|
-
["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer" },
|
|
562
|
+
["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer", ["basic"] = false },
|
|
563
563
|
});
|
|
564
564
|
var ctx = PlCtx(client, utility, null);
|
|
565
565
|
ctx.Spec = AuthSpec(null);
|
|
@@ -573,7 +573,7 @@ public class PipelineTest
|
|
|
573
573
|
var (client, utility) = PlClient(new Dictionary<string, object?>
|
|
574
574
|
{
|
|
575
575
|
["apikey"] = "K",
|
|
576
|
-
["auth"] = new Dictionary<string, object?> { ["prefix"] = "" },
|
|
576
|
+
["auth"] = new Dictionary<string, object?> { ["prefix"] = "", ["basic"] = false },
|
|
577
577
|
});
|
|
578
578
|
var ctx = PlCtx(client, utility, null);
|
|
579
579
|
ctx.Spec = AuthSpec(null);
|
|
@@ -587,7 +587,7 @@ public class PipelineTest
|
|
|
587
587
|
var (client, utility) = PlClient(new Dictionary<string, object?>
|
|
588
588
|
{
|
|
589
589
|
["apikey"] = "",
|
|
590
|
-
["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer" },
|
|
590
|
+
["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer", ["basic"] = false },
|
|
591
591
|
});
|
|
592
592
|
var ctx = PlCtx(client, utility, null);
|
|
593
593
|
ctx.Spec = AuthSpec(new Dictionary<string, object?>
|
|
@@ -604,7 +604,7 @@ public class PipelineTest
|
|
|
604
604
|
{
|
|
605
605
|
var (client, utility) = PlClient(new Dictionary<string, object?>
|
|
606
606
|
{
|
|
607
|
-
["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer" },
|
|
607
|
+
["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer", ["basic"] = false },
|
|
608
608
|
});
|
|
609
609
|
var options = client.OptionsMap();
|
|
610
610
|
if (options.TryGetValue("apikey", out var apikey) &&
|
|
@@ -1066,7 +1066,8 @@ defmodule ProjectName.SecretsTest do
|
|
|
1066
1066
|
nil
|
|
1067
1067
|
else
|
|
1068
1068
|
Enum.find_value(S.keysof(ents), fn name ->
|
|
1069
|
-
if S.ismap(S.getpath(ents, name <> ".op.list"))
|
|
1069
|
+
if S.ismap(S.getpath(ents, name <> ".op.list")) and
|
|
1070
|
+
unrouted?(S.getpath(ents, name <> ".op.list.points")) do
|
|
1070
1071
|
factory = existing_atom(name)
|
|
1071
1072
|
|
|
1072
1073
|
if factory != nil and
|
|
@@ -1083,6 +1084,15 @@ defmodule ProjectName.SecretsTest do
|
|
|
1083
1084
|
end
|
|
1084
1085
|
end
|
|
1085
1086
|
|
|
1087
|
+
# A list called with no match can take only a route naming no path parameter.
|
|
1088
|
+
defp unrouted?(points) do
|
|
1089
|
+
is_list(points) and
|
|
1090
|
+
Enum.any?(points, fn pt ->
|
|
1091
|
+
params = S.getpath(pt, "args.params")
|
|
1092
|
+
not is_list(params) or params == []
|
|
1093
|
+
end)
|
|
1094
|
+
end
|
|
1095
|
+
|
|
1086
1096
|
# Run an entity op and answer with its failure MESSAGE ("" when it
|
|
1087
1097
|
# succeeded). An entity op raises by default rather than returning its
|
|
1088
1098
|
# error, so a fail-closed assertion has to reach the message through the
|
|
@@ -495,7 +495,7 @@ class PipelineTest {
|
|
|
495
495
|
|
|
496
496
|
@Test
|
|
497
497
|
fun prepareAuth_apikeyWithPrefixSpaceJoined() {
|
|
498
|
-
val client = plClient(fhMap("apikey", "K", "auth", fhMap("prefix", "Bearer")))
|
|
498
|
+
val client = plClient(fhMap("apikey", "K", "auth", fhMap("prefix", "Bearer", "basic", false)))
|
|
499
499
|
val utility = client.getUtility()
|
|
500
500
|
val ctx = plCtx(client, utility, null)
|
|
501
501
|
ctx.spec = authSpec(null)
|
|
@@ -505,7 +505,7 @@ class PipelineTest {
|
|
|
505
505
|
|
|
506
506
|
@Test
|
|
507
507
|
fun prepareAuth_rawApikeyEmptyPrefixAsIs() {
|
|
508
|
-
val client = plClient(fhMap("apikey", "K", "auth", fhMap("prefix", "")))
|
|
508
|
+
val client = plClient(fhMap("apikey", "K", "auth", fhMap("prefix", "", "basic", false)))
|
|
509
509
|
val utility = client.getUtility()
|
|
510
510
|
val ctx = plCtx(client, utility, null)
|
|
511
511
|
ctx.spec = authSpec(null)
|
|
@@ -515,7 +515,7 @@ class PipelineTest {
|
|
|
515
515
|
|
|
516
516
|
@Test
|
|
517
517
|
fun prepareAuth_emptyApikeyDropsHeader() {
|
|
518
|
-
val client = plClient(fhMap("apikey", "", "auth", fhMap("prefix", "Bearer")))
|
|
518
|
+
val client = plClient(fhMap("apikey", "", "auth", fhMap("prefix", "Bearer", "basic", false)))
|
|
519
519
|
val utility = client.getUtility()
|
|
520
520
|
val ctx = plCtx(client, utility, null)
|
|
521
521
|
ctx.spec = authSpec(fhMap("authorization", "stale"))
|
|
@@ -525,7 +525,7 @@ class PipelineTest {
|
|
|
525
525
|
|
|
526
526
|
@Test
|
|
527
527
|
fun prepareAuth_missingApikeyDropsHeader() {
|
|
528
|
-
val client = plClient(fhMap("auth", fhMap("prefix", "Bearer")))
|
|
528
|
+
val client = plClient(fhMap("auth", fhMap("prefix", "Bearer", "basic", false)))
|
|
529
529
|
val options = client.optionsMap()
|
|
530
530
|
val apikey = options["apikey"]
|
|
531
531
|
if (apikey is String && "" != apikey) {
|
|
@@ -225,7 +225,7 @@ local function drive_entity_op_until(client, what, stop)
|
|
|
225
225
|
for _, opname in ipairs({ "list", "load" }) do
|
|
226
226
|
if type(ent[opname]) == "function" then
|
|
227
227
|
last_res, last_err = ent[opname](ent, { id = "id01" })
|
|
228
|
-
if stop() then return last_res, last_err end
|
|
228
|
+
if stop(last_res, last_err) then return last_res, last_err end
|
|
229
229
|
end
|
|
230
230
|
end
|
|
231
231
|
end
|
|
@@ -539,7 +539,11 @@ describe("secrets", function()
|
|
|
539
539
|
"expected sekreto's own message (" .. fragment .. "), got: " .. tostring(res.err))
|
|
540
540
|
assert.are.equal(0, #w.api(), "nothing may reach the wire")
|
|
541
541
|
|
|
542
|
-
|
|
542
|
+
-- An op whose route the call cannot fill fails before the chain is
|
|
543
|
+
-- consulted, so drive until one refuses with sekreto's message.
|
|
544
|
+
local err = drive_refusal(client, function(_, e)
|
|
545
|
+
return nil ~= e and nil ~= tostring(e):find(fragment, 1, true)
|
|
546
|
+
end)
|
|
543
547
|
assert.is_table(err, "the entity path must refuse too")
|
|
544
548
|
assert.is_truthy(tostring(err):find(fragment, 1, true), "got: " .. tostring(err))
|
|
545
549
|
assert.are.equal(0, #w.api())
|
|
@@ -288,9 +288,10 @@ let drive_entity (client : sdk_client) (r : recorder) : (unit, string) Stdlib.re
|
|
|
288
288
|
out := Ok ();
|
|
289
289
|
if before < List.length (api_calls r) then () else ops more
|
|
290
290
|
| exception Sdk_error_exc e ->
|
|
291
|
-
(* An op the entity does not define
|
|
292
|
-
*
|
|
293
|
-
|
|
291
|
+
(* An op the entity does not define, or a route the call
|
|
292
|
+
* cannot fill, fails before the chain is consulted: keep
|
|
293
|
+
* going. Anything else is the answer. *)
|
|
294
|
+
if e.err_code = "unsupported_op" || e.err_code = "url_param_missing" then ops more
|
|
294
295
|
else (out := Error e.err_msg)
|
|
295
296
|
| exception e -> out := Error (Printexc.to_string e))
|
|
296
297
|
in
|
|
@@ -209,7 +209,15 @@ sub listable_op {
|
|
|
209
209
|
my ($sdk) = @_;
|
|
210
210
|
my $entities = ProjectNameHelpers::to_map(
|
|
211
211
|
ProjectNameHelpers::gp($sdk->options_map, 'entity')) || {};
|
|
212
|
+
my $config = ProjectNameConfig::make_config();
|
|
212
213
|
for my $name (sort keys %$entities) {
|
|
214
|
+
# A list called with no match can take only a route naming no path
|
|
215
|
+
# parameter.
|
|
216
|
+
my $points = ProjectNameHelpers::gpath($config, "entity.$name.op.list.points");
|
|
217
|
+
next unless 'ARRAY' eq ref($points) && grep {
|
|
218
|
+
my $ps = 'HASH' eq ref($_) ? ProjectNameHelpers::gpath($_, 'args.params') : undef;
|
|
219
|
+
'ARRAY' ne ref($ps) || 0 == scalar(@$ps)
|
|
220
|
+
} @$points;
|
|
213
221
|
my $accessor = ucfirst($name);
|
|
214
222
|
next unless $sdk->can($accessor);
|
|
215
223
|
my $ent = eval { $sdk->$accessor() };
|
|
@@ -75,13 +75,15 @@ sub entity_list_to_data {
|
|
|
75
75
|
my ($list) = @_;
|
|
76
76
|
my $out = [];
|
|
77
77
|
for my $item (@{ $list || [] }) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
elsif (Scalar::Util::blessed($item) && $item->can('data_get')) {
|
|
78
|
+
# An entity is a blessed hash, which ismap also accepts, so it is asked
|
|
79
|
+
# for its data first.
|
|
80
|
+
if (Scalar::Util::blessed($item) && $item->can('data_get')) {
|
|
82
81
|
my $d = $item->data_get;
|
|
83
82
|
push @$out, $d if Voxgig::Struct::ismap($d);
|
|
84
83
|
}
|
|
84
|
+
elsif (Voxgig::Struct::ismap($item)) {
|
|
85
|
+
push @$out, $item;
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
88
|
return $out;
|
|
87
89
|
}
|
|
@@ -275,7 +275,9 @@ class ProjectNameSecretsTest extends TestCase
|
|
|
275
275
|
$this->driveUntil($client, 'returned an SDK error',
|
|
276
276
|
function () use (&$caught) { return $caught !== null; },
|
|
277
277
|
function (\Throwable $error) use (&$caught) {
|
|
278
|
-
|
|
278
|
+
// A call whose route it cannot fill is refused before the
|
|
279
|
+
// chain is consulted, so it is not the refusal under test.
|
|
280
|
+
if ($error instanceof ProjectNameError && 'url_param_missing' !== $error->sdk_code) {
|
|
279
281
|
$caught = $error;
|
|
280
282
|
}
|
|
281
283
|
});
|
|
@@ -599,7 +599,7 @@ fn pipeline_prepare_auth_guards_missing_spec() {
|
|
|
599
599
|
fn pipeline_prepare_auth_apikey_with_prefix_space_joined() {
|
|
600
600
|
let (client, utility) = pl_client(jo(vec![
|
|
601
601
|
("apikey", Value::str("K")),
|
|
602
|
-
("auth", jo(vec![("prefix", Value::str("Bearer"))])),
|
|
602
|
+
("auth", jo(vec![("prefix", Value::str("Bearer")), ("basic", Value::Bool(false))])),
|
|
603
603
|
]));
|
|
604
604
|
let ctx = pl_ctx(&client, &utility, None);
|
|
605
605
|
*ctx.spec.borrow_mut() = Some(auth_spec(Value::Noval));
|
|
@@ -613,7 +613,7 @@ fn pipeline_prepare_auth_apikey_with_prefix_space_joined() {
|
|
|
613
613
|
fn pipeline_prepare_auth_raw_apikey_empty_prefix_as_is() {
|
|
614
614
|
let (client, utility) = pl_client(jo(vec![
|
|
615
615
|
("apikey", Value::str("K")),
|
|
616
|
-
("auth", jo(vec![("prefix", Value::str(""))])),
|
|
616
|
+
("auth", jo(vec![("prefix", Value::str("")), ("basic", Value::Bool(false))])),
|
|
617
617
|
]));
|
|
618
618
|
let ctx = pl_ctx(&client, &utility, None);
|
|
619
619
|
*ctx.spec.borrow_mut() = Some(auth_spec(Value::Noval));
|
|
@@ -627,7 +627,7 @@ fn pipeline_prepare_auth_raw_apikey_empty_prefix_as_is() {
|
|
|
627
627
|
fn pipeline_prepare_auth_empty_apikey_drops_header() {
|
|
628
628
|
let (client, utility) = pl_client(jo(vec![
|
|
629
629
|
("apikey", Value::str("")),
|
|
630
|
-
("auth", jo(vec![("prefix", Value::str("Bearer"))])),
|
|
630
|
+
("auth", jo(vec![("prefix", Value::str("Bearer")), ("basic", Value::Bool(false))])),
|
|
631
631
|
]));
|
|
632
632
|
let ctx = pl_ctx(&client, &utility, None);
|
|
633
633
|
*ctx.spec.borrow_mut() = Some(auth_spec(jo(vec![(
|
|
@@ -647,7 +647,7 @@ fn pipeline_prepare_auth_empty_apikey_drops_header() {
|
|
|
647
647
|
fn pipeline_prepare_auth_missing_apikey_drops_header() {
|
|
648
648
|
let (client, utility) = pl_client(jo(vec![(
|
|
649
649
|
"auth",
|
|
650
|
-
jo(vec![("prefix", Value::str("Bearer"))]),
|
|
650
|
+
jo(vec![("prefix", Value::str("Bearer")), ("basic", Value::Bool(false))]),
|
|
651
651
|
)]));
|
|
652
652
|
let options = client.options_map();
|
|
653
653
|
if get_str(&options, "apikey")
|
|
@@ -62,9 +62,14 @@ object SecretsTestMain {
|
|
|
62
62
|
// let the prefix be whatever this SDK's API declares - pinning the whole
|
|
63
63
|
// header value passes only for a prefix-less API, and this file ships to
|
|
64
64
|
// every project that selects the feature.
|
|
65
|
+
// HTTP Basic carries base64(key:secret) instead, and scala ships this suite
|
|
66
|
+
// untrimmed, so it also runs for a Basic API.
|
|
65
67
|
private def credentialIs(name: String, header: String, token: String): Unit = {
|
|
66
68
|
val got = if (header == null) "" else header
|
|
67
|
-
|
|
69
|
+
val basic = got.startsWith("Basic ") && (try {
|
|
70
|
+
new String(java.util.Base64.getDecoder.decode(got.substring(6)), "UTF-8").startsWith(token + ":")
|
|
71
|
+
} catch { case _: IllegalArgumentException => false })
|
|
72
|
+
check(name, got == token || got.endsWith(" " + token) || basic,
|
|
68
73
|
"expected the authorization header to carry " + token + ", got \"" + got + "\"")
|
|
69
74
|
}
|
|
70
75
|
|
|
@@ -264,7 +269,7 @@ object SecretsTestMain {
|
|
|
264
269
|
var done = false
|
|
265
270
|
// A plain while, not a for-comprehension: a `return` out of a
|
|
266
271
|
// for-comprehension is a NON-LOCAL return, which scala 3 has deprecated.
|
|
267
|
-
val ops = entities(client).flatMap(ent => List(() => ent.list(null, null), () => ent.load(
|
|
272
|
+
val ops = entities(client).flatMap(ent => List(() => ent.list(null, null), () => ent.load(jmap("id" -> "x"), null)))
|
|
268
273
|
var index = 0
|
|
269
274
|
while (!done && index < ops.length) {
|
|
270
275
|
try ops(index)()
|
|
@@ -351,7 +351,7 @@ final class PipelineTest: XCTestCase {
|
|
|
351
351
|
|
|
352
352
|
func testPrepareAuthApikeyWithPrefixSpaceJoined() {
|
|
353
353
|
let (client, utility) = plClient(vm(
|
|
354
|
-
("apikey", .string("K")), ("auth", .map(vm(("prefix", .string("Bearer")))))))
|
|
354
|
+
("apikey", .string("K")), ("auth", .map(vm(("prefix", .string("Bearer")), ("basic", .bool(false)))))))
|
|
355
355
|
let ctx = plCtx(client, utility, nil)
|
|
356
356
|
ctx.spec = authSpec(nil)
|
|
357
357
|
_ = try! utility.prepareAuth(ctx)
|
|
@@ -360,7 +360,7 @@ final class PipelineTest: XCTestCase {
|
|
|
360
360
|
|
|
361
361
|
func testPrepareAuthRawApikeyEmptyPrefixAsIs() {
|
|
362
362
|
let (client, utility) = plClient(vm(
|
|
363
|
-
("apikey", .string("K")), ("auth", .map(vm(("prefix", .string("")))))))
|
|
363
|
+
("apikey", .string("K")), ("auth", .map(vm(("prefix", .string("")), ("basic", .bool(false)))))))
|
|
364
364
|
let ctx = plCtx(client, utility, nil)
|
|
365
365
|
ctx.spec = authSpec(nil)
|
|
366
366
|
_ = try! utility.prepareAuth(ctx)
|
|
@@ -369,7 +369,7 @@ final class PipelineTest: XCTestCase {
|
|
|
369
369
|
|
|
370
370
|
func testPrepareAuthEmptyApikeyDropsHeader() {
|
|
371
371
|
let (client, utility) = plClient(vm(
|
|
372
|
-
("apikey", .string("")), ("auth", .map(vm(("prefix", .string("Bearer")))))))
|
|
372
|
+
("apikey", .string("")), ("auth", .map(vm(("prefix", .string("Bearer")), ("basic", .bool(false)))))))
|
|
373
373
|
let ctx = plCtx(client, utility, nil)
|
|
374
374
|
ctx.spec = authSpec(vm(("authorization", .string("stale"))))
|
|
375
375
|
_ = try! utility.prepareAuth(ctx)
|
|
@@ -377,7 +377,7 @@ final class PipelineTest: XCTestCase {
|
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
func testPrepareAuthMissingApikeyDropsHeader() {
|
|
380
|
-
let (client, utility) = plClient(vm(("auth", .map(vm(("prefix", .string("Bearer")))))))
|
|
380
|
+
let (client, utility) = plClient(vm(("auth", .map(vm(("prefix", .string("Bearer")), ("basic", .bool(false)))))))
|
|
381
381
|
let options = client.optionsMap()
|
|
382
382
|
if let apikey = options.entries["apikey"]?.asString, apikey != "" { return }
|
|
383
383
|
let ctx = plCtx(client, utility, nil)
|
|
@@ -273,18 +273,22 @@ fn drive_entity(client: *sdk.SDK) Drive {
|
|
|
273
273
|
{
|
|
274
274
|
const ent = @field(sdk.SDK, d.name)(client, vnull());
|
|
275
275
|
const ops = h.getpath(&.{ "entity", ent.name, "op" }, cfg);
|
|
276
|
+
// A call whose route it cannot fill is refused before
|
|
277
|
+
// the chain is consulted, so the next entity is tried.
|
|
276
278
|
if (h.getp(ops, "load") == .object) {
|
|
277
279
|
const res = ent.load(h.jo(&.{.{ "id", h.vstr("s01") }}), vnull());
|
|
278
|
-
|
|
279
|
-
.err => |e|
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
switch (res) {
|
|
281
|
+
.err => |e| if (!std.mem.eql(u8, e.code, "url_param_missing"))
|
|
282
|
+
return .{ .ran = true, .ok = false, .msg = e.msg },
|
|
283
|
+
.ok => return .{ .ran = true, .ok = true, .msg = "" },
|
|
284
|
+
}
|
|
282
285
|
} else if (h.getp(ops, "list") == .object) {
|
|
283
286
|
const res = ent.list(h.omap(), vnull());
|
|
284
|
-
|
|
285
|
-
.err => |e|
|
|
286
|
-
|
|
287
|
-
|
|
287
|
+
switch (res) {
|
|
288
|
+
.err => |e| if (!std.mem.eql(u8, e.code, "url_param_missing"))
|
|
289
|
+
return .{ .ran = true, .ok = false, .msg = e.msg },
|
|
290
|
+
.ok => return .{ .ran = true, .ok = true, .msg = "" },
|
|
291
|
+
}
|
|
288
292
|
}
|
|
289
293
|
}
|
|
290
294
|
}
|