@voxgig/sdkgen 4.48.1 → 4.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/package.json +1 -1
  3. package/project/.sdk/model/feature/secrets.aontu +3 -0
  4. package/project/.sdk/src/cmp/c/Config_c.ts +6 -1
  5. package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +0 -10
  6. package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +0 -9
  7. package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +0 -11
  8. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +0 -7
  9. package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +0 -10
  10. package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +2 -11
  11. package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +0 -10
  12. package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +0 -11
  13. package/project/.sdk/src/cmp/ocaml/Entity_ocaml.ts +2 -10
  14. package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +0 -13
  15. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +0 -10
  16. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +0 -10
  17. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +0 -10
  18. package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +0 -12
  19. package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +0 -10
  20. package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +0 -9
  21. package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +0 -7
  22. package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +1 -14
  23. package/project/.sdk/tm/c/feature/cache.c +16 -1
  24. package/project/.sdk/tm/c/feature/secrets.c +149 -18
  25. package/project/.sdk/tm/c/tests/feature/secrets/secrets_test.c +319 -70
  26. package/project/.sdk/tm/c/tests/feature_test.c +31 -0
  27. package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +74 -29
  28. package/project/.sdk/tm/clojure/src/sdk/core.clj +8 -1
  29. package/project/.sdk/tm/clojure/src/sdk/features.clj +16 -2
  30. package/project/.sdk/tm/clojure/test/sdk/test/feature/secrets.clj +191 -48
  31. package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +16 -0
  32. package/project/.sdk/tm/cpp/core/types.hpp +1 -11
  33. package/project/.sdk/tm/cpp/feature/cache.hpp +14 -1
  34. package/project/.sdk/tm/cpp/feature/secrets.hpp +133 -18
  35. package/project/.sdk/tm/cpp/test/feature/secrets/secrets_test.cpp +175 -8
  36. package/project/.sdk/tm/cpp/test/feature_test.cpp +27 -0
  37. package/project/.sdk/tm/csharp/core/Control.cs +0 -5
  38. package/project/.sdk/tm/csharp/feature/CacheFeature.cs +16 -0
  39. package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +77 -38
  40. package/project/.sdk/tm/csharp/test/FeatureTest.cs +29 -0
  41. package/project/.sdk/tm/csharp/test/feature/secrets/SecretsFeatureTest.cs +315 -68
  42. package/project/.sdk/tm/elixir/lib/projectname/entity_base.ex +0 -13
  43. package/project/.sdk/tm/elixir/lib/projectname/feature/cache.ex +32 -10
  44. package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +78 -22
  45. package/project/.sdk/tm/elixir/test/feature/secrets/secrets_test.exs +178 -19
  46. package/project/.sdk/tm/elixir/test/feature_test.exs +20 -0
  47. package/project/.sdk/tm/go/feature/cache_feature.go +14 -1
  48. package/project/.sdk/tm/go/feature/secrets_feature.go +110 -15
  49. package/project/.sdk/tm/go/test/feature/secrets/secrets_feature_test.go +373 -87
  50. package/project/.sdk/tm/go/test/feature_test.go +32 -0
  51. package/project/.sdk/tm/go/utility/media.go +2 -2
  52. package/project/.sdk/tm/java/core/Control.java +0 -5
  53. package/project/.sdk/tm/java/feature/CacheFeature.java +12 -0
  54. package/project/.sdk/tm/java/feature/SecretsFeature.java +104 -34
  55. package/project/.sdk/tm/java/test/FeatureTest.java +25 -0
  56. package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +39 -0
  57. package/project/.sdk/tm/java/test/feature/secrets/SecretsFeatureTest.java +267 -53
  58. package/project/.sdk/tm/java/utility/Fetcher.java +18 -2
  59. package/project/.sdk/tm/java/utility/Media.java +2 -2
  60. package/project/.sdk/tm/js/src/feature/cache/CacheFeature.js +13 -0
  61. package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +79 -29
  62. package/project/.sdk/tm/js/test/feature/secrets/Secrets.test.js +282 -93
  63. package/project/.sdk/tm/js/test/feature.test.js +17 -0
  64. package/project/.sdk/tm/kotlin/core/Control.kt +0 -5
  65. package/project/.sdk/tm/kotlin/feature/CacheFeature.kt +12 -0
  66. package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +84 -24
  67. package/project/.sdk/tm/kotlin/test/FeatureTest.kt +24 -0
  68. package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +35 -0
  69. package/project/.sdk/tm/kotlin/test/feature/secrets/SecretsTest.kt +236 -54
  70. package/project/.sdk/tm/kotlin/utility/Fetcher.kt +13 -1
  71. package/project/.sdk/tm/lua/feature/cache_feature.lua +20 -0
  72. package/project/.sdk/tm/lua/feature/secrets_feature.lua +92 -15
  73. package/project/.sdk/tm/lua/test/feature/secrets/secrets_feature_test.lua +208 -43
  74. package/project/.sdk/tm/lua/test/feature_test.lua +18 -0
  75. package/project/.sdk/tm/lua/utility/clean.lua +1 -0
  76. package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +100 -14
  77. package/project/.sdk/tm/ocaml/sdk_features.ml +7 -1
  78. package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +143 -7
  79. package/project/.sdk/tm/ocaml/test/t_feature.ml +15 -0
  80. package/project/.sdk/tm/perl/feature/cache_feature.pm +13 -0
  81. package/project/.sdk/tm/perl/feature/secrets_feature.pm +87 -32
  82. package/project/.sdk/tm/perl/t/feature/secrets/secrets.t +177 -24
  83. package/project/.sdk/tm/perl/t/feature.t +24 -0
  84. package/project/.sdk/tm/php/feature/CacheFeature.php +13 -0
  85. package/project/.sdk/tm/php/feature/SecretsFeature.php +79 -23
  86. package/project/.sdk/tm/php/test/FeatureTest.php +23 -0
  87. package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +258 -48
  88. package/project/.sdk/tm/py/pkg/feature/cache_feature.py +7 -1
  89. package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +90 -29
  90. package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +313 -80
  91. package/project/.sdk/tm/py/test/test_feature.py +18 -0
  92. package/project/.sdk/tm/rb/feature/cache_feature.rb +12 -0
  93. package/project/.sdk/tm/rb/feature/secrets_feature.rb +68 -21
  94. package/project/.sdk/tm/rb/test/feature/secrets/secrets_feature_test.rb +214 -43
  95. package/project/.sdk/tm/rb/test/feature_test.rb +20 -0
  96. package/project/.sdk/tm/rust/feature/cache.rs +15 -1
  97. package/project/.sdk/tm/rust/feature/secrets.rs +103 -23
  98. package/project/.sdk/tm/rust/tests/feature/secrets/main.rs +357 -67
  99. package/project/.sdk/tm/rust/tests/feature_test.rs +41 -0
  100. package/project/.sdk/tm/scala/core/Control.scala +0 -5
  101. package/project/.sdk/tm/scala/feature/CacheFeature.scala +12 -0
  102. package/project/.sdk/tm/scala/feature/SecretsFeature.scala +88 -22
  103. package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +61 -1
  104. package/project/.sdk/tm/scala/sdktest/feature/secrets/SecretsTestMain.scala +230 -73
  105. package/project/.sdk/tm/scala/utility/Fetcher.scala +13 -1
  106. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Control.swift +0 -5
  107. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CacheFeature.swift +11 -0
  108. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +76 -16
  109. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +21 -0
  110. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/feature/secrets/SecretsFeatureTest.swift +257 -73
  111. package/project/.sdk/tm/ts/src/feature/cache/CacheFeature.ts +13 -0
  112. package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +77 -17
  113. package/project/.sdk/tm/ts/test/feature/secrets/Secrets.test.ts +282 -87
  114. package/project/.sdk/tm/ts/test/feature.test.ts +17 -0
  115. package/project/.sdk/tm/zig/feature/cache.zig +15 -1
  116. package/project/.sdk/tm/zig/feature/secrets.zig +109 -32
  117. package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +232 -9
  118. package/project/.sdk/tm/zig/test/feature_test.zig +33 -0
  119. package/project/sdkgen-package.json +1 -1
