@toa.io/extensions.exposition 0.9.0-canary.2 → 0.20.0-alpha.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 (363) hide show
  1. package/components/context.toa.yaml +15 -0
  2. package/components/identity.bans/manifest.toa.yaml +18 -0
  3. package/components/identity.basic/events/principal.js +9 -0
  4. package/components/identity.basic/manifest.toa.yaml +50 -0
  5. package/components/identity.basic/source/authenticate.ts +29 -0
  6. package/components/identity.basic/source/create.ts +19 -0
  7. package/components/identity.basic/source/transit.ts +64 -0
  8. package/components/identity.basic/source/types.ts +42 -0
  9. package/components/identity.basic/tsconfig.json +9 -0
  10. package/components/identity.roles/manifest.toa.yaml +31 -0
  11. package/components/identity.roles/source/list.ts +7 -0
  12. package/components/identity.roles/source/principal.ts +20 -0
  13. package/components/identity.roles/tsconfig.json +9 -0
  14. package/components/identity.tokens/manifest.toa.yaml +39 -0
  15. package/components/identity.tokens/receivers/identity.bans.updated.js +3 -0
  16. package/components/identity.tokens/source/authenticate.test.ts +56 -0
  17. package/components/identity.tokens/source/authenticate.ts +38 -0
  18. package/components/identity.tokens/source/decrypt.test.ts +59 -0
  19. package/components/identity.tokens/source/decrypt.ts +25 -0
  20. package/components/identity.tokens/source/encrypt.test.ts +35 -0
  21. package/components/identity.tokens/source/encrypt.ts +25 -0
  22. package/components/identity.tokens/source/revoke.ts +5 -0
  23. package/components/identity.tokens/source/types.ts +48 -0
  24. package/components/identity.tokens/tsconfig.json +9 -0
  25. package/cucumber.js +9 -0
  26. package/documentation/.assets/ia3-dark.jpg +0 -0
  27. package/documentation/.assets/ia3-light.jpg +0 -0
  28. package/documentation/.assets/overview-dark.jpg +0 -0
  29. package/documentation/.assets/overview-light.jpg +0 -0
  30. package/documentation/.assets/role-scopes-dark.jpg +0 -0
  31. package/documentation/.assets/role-scopes-light.jpg +0 -0
  32. package/documentation/.assets/rtd-dark.jpg +0 -0
  33. package/documentation/.assets/rtd-light.jpg +0 -0
  34. package/documentation/access.md +256 -0
  35. package/documentation/components.md +276 -0
  36. package/documentation/identity.md +156 -0
  37. package/documentation/protocol.md +15 -0
  38. package/documentation/query.md +226 -0
  39. package/documentation/tree.md +169 -0
  40. package/features/access.feature +442 -0
  41. package/features/annotation.feature +28 -0
  42. package/features/body.feature +21 -0
  43. package/features/directives.feature +56 -0
  44. package/features/dynamic.feature +89 -0
  45. package/features/errors.feature +208 -0
  46. package/features/identity.basic.feature +235 -0
  47. package/features/identity.feature +61 -0
  48. package/features/identity.roles.feature +51 -0
  49. package/features/identity.tokens.feature +116 -0
  50. package/features/queries.feature +214 -0
  51. package/features/routes.feature +49 -0
  52. package/features/steps/Common.ts +10 -0
  53. package/features/steps/Components.ts +43 -0
  54. package/features/steps/Database.ts +58 -0
  55. package/features/steps/Gateway.ts +105 -0
  56. package/features/steps/HTTP.ts +71 -0
  57. package/features/steps/Parameters.ts +12 -0
  58. package/features/steps/Workspace.ts +40 -0
  59. package/features/steps/components/greeter/manifest.toa.yaml +9 -0
  60. package/features/steps/components/greeter/operations/greet.js +7 -0
  61. package/features/steps/components/pots/manifest.toa.yaml +20 -0
  62. package/features/steps/components/users/manifest.toa.yaml +11 -0
  63. package/features/steps/tsconfig.json +9 -0
  64. package/package.json +31 -17
  65. package/readme.md +181 -0
  66. package/schemas/annotation.cos.yaml +4 -0
  67. package/schemas/directive.cos.yaml +3 -0
  68. package/schemas/method.cos.yaml +9 -0
  69. package/schemas/node.cos.yaml +5 -0
  70. package/schemas/query.cos.yaml +16 -0
  71. package/schemas/querystring.cos.yaml +5 -0
  72. package/schemas/range.cos.yaml +2 -0
  73. package/schemas/route.cos.yaml +2 -0
  74. package/source/Annotation.ts +6 -0
  75. package/source/Branch.ts +8 -0
  76. package/source/Composition.ts +58 -0
  77. package/source/Context.ts +6 -0
  78. package/source/Directive.test.ts +91 -0
  79. package/source/Directive.ts +120 -0
  80. package/source/Endpoint.ts +57 -0
  81. package/source/Factory.ts +53 -0
  82. package/source/Gateway.ts +93 -0
  83. package/source/HTTP/Server.fixtures.ts +45 -0
  84. package/source/HTTP/Server.test.ts +221 -0
  85. package/source/HTTP/Server.ts +135 -0
  86. package/source/HTTP/exceptions.ts +77 -0
  87. package/source/HTTP/formats/index.ts +19 -0
  88. package/source/HTTP/formats/json.ts +13 -0
  89. package/source/HTTP/formats/msgpack.ts +10 -0
  90. package/source/HTTP/formats/text.ts +9 -0
  91. package/source/HTTP/formats/yaml.ts +14 -0
  92. package/source/HTTP/index.ts +3 -0
  93. package/source/HTTP/messages.test.ts +116 -0
  94. package/source/HTTP/messages.ts +77 -0
  95. package/source/Mapping.ts +48 -0
  96. package/source/Query.test.ts +37 -0
  97. package/source/Query.ts +105 -0
  98. package/source/RTD/Context.ts +16 -0
  99. package/source/RTD/Directives.ts +9 -0
  100. package/source/RTD/Endpoint.ts +11 -0
  101. package/source/RTD/Match.ts +16 -0
  102. package/source/RTD/Method.ts +24 -0
  103. package/source/RTD/Node.ts +85 -0
  104. package/source/RTD/Route.ts +58 -0
  105. package/source/RTD/Tree.ts +57 -0
  106. package/source/RTD/factory.ts +47 -0
  107. package/source/RTD/index.ts +8 -0
  108. package/source/RTD/segment.test.ts +32 -0
  109. package/source/RTD/segment.ts +25 -0
  110. package/source/RTD/syntax/index.ts +2 -0
  111. package/source/RTD/syntax/parse.test.ts +188 -0
  112. package/source/RTD/syntax/parse.ts +153 -0
  113. package/source/RTD/syntax/types.ts +48 -0
  114. package/source/Remotes.test.ts +41 -0
  115. package/source/Remotes.ts +20 -0
  116. package/source/Tenant.ts +38 -0
  117. package/source/deployment.ts +42 -0
  118. package/source/directives/auth/Anonymous.ts +14 -0
  119. package/source/directives/auth/Echo.ts +12 -0
  120. package/source/directives/auth/Family.ts +145 -0
  121. package/source/directives/auth/Id.ts +19 -0
  122. package/source/directives/auth/Incept.ts +42 -0
  123. package/source/directives/auth/Role.test.ts +62 -0
  124. package/source/directives/auth/Role.ts +56 -0
  125. package/source/directives/auth/Rule.ts +28 -0
  126. package/source/directives/auth/Scheme.ts +26 -0
  127. package/source/directives/auth/index.ts +3 -0
  128. package/source/directives/auth/schemes.ts +8 -0
  129. package/source/directives/auth/split.ts +15 -0
  130. package/source/directives/auth/types.ts +37 -0
  131. package/source/directives/dev/Family.ts +34 -0
  132. package/source/directives/dev/Stub.ts +14 -0
  133. package/source/directives/dev/index.ts +3 -0
  134. package/source/directives/dev/types.ts +5 -0
  135. package/source/directives/index.ts +5 -0
  136. package/source/discovery.ts +1 -0
  137. package/source/exceptions.ts +17 -0
  138. package/source/index.test.ts +9 -0
  139. package/source/index.ts +6 -0
  140. package/source/manifest.test.ts +57 -0
  141. package/source/manifest.ts +35 -0
  142. package/source/root.ts +38 -0
  143. package/source/schemas.ts +9 -0
  144. package/transpiled/Annotation.d.ts +6 -0
  145. package/transpiled/Annotation.js +3 -0
  146. package/transpiled/Annotation.js.map +1 -0
  147. package/transpiled/Branch.d.ts +7 -0
  148. package/transpiled/Branch.js +3 -0
  149. package/transpiled/Branch.js.map +1 -0
  150. package/transpiled/Composition.d.ts +14 -0
  151. package/transpiled/Composition.js +43 -0
  152. package/transpiled/Composition.js.map +1 -0
  153. package/transpiled/Context.d.ts +5 -0
  154. package/transpiled/Context.js +3 -0
  155. package/transpiled/Context.js.map +1 -0
  156. package/transpiled/Directive.d.ts +32 -0
  157. package/transpiled/Directive.js +76 -0
  158. package/transpiled/Directive.js.map +1 -0
  159. package/transpiled/Endpoint.d.ts +20 -0
  160. package/transpiled/Endpoint.js +44 -0
  161. package/transpiled/Endpoint.js.map +1 -0
  162. package/transpiled/Factory.d.ts +11 -0
  163. package/transpiled/Factory.js +67 -0
  164. package/transpiled/Factory.js.map +1 -0
  165. package/transpiled/Gateway.d.ts +19 -0
  166. package/transpiled/Gateway.js +90 -0
  167. package/transpiled/Gateway.js.map +1 -0
  168. package/transpiled/HTTP/Server.d.ts +22 -0
  169. package/transpiled/HTTP/Server.fixtures.d.ts +12 -0
  170. package/transpiled/HTTP/Server.fixtures.js +36 -0
  171. package/transpiled/HTTP/Server.fixtures.js.map +1 -0
  172. package/transpiled/HTTP/Server.js +111 -0
  173. package/transpiled/HTTP/Server.js.map +1 -0
  174. package/transpiled/HTTP/exceptions.d.ts +39 -0
  175. package/transpiled/HTTP/exceptions.js +78 -0
  176. package/transpiled/HTTP/exceptions.js.map +1 -0
  177. package/transpiled/HTTP/formats/index.d.ts +8 -0
  178. package/transpiled/HTTP/formats/index.js +38 -0
  179. package/transpiled/HTTP/formats/index.js.map +1 -0
  180. package/transpiled/HTTP/formats/json.d.ts +4 -0
  181. package/transpiled/HTTP/formats/json.js +15 -0
  182. package/transpiled/HTTP/formats/json.js.map +1 -0
  183. package/transpiled/HTTP/formats/msgpack.d.ts +4 -0
  184. package/transpiled/HTTP/formats/msgpack.js +36 -0
  185. package/transpiled/HTTP/formats/msgpack.js.map +1 -0
  186. package/transpiled/HTTP/formats/text.d.ts +4 -0
  187. package/transpiled/HTTP/formats/text.js +13 -0
  188. package/transpiled/HTTP/formats/text.js.map +1 -0
  189. package/transpiled/HTTP/formats/yaml.d.ts +4 -0
  190. package/transpiled/HTTP/formats/yaml.js +39 -0
  191. package/transpiled/HTTP/formats/yaml.js.map +1 -0
  192. package/transpiled/HTTP/index.d.ts +3 -0
  193. package/transpiled/HTTP/index.js +20 -0
  194. package/transpiled/HTTP/index.js.map +1 -0
  195. package/transpiled/HTTP/messages.d.ts +27 -0
  196. package/transpiled/HTTP/messages.js +49 -0
  197. package/transpiled/HTTP/messages.js.map +1 -0
  198. package/transpiled/Mapping.d.ts +8 -0
  199. package/transpiled/Mapping.js +35 -0
  200. package/transpiled/Mapping.js.map +1 -0
  201. package/transpiled/Query.d.ts +13 -0
  202. package/transpiled/Query.js +107 -0
  203. package/transpiled/Query.js.map +1 -0
  204. package/transpiled/RTD/Context.d.ts +11 -0
  205. package/transpiled/RTD/Context.js +3 -0
  206. package/transpiled/RTD/Context.js.map +1 -0
  207. package/transpiled/RTD/Directives.d.ts +7 -0
  208. package/transpiled/RTD/Directives.js +3 -0
  209. package/transpiled/RTD/Directives.js.map +1 -0
  210. package/transpiled/RTD/Endpoint.d.ts +9 -0
  211. package/transpiled/RTD/Endpoint.js +3 -0
  212. package/transpiled/RTD/Endpoint.js.map +1 -0
  213. package/transpiled/RTD/Match.d.ts +11 -0
  214. package/transpiled/RTD/Match.js +3 -0
  215. package/transpiled/RTD/Match.js.map +1 -0
  216. package/transpiled/RTD/Method.d.ts +9 -0
  217. package/transpiled/RTD/Method.js +16 -0
  218. package/transpiled/RTD/Method.js.map +1 -0
  219. package/transpiled/RTD/Node.d.ts +21 -0
  220. package/transpiled/RTD/Node.js +61 -0
  221. package/transpiled/RTD/Node.js.map +1 -0
  222. package/transpiled/RTD/Route.d.ts +14 -0
  223. package/transpiled/RTD/Route.js +48 -0
  224. package/transpiled/RTD/Route.js.map +1 -0
  225. package/transpiled/RTD/Tree.d.ts +14 -0
  226. package/transpiled/RTD/Tree.js +45 -0
  227. package/transpiled/RTD/Tree.js.map +1 -0
  228. package/transpiled/RTD/factory.d.ts +6 -0
  229. package/transpiled/RTD/factory.js +36 -0
  230. package/transpiled/RTD/factory.js.map +1 -0
  231. package/transpiled/RTD/index.d.ts +8 -0
  232. package/transpiled/RTD/index.js +38 -0
  233. package/transpiled/RTD/index.js.map +1 -0
  234. package/transpiled/RTD/segment.d.ts +8 -0
  235. package/transpiled/RTD/segment.js +23 -0
  236. package/transpiled/RTD/segment.js.map +1 -0
  237. package/transpiled/RTD/syntax/index.d.ts +2 -0
  238. package/transpiled/RTD/syntax/index.js +19 -0
  239. package/transpiled/RTD/syntax/index.js.map +1 -0
  240. package/transpiled/RTD/syntax/parse.d.ts +4 -0
  241. package/transpiled/RTD/syntax/parse.js +128 -0
  242. package/transpiled/RTD/syntax/parse.js.map +1 -0
  243. package/transpiled/RTD/syntax/types.d.ts +41 -0
  244. package/transpiled/RTD/syntax/types.js +5 -0
  245. package/transpiled/RTD/syntax/types.js.map +1 -0
  246. package/transpiled/Remotes.d.ts +7 -0
  247. package/transpiled/Remotes.js +19 -0
  248. package/transpiled/Remotes.js.map +1 -0
  249. package/transpiled/Tenant.d.ts +12 -0
  250. package/transpiled/Tenant.js +30 -0
  251. package/transpiled/Tenant.js.map +1 -0
  252. package/transpiled/deployment.d.ts +3 -0
  253. package/transpiled/deployment.js +61 -0
  254. package/transpiled/deployment.js.map +1 -0
  255. package/transpiled/directives/auth/Anonymous.d.ts +6 -0
  256. package/transpiled/directives/auth/Anonymous.js +17 -0
  257. package/transpiled/directives/auth/Anonymous.js.map +1 -0
  258. package/transpiled/directives/auth/Echo.d.ts +6 -0
  259. package/transpiled/directives/auth/Echo.js +13 -0
  260. package/transpiled/directives/auth/Echo.js.map +1 -0
  261. package/transpiled/directives/auth/Family.d.ts +20 -0
  262. package/transpiled/directives/auth/Family.js +125 -0
  263. package/transpiled/directives/auth/Family.js.map +1 -0
  264. package/transpiled/directives/auth/Id.d.ts +7 -0
  265. package/transpiled/directives/auth/Id.js +17 -0
  266. package/transpiled/directives/auth/Id.js.map +1 -0
  267. package/transpiled/directives/auth/Incept.d.ts +10 -0
  268. package/transpiled/directives/auth/Incept.js +59 -0
  269. package/transpiled/directives/auth/Incept.js.map +1 -0
  270. package/transpiled/directives/auth/Role.d.ts +11 -0
  271. package/transpiled/directives/auth/Role.js +44 -0
  272. package/transpiled/directives/auth/Role.js.map +1 -0
  273. package/transpiled/directives/auth/Rule.d.ts +9 -0
  274. package/transpiled/directives/auth/Rule.js +22 -0
  275. package/transpiled/directives/auth/Rule.js.map +1 -0
  276. package/transpiled/directives/auth/Scheme.d.ts +7 -0
  277. package/transpiled/directives/auth/Scheme.js +47 -0
  278. package/transpiled/directives/auth/Scheme.js.map +1 -0
  279. package/transpiled/directives/auth/index.d.ts +2 -0
  280. package/transpiled/directives/auth/index.js +7 -0
  281. package/transpiled/directives/auth/index.js.map +1 -0
  282. package/transpiled/directives/auth/schemes.d.ts +3 -0
  283. package/transpiled/directives/auth/schemes.js +9 -0
  284. package/transpiled/directives/auth/schemes.js.map +1 -0
  285. package/transpiled/directives/auth/split.d.ts +2 -0
  286. package/transpiled/directives/auth/split.js +38 -0
  287. package/transpiled/directives/auth/split.js.map +1 -0
  288. package/transpiled/directives/auth/types.d.ts +31 -0
  289. package/transpiled/directives/auth/types.js +3 -0
  290. package/transpiled/directives/auth/types.js.map +1 -0
  291. package/transpiled/directives/dev/Family.d.ts +10 -0
  292. package/transpiled/directives/dev/Family.js +25 -0
  293. package/transpiled/directives/dev/Family.js.map +1 -0
  294. package/transpiled/directives/dev/Stub.d.ts +7 -0
  295. package/transpiled/directives/dev/Stub.js +14 -0
  296. package/transpiled/directives/dev/Stub.js.map +1 -0
  297. package/transpiled/directives/dev/index.d.ts +2 -0
  298. package/transpiled/directives/dev/index.js +7 -0
  299. package/transpiled/directives/dev/index.js.map +1 -0
  300. package/transpiled/directives/dev/types.d.ts +4 -0
  301. package/transpiled/directives/dev/types.js +3 -0
  302. package/transpiled/directives/dev/types.js.map +1 -0
  303. package/transpiled/directives/index.d.ts +2 -0
  304. package/transpiled/directives/index.js +10 -0
  305. package/transpiled/directives/index.js.map +1 -0
  306. package/transpiled/discovery.d.ts +1 -0
  307. package/transpiled/discovery.js +3 -0
  308. package/transpiled/discovery.js.map +1 -0
  309. package/transpiled/exceptions.d.ts +2 -0
  310. package/transpiled/exceptions.js +39 -0
  311. package/transpiled/exceptions.js.map +1 -0
  312. package/transpiled/index.d.ts +5 -0
  313. package/transpiled/index.js +12 -0
  314. package/transpiled/index.js.map +1 -0
  315. package/transpiled/manifest.d.ts +3 -0
  316. package/transpiled/manifest.js +30 -0
  317. package/transpiled/manifest.js.map +1 -0
  318. package/transpiled/root.d.ts +2 -0
  319. package/transpiled/root.js +39 -0
  320. package/transpiled/root.js.map +1 -0
  321. package/transpiled/schemas.d.ts +3 -0
  322. package/transpiled/schemas.js +14 -0
  323. package/transpiled/schemas.js.map +1 -0
  324. package/transpiled/tsconfig.tsbuildinfo +1 -0
  325. package/tsconfig.json +12 -0
  326. package/src/.manifest/index.js +0 -7
  327. package/src/.manifest/normalize.js +0 -58
  328. package/src/.manifest/schema.yaml +0 -71
  329. package/src/.manifest/validate.js +0 -17
  330. package/src/constants.js +0 -3
  331. package/src/deployment.js +0 -23
  332. package/src/exposition.js +0 -68
  333. package/src/factory.js +0 -76
  334. package/src/index.js +0 -9
  335. package/src/manifest.js +0 -12
  336. package/src/query/criteria.js +0 -55
  337. package/src/query/enum.js +0 -35
  338. package/src/query/index.js +0 -17
  339. package/src/query/query.js +0 -60
  340. package/src/query/range.js +0 -28
  341. package/src/query/sort.js +0 -19
  342. package/src/remote.js +0 -88
  343. package/src/server.js +0 -83
  344. package/src/tenant.js +0 -29
  345. package/src/translate/etag.js +0 -14
  346. package/src/translate/index.js +0 -7
  347. package/src/translate/request.js +0 -68
  348. package/src/translate/response.js +0 -62
  349. package/src/tree.js +0 -109
  350. package/test/manifest.normalize.fixtures.js +0 -37
  351. package/test/manifest.normalize.test.js +0 -37
  352. package/test/manifest.validate.test.js +0 -40
  353. package/test/query.range.test.js +0 -18
  354. package/test/tree.fixtures.js +0 -21
  355. package/test/tree.test.js +0 -44
  356. package/types/annotations.d.ts +0 -10
  357. package/types/declarations.d.ts +0 -31
  358. package/types/exposition.d.ts +0 -13
  359. package/types/http.d.ts +0 -13
  360. package/types/query.d.ts +0 -16
  361. package/types/remote.d.ts +0 -19
  362. package/types/server.d.ts +0 -13
  363. package/types/tree.d.ts +0 -33
