gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit15b996a515b996a5Org list: keyed rows by @id, newest first, concat instead of hand loopmre15b996a5/tests/app-auth-unit.hl

1.7 KB

  1. // tests/app-auth-unit.hl — run by tests/app-token.mjs with its own GITORIA_STORAGE: appOfRequest (lib/app-auth.hl) called directly, because no apps API route uses it yet (#44).
  2. // Prints one line per case: `<case> <status or ok>`.
  3. import { now } from 'hl:time'
  4. import { sha256 } from 'hl:crypto'
  5. import { reposTable } from './../lib/repos.hl'
  6. import { removeApp } from './../lib/apps.hl'
  7. import { appsTable } from './../lib/apps-table.hl'
  8. import { issueToken, dropTokensOfApp } from './../lib/app-tokens.hl'
  9. import { appOfRequest } from './../lib/app-auth.hl'
  10. r1 = reposTable.put({ slug = 'one' description = 'x' owner = 'u' created = now() org = '' priv = true })
  11. r2 = reposTable.put({ slug = 'two' description = 'x' owner = 'u' created = now() org = '' priv = false })
  12. a1 = appsTable.put({ repo = r1 name = 'A' hookUrl = 'https://x.worldapi.org/' keyHash = sha256('k1') secret = 's' createdBy = 'u' created = now() lastDelivery = 0 lastStatus = '' })
  13. app1 = appsTable.fetch(a1)
  14. t = issueToken(app1)
  15. static ask = (host, token) => {
  16. headers = { host = host }
  17. if (token != null) { headers['authorization'] = 'Bearer ' + token }
  18. return appOfRequest({ params = {} }, { headers = headers })
  19. }
  20. static show = (label, r) => {
  21. console.log(label + ' ' + (r.error != null ? r.error.status + ' ' + JSON.parse(r.error.body).error.code : 'ok ' + r.app.name + ' ' + r.repo.slug))
  22. }
  23. show('good', ask('one.localhost:1', t.token))
  24. show('none', ask('one.localhost:1', null))
  25. show('unknown', ask('one.localhost:1', 'gat_' + 'b'.repeat(40)))
  26. show('other-repo', ask('two.localhost:1', t.token))
  27. show('no-repo', ask('zzz.localhost:1', t.token))
  28. dropTokensOfApp(a1)
  29. show('dropped', ask('one.localhost:1', t.token))
  30. t2 = issueToken(app1)
  31. appsTable.delete(a1)
  32. show('app-gone', ask('one.localhost:1', t2.token))

Branches

Latest commits

  • 15b996a5Org list: keyed rows by @id, newest first, concat instead of hand loopmre
  • 85c86605log: 2026-11-08 Arachne on list shapemre
  • cb634512log: 2026-11-08 keyed lists livemre
  • 07c98d4aLists: keyed rows with @id, remove(id) and one whole-list assignment instead of hand-rebuilt loopsmre
  • 0db0d81elog: 2026-11-08 day52 live, W30 startedmre
  • b05f6d92tests/status: the gate's 3 s app token expired during the restart; it lives 60 s like status-keyedmre
  • 1e8f4f0avendor: Hybriel set-day52 (fault-path leak fix #335, keyed rows #331)mre
  • f5f0fb7blog: 2026-11-08 day50/#29 live, H25 correction, V52 startedmre
  • dc77fb95main: offline note from __hlOnline, tick removed (#29)mre
  • 37a86d93tests/reviews: seeded fake hook's DNS failures are not server errors (flaky gate)mre
  • 07ab845bvendor: Hybriel set-day50 (run() leak fix #335)mre
  • 71b2fa4blog: hybriel#335mre
  • bd94cc7elog: #25 cause found (run() leak)mre
  • 565cb508log: H25 round 1mre
  • 90a0af84log: H25 startedmre
  • 87bd53b8mission H25mre
  • 71a746cflog: day48 livemre
  • bf568e14log: V48 mergedmre
  • 09955dedMerge v48: Hybriel set-day48, theme layouts ce4a0bamre
  • f2a2b0cevendor: Hybriel set-day48, theme layouts ce4a0bamre