@@ -1,6 +1,8 @@
1
1
  package SCALAPACKAGE.feature
2
2
 
3
- import java.util.{LinkedHashMap, List => JList, Map => JMap}
3
+ import java.net.URI
4
+ import java.nio.charset.StandardCharsets
5
+ import java.util.{Base64, LinkedHashMap, Locale, List => JList, Map => JMap}
4
6
  import java.util.function.{BiFunction, Supplier}
5
7
 
6
8
  import scala.collection.immutable.ListMap
@@ -78,6 +80,11 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
78
80
  // writes it - see the class note.
79
81
  private var liveopts: JMap[String, Object] = null
80
82
 
83
+ // What prepareAuth was generated from: the config declares auth only
84
+ // where it places a credential, and Basic only where it composes one.
85
+ private var declared: Boolean = false
86
+ private var basic: Boolean = false
87
+
81
88
  private var secretname: String = "apikey"
82
89
  private var docache: Boolean = true
83
90
  private var sek: Sekreto = null
@@ -97,6 +104,7 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
97
104
  private var xresponse: String = "access_token"
98
105
  private var xstatuses: List[Int] = List(401)
99
106
  private var xretries: Int = 1
107
+ private var xredirect: String = "refuse"
100
108
 
101
109
  // The refresh credential the chain resolved, for every later purchase.
