gitoria
All repositories: gitoria
1.7 KB
// 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).// Prints one line per case: `<case> <status or ok>`.import { now } from 'hl:time'import { sha256 } from 'hl:crypto'import { reposTable } from './../lib/repos.hl'import { removeApp } from './../lib/apps.hl'import { appsTable } from './../lib/apps-table.hl'import { issueToken, dropTokensOfApp } from './../lib/app-tokens.hl'import { appOfRequest } from './../lib/app-auth.hl'r1 = reposTable.put({ slug = 'one' description = 'x' owner = 'u' created = now() org = '' priv = true })r2 = reposTable.put({ slug = 'two' description = 'x' owner = 'u' created = now() org = '' priv = false })a1 = appsTable.put({ repo = r1 name = 'A' hookUrl = 'https://x.worldapi.org/' keyHash = sha256('k1') secret = 's' createdBy = 'u' created = now() lastDelivery = 0 lastStatus = '' })app1 = appsTable.fetch(a1)t = issueToken(app1)static ask = (host, token) => {headers = { host = host }if (token != null) { headers['authorization'] = 'Bearer ' + token }return appOfRequest({ params = {} }, { headers = headers })}static show = (label, r) => {console.log(label + ' ' + (r.error != null ? r.error.status + ' ' + JSON.parse(r.error.body).error.code : 'ok ' + r.app.name + ' ' + r.repo.slug))}show('good', ask('one.localhost:1', t.token))show('none', ask('one.localhost:1', null))show('unknown', ask('one.localhost:1', 'gat_' + 'b'.repeat(40)))show('other-repo', ask('two.localhost:1', t.token))show('no-repo', ask('zzz.localhost:1', t.token))dropTokensOfApp(a1)show('dropped', ask('one.localhost:1', t.token))t2 = issueToken(app1)appsTable.delete(a1)show('app-gone', ask('one.localhost:1', t2.token))
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- e9f950a8reports: G25c soakmre
- a7783686log: deploy 9f41ffcmre
- 9f41ffc1log: W30b mergedmre
- bef635c1Merge branch 'w30b'mre
- 15b996a5Org list: keyed rows by @id, newest first, concat instead of hand loopmre
- c4f6d9e3reports: G25c growth huntmre
- b88e39f1log: privacy cleanup donemre
- bfd7826ddocs: neutral example organisation namemre
- 01b71c2edocs: neutral wording in missions, reports and logmre
- 3eeea733log: 2026-11-09 PR flow plan and membersmre
- e7c2ff1fdocs: neutral name for the apps-api reviewmre
- 120b7abdlog: step 3 queuedmre
- 358474bflog: P50 livemre
- 477d7bdcMerge branch 'p50'mre
- 00efc06fP50 reportmre
- e3f85afblog: commit mention slipmre
- 4d1a4cf4log: #25 numbersmre
- 1af0a60ddocs: H25 run() correctionmre
- eefa2dbcRepo setting: refuse direct pushes to the main branch (pre-receive over HTTPS and ssh)mre
- 8c8ba2f1log: PR flow announcedmre