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
Latest commits
- 26117255|||PR apps API: review comments on files with spaces in their namemre
- b8796cecMerge branch 'f1-broken-json' into mainGitoria
- 2f2959c5|||PR apps API: broken JSON body gives 400 invalid_json, not 500mre
- f7c6ca07Merge branch 'ident-chooser-selector' into mainGitoria
- 691abb8e|||PR tests: find ident identity choice without the removed .choose classmre
- 16a3530fMerge branch 'heap-revert' into mainGitoria
- 220a80e0|||PR Remove temporary /__heap route and heap helper; logmre
- 13f0c342Merge branch 'hl25-records' into mainGitoria
- a002ecb7|||PR records: HL25 report, heap helper, logmre
- 2492a55cTemporary keyed /__heap route for the live memory snapshotmre
- fefaedd2log: tracker PR-only, HL25 startedmre
- 21aa57calog: parkmre
- 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