102
110
  private var refresh: String = ""
@@ -136,6 +144,18 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
136
144
  this.liveopts = ctx.options
137
145
  this.active = FeatureOptions.foptBool(options, "active", false)
138
146
 
147
+ val configopts = if (ctx.config == null) null else ctx.config.get("options")
148
+ val authdecl = configopts match {
149
+ case m: JMap[_, _] => m.get("auth")
150
+ case _ => null
151
+ }
152
+ authdecl match {
153
+ case m: JMap[_, _] =>
154
+ this.declared = true
155
+ this.basic = java.lang.Boolean.TRUE == m.get("basic")
156
+ case _ =>
157
+ }
158
+
139
159
  if (!this.active) return
140
160
 
141
161
  this.secretname = FeatureOptions.foptStr(options, "name", "apikey")
@@ -149,6 +169,9 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
149
169
  this.xrequest = FeatureOptions.foptStr(xopts, "request", "refresh_token")
150
170
  this.xresponse = FeatureOptions.foptStr(xopts, "response", "access_token")
151
171
  this.xretries = FeatureOptions.foptInt(xopts, "retries", 1)
172
+ this.xredirect =
173
+ if ("same-origin" == FeatureOptions.foptStr(xopts, "redirect", "refuse")) "same-origin"
174
+ else "refuse"
152
175
 
153
176
  val statuses = ListBuffer.empty[Int]
154
177
  val slist = FeatureOptions.foptList(xopts, "statuses")
@@ -293,11 +316,16 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
293
316
  }
294
317
  }
295
318
 
319
+ // prepareAuth's decision: auth the config declares, not suppressed by
320
+ // `auth: null`.
321
+ private def authon(): Boolean =
322
+ this.declared && this.liveopts != null && this.liveopts.get("auth") != null
323
+
296
324
  // Resolve once, reporting whether a credential came out of it. That
297
325
  // boolean is the whole of what resolve() needs to tell a cacheable HIT
298
326
  // from a miss it must not keep.
