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
- f6d32341log: Apollo on budget and #25 nextmre
- d7184f53log: batch live, #25 evidencemre
- 5e25e816log: W61 mergedmre
- aafe330dTidy: drop evidence JSON (kept in scratch), collapse blank linesmre
- aca1fda1Merge W61: theme from layouts 17e0f03, Views refer to Style rules (gitoria#37 #27)mre
- 03cb650blog: W61 theme decisionmre
- 248bce85Report final style gates, CSS mappings and 136 whole-image comparisonsmre
- 153c344bRestore organization metadata exposed by the whole-image comparisonmre
- 917a1465Update status gate assertions for the referenced state rulemre
- 3cdb02c6Own settings feedback styles and explain connection-state classesmre
- 00d5d6c4Reference code-entry styles and nest code-browser media and pseudosmre
- 3c425eddReference PR content styles and explain dynamic state classesmre
- e46fa222Own shell feedback styles and retain documented selector formsmre
- c26084c4Reference repository list styles and nest its breakpointmre
- f3e196b5Document Markdown direct-child selector remaindersmre
- 70597528Reference pull list rules and explain runtime class predicatesmre
- 1ce7ac24Reference ticket row and feedback styles from its Viewmre
- 10cdf54bGive organization repository rows their own Style referencesmre
- 0d019521Document shared class selectors in the styles-only filemre
- c67404a7Scope token labels and feedback through the token Viewmre