@@ -0,0 +1,442 @@
1
+ Feature: Access authorization
2
+
3
+ Background:
4
+ Given the `identity.basic` database contains:
5
+ # developer:secret
6
+ # user:12345
7
+ | _id | username | password |
8
+ | efe3a65ebbee47ed95a73edd911ea328 | developer | $2b$10$ZRSKkgZoGnrcTNA5w5eCcu3pxDzdTduhteVYXcp56AaNcilNkwJ.O |
9
+ | e8e4f9c2a68d419b861403d71fabc915 | user | $2b$10$Frszmrmsz9iwSXzBbRRMKeDVKsNxozkrLNSsN.SnVC.KPxLtQr/bK |
10
+ And the `identity.bans` database is empty
11
+
12
+ Scenario: Deny by default
13
+ Given the annotation:
14
+ """yaml
15
+ /:
16
+ GET:
17
+ dev:stub:
18
+ access: granted!
19
+ """
20
+ When the following request is received:
21
+ """
22
+ GET / HTTP/1.1
23
+ """
24
+ Then the following reply is sent:
25
+ """
26
+ 401 Unauthorized
27
+ """
28
+
29
+ Scenario: Allow anonymous access
30
+ Given the annotation:
31
+ """yaml
32
+ /:
33
+ auth:anonymous: true
34
+ GET:
35
+ dev:stub:
36
+ access: granted!
37
+ """
38
+ When the following request is received:
39
+ """
40
+ GET / HTTP/1.1
41
+ """
42
+ Then the following reply is sent:
43
+ """
44
+ 200 OK
45
+ content-type: application/yaml
46
+
47
+ access: granted!
48
+ """
49
+
50
+ Scenario: Deny access with credentials to a resource with anonymous access
51
+ Given the annotation:
52
+ """yaml
53
+ /:
54
+ auth:anonymous: true
55
+ GET:
56
+ dev:stub:
57
+ access: granted!
58
+ """
59
+ When the following request is received:
60
+ """
61
+ GET / HTTP/1.1
62
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldA==
63
+ """
64
+ Then the following reply is sent:
65
+ """
66
+ 403 Forbidden
67
+ """
68
+
69
+ Scenario: Using `auth:id` directive
70
+ Given the annotation:
71
+ """yaml
72
+ /:id:
73
+ auth:id: id
74
+ GET:
75
+ dev:stub:
76
+ access: granted!
77
+ """
78
+ When the following request is received:
79
+ """
80
+ GET /efe3a65ebbee47ed95a73edd911ea328/ HTTP/1.1
81
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldA==
82
+ accept: application/yaml
83
+ """
84
+ Then the following reply is sent:
85
+ """
86
+ 200 OK
87
+ content-type: application/yaml
88
+
89
+ access: granted!
90
+ """
91
+ When the following request is received:
92
+ """
93
+ GET /efe3a65ebbee47ed95a73edd911ea328/ HTTP/1.1
94
+ authorization: Basic dXNlcjoxMjM0NQ==
95
+ accept: application/yaml
96
+ """
97
+ Then the following reply is sent:
98
+ """
99
+ 403 Forbidden
100
+ """
101
+
102
+ Scenario: Using `auth:role` directive
103
+ Given the `identity.roles` database contains:
104
+ | _id | identity | role |
105
+ | 775a648d054e4ce1a65f8f17e5b51803 | efe3a65ebbee47ed95a73edd911ea328 | developer |
106
+ | 1d95bd2c764142818f6ece5e084015b5 | efe3a65ebbee47ed95a73edd911ea328 | user |
107
+ And the annotation:
108
+ """yaml
109
+ /:
110
+ auth:role: developer
111
+ GET:
112
+ dev:stub:
113
+ access: granted!
114
+ """
115
+ When the following request is received:
116
+ # identity with `developer` and `user` roles
117
+ """
118
+ GET / HTTP/1.1
119
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldA==
120
+ accept: application/yaml
121
+ """
122
+ Then the following reply is sent:
123
+ """
124
+ 200 OK
125
+ content-type: application/yaml
126
+
127
+ access: granted!
128
+ """
129
+ When the following request is received:
130
+ # identity with no roles
131
+ """
132
+ GET / HTTP/1.1
133
+ authorization: Basic dXNlcjoxMjM0NQ==
134
+ """
135
+ Then the following reply is sent:
136
+ """
137
+ 403 Forbidden
138
+ """
139
+
140
+ Scenario: Using `auth:role` directive with scope matching
141
+ Given the `identity.roles` database contains:
142
+ | _id | identity | role |
143
+ | 775a648d054e4ce1a65f8f17e5b51803 | efe3a65ebbee47ed95a73edd911ea328 | developer:rust |
144
+ And the annotation:
145
+ """yaml
146
+ /:
147
+ auth:role: developer:rust:junior # role scope matches
148
+ /nested:
149
+ GET:
150
+ dev:stub: good!
151
+ /javascript:
152
+ auth:role: developer:javascript # role scope does not match
153
+ GET:
154
+ dev:stub: no good!
155
+ """
156
+ When the following request is received:
157
+ """
158
+ GET /nested/ HTTP/1.1
159
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldA==
160
+ accept: text/plain
161
+ """
162
+ Then the following reply is sent:
163
+ """
164
+ 200 OK
165
+ content-type: text/plain
166
+
167
+ good!
168
+ """
169
+ When the following request is received:
170
+ """
171
+ GET /javascript/ HTTP/1.1
172
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldA==
173
+ """
174
+ Then the following reply is sent:
175
+ """
176
+ 403 Forbidden
177
+ """
178
+
179
+ Scenario: Allow by `auth:role` matching one of the roles
180
+ Given the `identity.roles` database contains:
181
+ | _id | identity | role |
182
+ | 775a648d054e4ce1a65f8f17e5b51803 | efe3a65ebbee47ed95a73edd911ea328 | developer |
183
+ And the annotation:
184
+ """yaml
185
+ /:
186
+ role:
187
+ - developer
188
+ - admin
189
+ GET:
190
+ dev:stub:
191
+ access: granted!
192
+ """
193
+ When the following request is received:
194
+ # identity with `developer` and `user` roles
195
+ """
196
+ GET / HTTP/1.1
197
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldA==
198
+ accept: application/yaml
199
+ """
200
+ Then the following reply is sent:
201
+ """
202
+ 200 OK
203
+ content-type: application/yaml
204
+
205
+ access: granted!
206
+ """
207
+
208
+ Scenario: Using `auth:rule` directive
209
+ Given the `identity.roles` database contains:
210
+ | _id | identity | role |
211
+ | 775a648d054e4ce1a65f8f17e5b51803 | efe3a65ebbee47ed95a73edd911ea328 | developer:rust |
212
+ And the annotation:
213
+ """yaml
214
+ /rust/:id:
215
+ auth:rule:
216
+ id: id
217
+ role: developer:rust
218
+ GET:
219
+ dev:stub:
220
+ access: granted!
221
+ /javascript/:id:
222
+ rule:
223
+ id: id
224
+ role: developer:javascript
225
+ GET:
226
+ dev:stub:
227
+ access: granted!
228
+ """
229
+ When the following request is received:
230
+ """
231
+ GET /rust/efe3a65ebbee47ed95a73edd911ea328/ HTTP/1.1
232
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldA==
233
+ accept: application/yaml
234
+ """
235
+ Then the following reply is sent:
236
+ """
237
+ 200 OK
238
+ content-type: application/yaml
239
+
240
+ access: granted!
241
+ """
242
+ When the following request is received:
243
+ """
244
+ GET /javascript/efe3a65ebbee47ed95a73edd911ea328/ HTTP/1.1
245
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldA==
246
+ """
247
+ Then the following reply is sent:
248
+ """
249
+ 403 Forbidden
250
+ """
251
+
252
+ Scenario: Token authentication scheme
253
+ Given the annotation:
254
+ """yaml
255
+ /:id:
256
+ auth:id: id
257
+ GET:
258
+ dev:stub:
259
+ access: granted!
260
+ """
261
+ When the following request is received:
262
+ """
263
+ GET /efe3a65ebbee47ed95a73edd911ea328/ HTTP/1.1
264
+ authorization: Token v3.local.9oEtVJkfRw4cOJ8M4DxuVuAN29dGT26XMYyPAoXtwrkdkiJVSVj46sMNAOdlxwKGszJZV_ReOL26dxDVlsQ7QAIuRhRPlvsHYNOhcD-LApoAXV0S3IK16EMoEv7tE9z70FCLC3WoIW9RIQ8PR3uZhAdhSgBilsVOpWrk4XtnfCIlVwhYMKu79a66oZZhV2Q7Kl3nfYsf84-6rAL_1H0MsqCDUHVXuIg
265
+ accept: application/yaml
266
+ """
267
+ Then the following reply is sent:
268
+ """
269
+ 200 OK
270
+ content-type: application/yaml
271
+
272
+ access: granted!
273
+ """
274
+ And the reply does not contain:
275
+ """
276
+ authorization: Token
277
+ """
278
+ When the following request is received:
279
+ """
280
+ GET /efe3a65ebbee47ed95a73edd911ea328/ HTTP/1.1
281
+ authorization: Token v3.local.cjlxn4IJ9hI92KuksguzDx7_kYxgDFFGFnfNchf0cWnmos34dqX2XpTAUBd-LqgqfuH-lVGfNvjBUkw5JtHRBiIAVaPHF3Ncc0eafwgH2DPme9pndZL92fWryGnJ-sMHA28Q6UcXsIfhgd2JZ0n-585SBhwlosC3gKTcVHK7XNljeaTen4jZPw8uY-pdbsm6dDq3aKMzl8K78_BTTfiNPG2cI_aNuHw
282
+ accept: application/yaml
283
+ """
284
+ Then the following reply is sent:
285
+ """
286
+ 403 Forbidden
287
+ """
288
+
289
+ Scenario: Using token with roles
290
+ Given the annotation:
291
+ """yaml
292
+ /:
293
+ auth:role: developer
294
+ GET:
295
+ dev:stub:
296
+ access: granted!
297
+ """
298
+ And the `identity.roles` database contains:
299
+ | _id | identity | role |
300
+ | 775a648d054e4ce1a65f8f17e5b51803 | efe3a65ebbee47ed95a73edd911ea328 | developer |
301
+ When the following request is received:
302
+ """
303
+ GET / HTTP/1.1
304
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldA==
305
+ accept: application/yaml
306
+ """
307
+ Then the following reply is sent:
308
+ """
309
+ 200 OK
310
+ content-type: application/yaml
311
+ authorization: Token ${{ token }}
312
+
313
+ access: granted!
314
+ """
315
+ When the following request is received:
316
+ """
317
+ GET / HTTP/1.1
318
+ authorization: Token ${{ token }}
319
+ accept: application/yaml
320
+ """
321
+ Then the following reply is sent:
322
+ """
323
+ 200 OK
324
+ content-type: application/yaml
325
+
326
+ access: granted!
327
+ """
328
+
329
+ Scenario: Using `auth:scheme` directive
330
+ Given the annotation:
331
+ """yaml
332
+ /:id:
333
+ auth:scheme: basic
334
+ auth:id: id
335
+ GET:
336
+ dev:stub:
337
+ access: granted!
338
+ """
339
+ When the following request is received:
340
+ """
341
+ GET /efe3a65ebbee47ed95a73edd911ea328/ HTTP/1.1
342
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldA==
343
+ accept: application/yaml
344
+ """
345
+ Then the following reply is sent:
346
+ """
347
+ 200 OK
348
+ content-type: application/yaml
349
+
350
+ access: granted!
351
+ """
352
+ When the following request is received:
353
+ """
354
+ GET /efe3a65ebbee47ed95a73edd911ea328/ HTTP/1.1
355
+ authorization: Token v3.local.9oEtVJkfRw4cOJ8M4DxuVuAN29dGT26XMYyPAoXtwrkdkiJVSVj46sMNAOdlxwKGszJZV_ReOL26dxDVlsQ7QAIuRhRPlvsHYNOhcD-LApoAXV0S3IK16EMoEv7tE9z70FCLC3WoIW9RIQ8PR3uZhAdhSgBilsVOpWrk4XtnfCIlVwhYMKu79a66oZZhV2Q7Kl3nfYsf84-6rAL_1H0MsqCDUHVXuIg
356
+ accept: text/plain
357
+ """
358
+ Then the following reply is sent:
359
+ """
360
+ 403 Forbidden
361
+
362
+ Basic authentication scheme is required to access this resource.
363
+ """
364
+
365
+ Scenario: Adding a role without required permissions
366
+
367
+ Trunk directives should not be applied to the Identity management resources.
368
+
369
+ Given the annotation:
370
+ """yaml
371
+ anonymous: true
372
+ """
373
+ When the following request is received:
374
+ """
375
+ POST /identity/roles/efe3a65ebbee47ed95a73edd911ea328/ HTTP/1.1
376
+ content-type: application/yaml
377
+
378
+ role: developer
379
+ """
380
+ Then the following reply is sent:
381
+ """
382
+ 401 Unauthorized
383
+ """
384
+
385
+ Scenario: Banning an Identity
386
+ Given the `identity.roles` database contains:
387
+ | _id | identity | role |
388
+ | 775a648d054e4ce1a65f8f17e5b51803 | efe3a65ebbee47ed95a73edd911ea328 | system |
389
+ And the annotation:
390
+ """yaml
391
+ /:id:
392
+ auth:id: id
393
+ GET:
394
+ dev:stub:
395
+ access: granted!
396
+ """
397
+ And the `identity.tokens` configuration:
398
+ """yaml
399
+ refresh: 1
400
+ """
401
+ When the following request is received:
402
+ """
403
+ GET /e8e4f9c2a68d419b861403d71fabc915/ HTTP/1.1
404
+ authorization: Basic dXNlcjoxMjM0NQ==
405
+ """
406
+ Then the following reply is sent:
407
+ """
408
+ 200 OK
409
+ authorization: Token ${{ token }}
410
+ """
411
+ When the following request is received:
412
+ """
413
+ PUT /identity/bans/e8e4f9c2a68d419b861403d71fabc915/ HTTP/1.1
414
+ authorization: Basic ZGV2ZWxvcGVyOnNlY3JldA==
415
+ content-type: application/yaml
416
+
417
+ banned: true
418
+ """
419
+ Then the following reply is sent:
420
+ """
421
+ 204 No Content
422
+ """
423
+ # accessing a resource with a banned Identity
424
+ When the following request is received:
425
+ """
426
+ GET /e8e4f9c2a68d419b861403d71fabc915/ HTTP/1.1
427
+ authorization: Basic dXNlcjoxMjM0NQ==
428
+ """
429
+ Then the following reply is sent:
430
+ """
431
+ 401 Unauthorized
432
+ """
433
+ Then after 1 second
434
+ When the following request is received:
435
+ """
436
+ GET /e8e4f9c2a68d419b861403d71fabc915/ HTTP/1.1
437
+ authorization: Token ${{ token }}
438
+ """
439
+ Then the following reply is sent:
440
+ """
441
+ 401 Unauthorized
442
+ """
@@ -0,0 +1,28 @@
1
+ Feature: Annotation
2
+
3
+ Scenario: Simple annotation
4
+ Given the annotation:
5
+ """yaml
6
+ anonymous: true
7
+ /foo:
8
+ GET:
9
+ endpoint: pots.enumerate
10
+ """
11
+ And the `pots` is running
12
+ And the `pots` database contains:
13
+ | _id | title | volume |
14
+ | 4c4759e6f9c74da989d64511df42d6f4 | First pot | 100 |
15
+ When the following request is received:
16
+ """
17
+ GET /foo/ HTTP/1.1
18
+ accept: application/yaml
19
+ """
20
+ Then the following reply is sent:
21
+ """
22
+ 200 OK
23
+ content-type: application/yaml
24
+
25
+ - id: 4c4759e6f9c74da989d64511df42d6f4
26
+ title: First pot
27
+ volume: 100
28
+ """
@@ -0,0 +1,21 @@
1
+ Feature: Request body
2
+
3
+ Scenario: Creating an entity
4
+ Given the `pots` is running with the following manifest:
5
+ """yaml
6
+ exposition:
7
+ /:
8
+ POST: transit
9
+ """
10
+ When the following request is received:
11
+ """
12
+ POST /pots/ HTTP/1.1
13
+ content-type: application/yaml
14
+
15
+ title: Hello
16
+ volume: 1.5
17
+ """
18
+ Then the following reply is sent:
19
+ """
20
+ 201 Created
21
+ """
@@ -0,0 +1,56 @@
1
+ Feature: Directives
2
+
3
+ Scenario: Basic directive
4
+ Given the annotation:
5
+ """yaml
6
+ anonymous: true
7
+ /:
8
+ GET:
9
+ dev:stub:
10
+ hello: world
11
+ """
12
+ When the following request is received:
13
+ """
14
+ GET / HTTP/1.1
15
+ accept: application/json
16
+ """
17
+ Then the following reply is sent:
18
+ """
19
+ 200 OK
20
+ content-type: application/json
21
+
22
+ {"hello":"world"}
23
+ """
24
+
25
+ Scenario: Nested routes
26
+ Given the annotation:
27
+ """yaml
28
+ anonymous: true
29
+ /:
30
+ dev:stub:
31
+ hello: again
32
+ GET: {}
33
+ /pots:
34
+ GET: {}
35
+ """
36
+ When the following request is received:
37
+ """
38
+ GET /pots/ HTTP/1.1
39
+ accept: application/yaml
40
+ """
41
+ Then the following reply is sent:
42
+ """
43
+ 200 OK
44
+ content-type: application/yaml
45
+
46
+ hello: again
47
+ """
48
+ When the following request is received:
49
+ """
50
+ GET /pots/non-existent/ HTTP/1.1
51
+ accept: application/yaml
52
+ """
53
+ Then the following reply is sent:
54
+ """
55
+ 404 Not Found
56
+ """
@@ -0,0 +1,89 @@
1
+ Feature: Dynamic tree updates
2
+
3
+ Background:
4
+ Given the `pots` database contains:
5
+ | _id | title | volume | temperature |
6
+ | 4c4759e6f9c74da989d64511df42d6f4 | First pot | 100 | 80 |
7
+
8
+ Scenario: Updating routes
9
+ And the `pots` is running with the following manifest:
10
+ """yaml
11
+ exposition:
12
+ /:
13
+ POST: transit
14
+ """
15
+ Then the `pots` is stopped
16
+ Then the `pots` is running with the following manifest:
17
+ """yaml
18
+ exposition:
19
+ /:
20
+ GET: enumerate
21
+ """
22
+ When the following request is received:
23
+ """
24
+ GET /pots/ HTTP/1.1
25
+ accept: application/yaml
26
+ """
27
+ Then the following reply is sent:
28
+ """
29
+ 200 OK
30
+ """
31
+
32
+ Scenario: Updating routes with conflict
33
+ And the `pots` is running with the following manifest:
34
+ """yaml
35
+ exposition:
36
+ /:id:
37
+ GET: observe
38
+ """
39
+ Then the `pots` is stopped
40
+ Then the `pots` is running with the following manifest:
41
+ """yaml
42
+ exposition:
43
+ /:id:
44
+ GET: observe
45
+ /big:
46
+ GET:
47
+ endpoint: enumerate
48
+ query:
49
+ criteria: volume>200
50
+ """
51
+ When the following request is received:
52
+ """
53
+ GET /pots/big/ HTTP/1.1
54
+ accept: application/yaml
55
+ """
56
+ Then the following reply is sent:
57
+ """
58
+ 200 OK
59
+ """
60
+
61
+ Scenario: Updating method mapping
62
+ Given the `pots` is running with the following manifest:
63
+ """yaml
64
+ exposition:
65
+ /big:
66
+ GET:
67
+ endpoint: enumerate
68
+ query:
69
+ criteria: volume>200 # closed
70
+ """
71
+ Then the `pots` is stopped
72
+ Then the `pots` is running with the following manifest:
73
+ """yaml
74
+ exposition:
75
+ /big:
76
+ GET:
77
+ endpoint: enumerate
78
+ query:
79
+ criteria: volume>200; # open
80
+ """
81
+ When the following request is received:
82
+ """
83
+ GET /pots/big/?criteria=temperature>50 HTTP/1.1
84
+ accept: application/yaml
85
+ """
86
+ Then the following reply is sent:
87
+ """
88
+ 200 OK
89
+ """