299
327
  private def resolveonce(): Boolean = {
300
- if (this.sek == null) return false
328
+ if (this.sek == null || !authon()) return false
301
329
 
302
330
  // tryget returns None for a MISS and RAISES for an ERROR. That is the
303
331
  // whole miss-vs-error rule, and it is sekreto's, not this feature's.
@@ -327,15 +355,6 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
327
355
  // the same path expiry takes anyway.
328
356
  if ("" != this.cred) return true
329
357
 
330
- // `auth: null` is the documented way to send NO credential, and a
331
- // purchase is a credential-bearing call: the refresh token goes to the
332
- // token endpoint in the request body. withrefresh honours suppression
333
- // for the RETRY, but it runs after this - by then the refresh token has
334
- // already left the process, and no later check can call it back. The
335
- // suppression has to be honoured here, before the first purchase, or it
336
- // only ever half-held.
337
- if (this.liveopts == null || this.liveopts.get("auth") == null) return false
338
-
339
358
  buyonce()
340
359
 
341
360
  true
@@ -355,12 +374,9 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
355
374
  fetchdef: JMap[String, Object],
356
375
  inner: FetcherFn,
357
376
  ): Object = {
358
- // `auth: null` is the documented way to send NO credential, and
359
- // prepareAuth honours it by removing the header. A refusal of a
360
- // deliberately unauthenticated request is not an expired token and
361
- // cannot be fixed by buying one - retrying would transmit exactly the
362
- // credential the caller suppressed.
363
- if (this.liveopts == null || this.liveopts.get("auth") == null) {
377
+ // A refusal of an unauthenticated request is not an expired token, and
378
+ // retrying would transmit the credential that auth off withholds.
379
+ if (!authon()) {
364
380
  return inner(ctx, url, fetchdef)
365
381
  }
366
382
 
@@ -423,7 +439,7 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
423
439
  // Reached defensively on the exchange path - withrefresh does not retry
424
440
  // at all when auth is null - but this is the function that writes the
425
441
  // credential, so it is where the rule has to hold.
426
- val rawauth = if (this.liveopts == null) null else this.liveopts.get("auth")
442
+ val rawauth = if (!authon()) null else this.liveopts.get("auth")
427
443
  rawauth match {
428
444
  case authmap: JMap[_, _] =>
429
445
  // The header prepareAuth wrote: auth.name, lower-cased.
@@ -431,16 +447,29 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
431
447
  case s: String if s.nonEmpty => s.toLowerCase(java.util.Locale.ROOT)
432
448
  case _ => "authorization"
433
449
  }
450
+ val value =
451
+ if (this.basic && java.lang.Boolean.TRUE == authmap.get("basic")) pair(token) else token
434
452
  val prefix = authmap.asInstanceOf[JMap[String, Object]].get("prefix") match {
435
453
  case s: String => s
436
454
  case _ => ""
437
455
  }
438
- if ("" == prefix) headers.put(name, token)
439
- else headers.put(name, prefix + " " + token)
456
+ if ("" == prefix) headers.put(name, value)
457
+ else headers.put(name, prefix + " " + value)
440
458
  case _ => headers.remove("authorization")
441
459
  }
442
460
  }
443
461
 
462
+ // Under Basic the token is the key half, as apikey is: prepareAuth's pair.
463
+ private def pair(token: String): String = {
464
+ val secret = this.liveopts.get("secret") match {
465
+ case s: String => s
466
+ case _ => ""
467
+ }
468
+ val pair = Base64.getEncoder.encodeToString((token + ":" + secret).getBytes(StandardCharsets.UTF_8))
469
+ register(pair)
470
+ pair
471
+ }
472
+
444
473
  // ---- the access-token exchange -----------------------------------------
445
474
 
446
475
  // Buy an access token with the refresh token, and publish it. ALWAYS
@@ -486,10 +515,21 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
486
515
  fetchdef.put("method", this.xmethod)
487
516
  fetchdef.put("headers", headers)
488
517
  fetchdef.put("body", Struct.jsonify(bodymap, flags))
489
- // Never followed: a redirect would carry the refresh token on.
518
+ // Never followed by the client: a redirect would carry the refresh token on.
490
519
  fetchdef.put("redirect", "manual")
491
520
 
