@toa.io/extensions.exposition 1.0.0-alpha.20 → 1.0.0-alpha.22
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/components/context.toa.yaml +2 -2
- package/components/identity.basic/manifest.toa.yaml +18 -9
- package/components/identity.basic/operations/authenticate.d.ts +5 -1
- package/components/identity.basic/operations/authenticate.js +2 -2
- package/components/identity.basic/operations/authenticate.js.map +1 -1
- package/components/identity.basic/operations/incept.d.ts +11 -0
- package/components/identity.basic/operations/incept.js +13 -0
- package/components/identity.basic/operations/incept.js.map +1 -0
- package/components/identity.basic/operations/transit.d.ts +3 -3
- package/components/identity.basic/operations/transit.js +5 -3
- package/components/identity.basic/operations/transit.js.map +1 -1
- package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/operations/types.d.ts +2 -0
- package/components/identity.basic/source/authenticate.ts +12 -5
- package/components/identity.basic/source/incept.ts +22 -0
- package/components/identity.basic/source/transit.ts +7 -5
- package/components/identity.basic/source/types.ts +2 -0
- package/components/identity.federation/manifest.toa.yaml +28 -11
- package/components/identity.federation/operations/authenticate.d.ts +2 -2
- package/components/identity.federation/operations/authenticate.js +6 -5
- package/components/identity.federation/operations/authenticate.js.map +1 -1
- package/components/identity.federation/operations/incept.d.ts +11 -0
- package/components/identity.federation/operations/{create.js → incept.js} +6 -7
- package/components/identity.federation/operations/incept.js.map +1 -0
- package/components/identity.federation/operations/lib/jwt.js +3 -3
- package/components/identity.federation/operations/lib/jwt.js.map +1 -1
- package/components/identity.federation/operations/schemas.d.ts +7 -3
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/operations/types.d.ts +5 -0
- package/components/identity.federation/source/authenticate.ts +9 -6
- package/components/identity.federation/source/{create.ts → incept.ts} +10 -9
- package/components/identity.federation/source/lib/jwt.test.ts +2 -2
- package/components/identity.federation/source/lib/jwt.ts +3 -3
- package/components/identity.federation/source/schemas.ts +7 -3
- package/components/identity.federation/source/types.ts +6 -0
- package/components/identity.tokens/manifest.toa.yaml +7 -1
- package/components/identity.tokens/operations/authenticate.d.ts +2 -2
- package/components/identity.tokens/operations/authenticate.js +5 -2
- package/components/identity.tokens/operations/authenticate.js.map +1 -1
- package/components/identity.tokens/operations/decrypt.js +1 -0
- package/components/identity.tokens/operations/decrypt.js.map +1 -1
- package/components/identity.tokens/operations/encrypt.js +1 -0
- package/components/identity.tokens/operations/encrypt.js.map +1 -1
- package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/operations/types.d.ts +7 -0
- package/components/identity.tokens/source/authenticate.test.ts +11 -4
- package/components/identity.tokens/source/authenticate.ts +7 -3
- package/components/identity.tokens/source/decrypt.test.ts +5 -3
- package/components/identity.tokens/source/decrypt.ts +9 -8
- package/components/identity.tokens/source/encrypt.test.ts +4 -1
- package/components/identity.tokens/source/encrypt.ts +1 -0
- package/components/identity.tokens/source/types.ts +8 -0
- package/documentation/authorities.md +53 -0
- package/documentation/components.md +3 -3
- package/documentation/identity.md +17 -22
- package/documentation/require.md +1 -1
- package/documentation/vary.md +5 -11
- package/features/access.feature +55 -7
- package/features/annotation.feature +1 -0
- package/features/authorities.basic.feature +140 -0
- package/features/authorities.feature +32 -0
- package/features/authorities.federation.feature +99 -0
- package/features/authorities.tokens.feature +118 -0
- package/features/body.feature +2 -0
- package/features/cache.feature +39 -5
- package/features/cors.feature +4 -0
- package/features/directives.feature +3 -0
- package/features/dynamic.feature +4 -0
- package/features/errors.feature +12 -1
- package/features/etag.feature +6 -0
- package/features/identity.bans.feature +12 -3
- package/features/identity.basic.feature +34 -15
- package/features/identity.feature +7 -2
- package/features/identity.federation.feature +14 -4
- package/features/identity.roles.feature +29 -17
- package/features/identity.tokens.feature +18 -6
- package/features/io.feature +9 -0
- package/features/octets.entries.feature +8 -0
- package/features/octets.feature +22 -0
- package/features/octets.meta.feature +3 -0
- package/features/octets.workflows.feature +13 -0
- package/features/queries.feature +8 -0
- package/features/require.feature +3 -0
- package/features/response.feature +5 -2
- package/features/routes.feature +7 -0
- package/features/steps/Gateway.ts +23 -6
- package/features/streams.feature +1 -0
- package/features/timing.feature +3 -0
- package/features/vary.feature +49 -0
- package/package.json +7 -7
- package/readme.md +19 -14
- package/schemas/annotation.cos.yaml +1 -1
- package/source/Annotation.ts +3 -3
- package/source/Endpoint.ts +1 -1
- package/source/Factory.ts +8 -10
- package/source/Gateway.ts +2 -6
- package/source/HTTP/Context.ts +3 -1
- package/source/HTTP/Server.ts +23 -26
- package/source/HTTP/exceptions.ts +6 -0
- package/source/Query.ts +9 -5
- package/source/deployment.ts +25 -21
- package/source/directives/auth/Authorization.ts +18 -8
- package/source/directives/auth/Incept.ts +2 -1
- package/source/directives/vary/embeddings/Authority.ts +8 -0
- package/source/directives/vary/embeddings/index.ts +3 -1
- package/source/schemas.ts +1 -1
- package/transpiled/Annotation.d.ts +3 -3
- package/transpiled/Endpoint.js +1 -1
- package/transpiled/Endpoint.js.map +1 -1
- package/transpiled/Factory.js +9 -8
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Gateway.js.map +1 -1
- package/transpiled/HTTP/Context.d.ts +2 -1
- package/transpiled/HTTP/Context.js +3 -1
- package/transpiled/HTTP/Context.js.map +1 -1
- package/transpiled/HTTP/Server.d.ts +8 -1
- package/transpiled/HTTP/Server.js +14 -20
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/HTTP/exceptions.d.ts +3 -0
- package/transpiled/HTTP/exceptions.js +7 -1
- package/transpiled/HTTP/exceptions.js.map +1 -1
- package/transpiled/Query.js +2 -2
- package/transpiled/Query.js.map +1 -1
- package/transpiled/deployment.d.ts +1 -1
- package/transpiled/deployment.js +21 -19
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/directives/auth/Authorization.js +9 -4
- package/transpiled/directives/auth/Authorization.js.map +1 -1
- package/transpiled/directives/auth/Incept.js +2 -1
- package/transpiled/directives/auth/Incept.js.map +1 -1
- package/transpiled/directives/vary/embeddings/Authority.d.ts +5 -0
- package/transpiled/directives/vary/embeddings/Authority.js +10 -0
- package/transpiled/directives/vary/embeddings/Authority.js.map +1 -0
- package/transpiled/directives/vary/embeddings/index.js +3 -1
- package/transpiled/directives/vary/embeddings/index.js.map +1 -1
- package/transpiled/schemas.d.ts +1 -1
- package/transpiled/schemas.js +2 -2
- package/transpiled/schemas.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/operations/create.d.ts +0 -10
- package/components/identity.basic/operations/create.js +0 -10
- package/components/identity.basic/operations/create.js.map +0 -1
- package/components/identity.basic/source/create.ts +0 -18
- package/components/identity.federation/operations/create.d.ts +0 -10
- package/components/identity.federation/operations/create.js.map +0 -1
- package/source/HTTP/Server.test.ts +0 -126
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto'
|
|
2
|
-
import { Connector } from '@toa.io/core'
|
|
3
|
-
import { type Processing, Server } from './Server'
|
|
4
|
-
import { type OutgoingMessage } from './messages'
|
|
5
|
-
import { BadRequest } from './exceptions'
|
|
6
|
-
|
|
7
|
-
let server: Server
|
|
8
|
-
|
|
9
|
-
beforeAll(() => {
|
|
10
|
-
server = Server.create({ port: 0 })
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('should instance of connector', async () => {
|
|
14
|
-
expect(server).toBeInstanceOf(Connector)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('should start HTTP server', async () => {
|
|
18
|
-
await server.connect()
|
|
19
|
-
|
|
20
|
-
expect(server.connected).toBeTruthy()
|
|
21
|
-
expect(server.port).toBeGreaterThan(0)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('should register request handler', async () => {
|
|
25
|
-
const process: Processing = jest.fn().mockResolvedValue(undefined)
|
|
26
|
-
|
|
27
|
-
server.attach(process)
|
|
28
|
-
|
|
29
|
-
const res = await fetch(`http://localhost:${server.port}`)
|
|
30
|
-
|
|
31
|
-
await res.text()
|
|
32
|
-
|
|
33
|
-
expect(process).toHaveBeenCalledTimes(1)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('should send 501 on unknown method', async () => {
|
|
37
|
-
const head = await fetch(`http://localhost:${server.port}/`, { method: 'COPY' })
|
|
38
|
-
|
|
39
|
-
await head.text()
|
|
40
|
-
expect(head.status).toBe(501)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('should stop HTTP server', async () => {
|
|
44
|
-
await server.connect()
|
|
45
|
-
await server.disconnect()
|
|
46
|
-
expect(server.connected).toBeFalsy()
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
describe('result', () => {
|
|
50
|
-
beforeEach(async () => {
|
|
51
|
-
server = Server.create({ port: 0 })
|
|
52
|
-
await server.connect()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
afterEach(async () => {
|
|
56
|
-
await server.disconnect()
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should send status code 200 if the result has a value', async () => {
|
|
60
|
-
server.attach(async (): Promise<OutgoingMessage> => ({
|
|
61
|
-
headers: new Headers(), body: randomUUID()
|
|
62
|
-
}))
|
|
63
|
-
|
|
64
|
-
const res = await fetch(`http://localhost:${server.port}/`)
|
|
65
|
-
|
|
66
|
-
await res.text()
|
|
67
|
-
expect(res.status).toBe(200)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('should send status code 204 if the result has no value', async () => {
|
|
71
|
-
server.attach(async (): Promise<OutgoingMessage> => ({ headers: new Headers() }))
|
|
72
|
-
|
|
73
|
-
const res = await fetch(`http://localhost:${server.port}/`)
|
|
74
|
-
|
|
75
|
-
await res.text()
|
|
76
|
-
expect(res.status).toBe(204)
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it('should send result', async () => {
|
|
80
|
-
const body = { [randomUUID()]: randomUUID() }
|
|
81
|
-
|
|
82
|
-
server.attach(async (): Promise<OutgoingMessage> =>
|
|
83
|
-
({ headers: new Headers(), body }))
|
|
84
|
-
|
|
85
|
-
const res = await fetch(`http://localhost:${server.port}/`,
|
|
86
|
-
{ headers: { accept: 'application/json' } })
|
|
87
|
-
|
|
88
|
-
const result = await res.json()
|
|
89
|
-
|
|
90
|
-
expect(result).toEqual(body)
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
it('should return 500 on exception', async () => {
|
|
94
|
-
server.attach(jest.fn().mockRejectedValue(new Error('Bad')))
|
|
95
|
-
|
|
96
|
-
const res = await fetch(`http://localhost:${server.port}/`)
|
|
97
|
-
|
|
98
|
-
await res.text()
|
|
99
|
-
expect(res.status).toBe(500)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('should send client error', async () => {
|
|
103
|
-
const message = randomUUID()
|
|
104
|
-
|
|
105
|
-
server.attach(jest.fn().mockRejectedValueOnce(new BadRequest(message)))
|
|
106
|
-
|
|
107
|
-
const res = await fetch(`http://localhost:${server.port}/`)
|
|
108
|
-
const text = await res.text()
|
|
109
|
-
|
|
110
|
-
expect(res.status).toBe(400)
|
|
111
|
-
expect(text).toContain(message)
|
|
112
|
-
})
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
describe('options', () => {
|
|
116
|
-
it('should send 501 on unspecified method', async () => {
|
|
117
|
-
server = Server.create({ methods: new Set(['COPY']), port: 0 })
|
|
118
|
-
await server.connect()
|
|
119
|
-
|
|
120
|
-
const res = await fetch(`http://localhost:${server.port}/`)
|
|
121
|
-
|
|
122
|
-
await res.text()
|
|
123
|
-
await server.disconnect()
|
|
124
|
-
expect(res.status).toBe(501)
|
|
125
|
-
})
|
|
126
|
-
})
|