gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit55c8477955c84779Merge branch 'gp-gate-ports' into mainGitoria55c84779/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

  • 55c84779Merge branch 'gp-gate-ports' into mainGitoria
  • 57af42bbREADME: point to deploy.sh for the port listmre
  • d63375d2README: gate commands with explicit portsmre
  • feeaa701|||PR gates: explicit ports only, deploy.sh passes themmre
  • 6cc1f943Merge branch 'records-1112' into mainGitoria
  • 9448c438|||PR records: LOG, missions and reports since 11-09mre
  • 6dc08a8eMerge branch 'p51-public-pr-reads' into mainGitoria
  • 7b88cfe0Type publicReaderOfRequest parameters (L10)Gitoria
  • 2a4b3dc1|||PR Anonymous reads of public repos' pulls and statusesmre
  • 21b2c141Merge branch 's25-no-session-on-login-error' into mainGitoria
  • 698458e2|||PR No session for cookieless login errors: READMEmre
  • cce7b785|||PR No session for cookieless login errorsmre
  • 678d6303Merge branch 'v59' into mainGitoria
  • 5803cf4f|||PR vendor: Hybriel set-day59 and GC budget 32 MiBmre
  • 9eff6627Merge branch 'f2-api-bugs' into mainGitoria
  • 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