492
- val res = exchangefetch(url, fetchdef)
521
+ var res = exchangefetch(url, fetchdef)
522
+
523
+ // By option alone, and only while the exchange stays on its own origin.
524
+ var at = url
525
+ var hops = 0
526
+ var next = if ("same-origin" == this.xredirect) moved(url, at, res) else null
527
+ while (next != null && hops < SecretsFeature.REDIRECT_MAX) {
528
+ at = next
529
+ res = exchangefetch(at, fetchdef)
530
+ hops += 1
531
+ next = moved(url, at, res)
532
+ }
493
533
  if (res == null) {
494
534
  throw new SekretoError("secrets: token exchange failed: no response from " + url)
495
535
  }
@@ -557,6 +597,28 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
557
597
  }
558
598
  }
559
599
 
600
+ // Where a 307 or 308 points, when that is on the exchange's own origin. Any
601
+ // other redirect would drop the body or leave the origin.
602
+ private def moved(url: String, at: String, res: JMap[String, Object]): String = {
603
+ val status = FeatureOptions.fresStatus(res)
604
+ if (307 != status && 308 != status) return null
605
+ val location = FeatureOptions.fresHeader(res, "location")
606
+ if ("" == location) return null
607
+ try {
608
+ val next = Fetcher.resolveLocation(URI.create(at), location)
609
+ val origin = originOf(next)
610
+ if (origin != null && origin == originOf(URI.create(url))) next.toString else null
611
+ }
612
+ catch { case _: RuntimeException => null }
613
+ }
614
+
615
+ private def originOf(uri: URI): String = {
616
+ if (uri.getScheme == null || uri.getHost == null) return null
617
+ val scheme = uri.getScheme.toLowerCase(Locale.ROOT)
618
+ val port = if (uri.getPort < 0) (if ("https" == scheme) 443 else 80) else uri.getPort
619
+ scheme + "://" + uri.getHost.toLowerCase(Locale.ROOT) + ":" + port
620
+ }
621
+
560
622
  // ---- support ------------------------------------------------------------
561
623
 
562
624
  private def optstr(map: JMap[String, Object], key: String): String = {
@@ -597,3 +659,7 @@ class SecretsFeature extends BaseFeature("secrets", "0.1.0", true) {
597
659
  case other => VStr(String.valueOf(other))
598
660
  }
599
661
  }
662
+
663
+ object SecretsFeature {
664
+ private val REDIRECT_MAX = 5
665
+ }
@@ -406,6 +406,28 @@ object SdkTestMain {
406
406
  { val rec = new FhRecorder()
407
407
  val h = fhMake((c, u, fd) => rec.fetch(c, u, fd), fhF(new CacheFeature(), om("active" -> B(false))))
408
408
  h.op(fhOp("load").withPath("/x")); h.op(fhOp("load").withPath("/x")); eqI("cache.inactive", 2, rec.calls.size()) }
409
+ // A body that declares another type than JSON passes by, unread.
410
+ { val sent = new java.util.ArrayList[JMap[String, Object]]()
411
+ val rec = new FhRecorder()
412
+ rec.reply = (n, fd) => {
413
+ val res = fhResponse(200, null, om("content-type" -> "audio/wav"))
414
+ res.put("body", "RIFF".getBytes)
415
+ sent.add(res)
416
+ res
417
+ }
418
+ val f = new CacheFeature()
419
+ val h = fhMake((c, u, fd) => rec.fetch(c, u, fd), fhF(f, om("ttl" -> I(10000))))
420
+ val a = h.op(fhOp("load").withPath("/w/1/audio")); val b = h.op(fhOp("load").withPath("/w/1/audio"))
421
+ eqI("cache.notJson.calls", 2, rec.calls.size())
422
+ check("cache.notJson.first", a.ctx.response != null &&
423
+ (sent.get(0).get("body") eq a.ctx.response.body) &&
424
+ (sent.get(0).get("headers") eq a.ctx.response.headers),
425
+ "the cache handed on a copy it had read")
426
+ check("cache.notJson.second", b.ctx.response != null &&
427
+ (sent.get(1).get("body") eq b.ctx.response.body) &&
428
+ (sent.get(1).get("headers") eq b.ctx.response.headers),
429
+ "the cache handed on a copy it had read")
430
+ eqI("cache.notJson.bypass", 2, f.bypass) }
409
431
  }
