@crombolo/remote-conformance 0.26.0 → 0.28.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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +18 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/remote-conformance",
3
- "version": "0.26.0",
3
+ "version": "0.28.0",
4
4
  "description": "Checks a server against the Crombolo remote protocol: discovery, sign-in, environments, pulls, pushes and media by reference.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
package/src/index.ts CHANGED
@@ -205,6 +205,24 @@ export async function runConformance(options: ConformanceOptions): Promise<Confo
205
205
  assert(body.links?.['conformance/not-there.png'] === null, 'the missing file was not null')
206
206
  })
207
207
 
208
+ await check('the audit log answers a page, oldest first after a cursor', async () => {
209
+ const capabilities = (state.discovery?.capabilities as string[] | undefined) ?? []
210
+ if (!capabilities.includes('audit') || !state.may?.audit) return 'skip'
211
+ const response = await api(`environments/${state.environment}/audit?after=0&limit=5`)
212
+ assert(response.status === 200, `answered ${response.status}`)
213
+ const body = (await response.json()) as { items?: Json[]; next?: unknown; truncated?: unknown }
214
+ assert(Array.isArray(body.items), 'items is missing')
215
+ assert(typeof body.truncated === 'boolean', 'truncated is missing')
216
+ const ids = (body.items ?? []).map((item) => Number(item.id))
217
+ assert(
218
+ ids.every((id, index) => index === 0 || id > (ids[index - 1] as number)),
219
+ 'the entries are not oldest first',
220
+ )
221
+ const refused = await api(`environments/${state.environment}/audit?limit=501`)
222
+ assert(refused.status === 400, `a limit over 500 answered ${refused.status}`)
223
+ assert(isProblem(refused), 'not application/problem+json')
224
+ })
225
+
208
226
  await check('a push check answers what would be recycled and removed', async () => {
209
227
  const capabilities = (state.discovery?.capabilities as string[] | undefined) ?? []
210
228
  if (!capabilities.includes('push-check') || !state.may?.push) return 'skip'