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
- ac5ba6a4log: W60, #25 measuredmre
- 452f6a1amission W60: logic clean-upsmre
- 1448c899log: cleanup, #49 GPTBot, tracker mentions on #36mre
- fcf95936log: v1.5.1 provenmre
- 22105420log: W51b livemre
- 7e8aabeareport: W51b pull source verificationmre
- 6c18de76fix: preserve pull sources across containing branchesmre
- fc36fa2elog: W51b pull source bugmre
- 56bc1220log: v1.5.1 livemre
- 845fc0aareport: W51mre
- 83127391fix: return v1.5.1 app and merge error detailsmre
- b07d0e97log: W51 v1.5.1 startedmre
- 0b417d06docs: apps-api v1.5 user tokens (#48, W49)mre
- d046940alog: vinzenz contract note sentmre
- db443456log: vinzenz note retry 2mre
- 802f229alog: kunibert repo ping provenmre
- 2d2eaa92log: Kunibert connected to kunibert repomre
- 65d5f80alogmre
- dab74b0dW49 report, logmre
- fd4fc028Exercise member status reads with a populated check statemre