410
432
 
411
433
  private def testIdempotency(): Unit = {
@@ -769,6 +791,44 @@ object SdkTestMain {
769
791
  finally server.stop(0)
770
792
  }
771
793
 
794
+ // A Location of a query alone keeps the path that answered.
795
+ private def testRedirectToAQuery(): Unit = {
796
+ val seen = java.util.Collections.synchronizedList(new ArrayList[String]())
797
+ val server = com.sun.net.httpserver.HttpServer.create(new java.net.InetSocketAddress("127.0.0.1", 0), 0)
798
+ server.createContext("/", (exchange: com.sun.net.httpserver.HttpExchange) => {
799
+ val query = exchange.getRequestURI.getRawQuery
800
+ seen.add(exchange.getRequestURI.getRawPath + (if (query == null) "" else "?" + query))
801
+ if (query == null) {
802
+ exchange.getResponseHeaders.set("Location", "?step=2")
803
+ exchange.sendResponseHeaders(302, -1L)
804
+ } else {
805
+ val body = "{\"id\":\"q1\"}".getBytes("UTF-8")
806
+ exchange.getResponseHeaders.set("Content-Type", "application/json")
807
+ exchange.sendResponseHeaders(200, body.length.toLong)
808
+ exchange.getResponseBody.write(body)
809
+ }
810
+ exchange.close()
811
+ })
812
+ server.start()
813
+ val base = "http://127.0.0.1:" + server.getAddress.getPort
814
+ try {
815
+ val opts = new LinkedHashMap[String, Object]()
816
+ opts.put("base", base)
817
+ val client = new ProjectNameSDK(opts)
818
+ val utility = client.getUtility()
819
+ val cm = new LinkedHashMap[String, Object]()
820
+ cm.put("opname", "load")
821
+ val ctx = utility.makeContext(cm, client.getRootCtx())
822
+ val fetchdef = new LinkedHashMap[String, Object]()
823
+ fetchdef.put("method", "GET")
824
+ fetchdef.put("headers", new LinkedHashMap[String, Object]())
825
+ val res = utility.fetcher(ctx, base + "/redirect/q1", fetchdef).asInstanceOf[JMap[String, Object]]
826
+ eq("redirect.query.status", Integer.valueOf(200), res.get("status"))
827
+ eq("redirect.query.hops", "[/redirect/q1, /redirect/q1?step=2]", seen.toString)
828
+ }
829
+ finally server.stop(0)
830
+ }
831
+
772
832
  private val REDIRECT_SECRET = "REDIRECT-SECRET-q7w3e9r1"
773
833
  private val REDIRECT_CREDENTIALS =
774
834
  Seq("authorization", "cookie", "x-api-key", "private-token", "x-acme-auth")
@@ -993,7 +1053,7 @@ object SdkTestMain {
993
1053
  "composition" -> testComposition, "featureAdd" -> testFeatureAdd,
994
1054
  "featureOrder" -> testFeatureOrder, "entityCrud" -> testEntityCrud,
995
1055
  "entityStream" -> testEntityStream, "getOnlyGuard" -> testGetOnlyGuard,
996
- "redirect" -> testRedirect, "redirectToAnotherOrigin" -> testRedirectToAnotherOrigin,
1056
+ "redirect" -> testRedirect, "redirectToAQuery" -> testRedirectToAQuery, "redirectToAnotherOrigin" -> testRedirectToAnotherOrigin,
997
1057
  "redirectOnTheSameOrigin" -> testRedirectOnTheSameOrigin,
998
1058
  "redirectBody" -> testRedirectBody, "redirectMethods" -> testRedirectMethods,
999
1059
  "redirectLimit" -> testRedirectLimit,