gitoriaLog in with ident

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitcc063ea2cc063ea2deploy.sh: never send .git or .gitignore to Byrodinmrecc063ea2/tests/oldstore-009.hl

3.5 KB

  1. // tests/oldstore-009.hl — THE MIGRATION FIXTURE (tests/migration.mjs): an ident store in the
  2. // OLD format (before mission 009: `*id` tables `<prefix>-<table>.*`, public ids = id + 1),
  3. // with known keys, secret hashes and per-app ids. OLD_PREFIX=/abs/dir/ident
  4. import { MPackDB } from 'hl:mpackdb'
  5. import { env } from 'hl:proc'
  6. import { now } from 'hl:time'
  7. import { sha256 } from 'hl:crypto'
  8. let p = env('OLD_PREFIX')
  9. let accounts = new MPackDB(file = p + '-accounts.db', primaryKey = '*id', indexes = ['!email'])
  10. let identities = new MPackDB(file = p + '-identities.db', primaryKey = '*id', indexes = ['account'])
  11. let otp = new MPackDB(file = p + '-otp.db', primaryKey = '*id', indexes = ['email'])
  12. let sends = new MPackDB(file = p + '-sends.db', primaryKey = '*id', indexes = ['email'])
  13. let apps = new MPackDB(file = p + '-apps.db', primaryKey = '*id', indexes = ['owner' '!apiKey'])
  14. let conns = new MPackDB(file = p + '-connections.db', primaryKey = '*id', indexes = ['!pair' 'app' '!appIdentity'])
  15. let requests = new MPackDB(file = p + '-requests.db', primaryKey = '*id', indexes = ['!rid'])
  16. let grants = new MPackDB(file = p + '-grants.db', primaryKey = '*id', indexes = ['!hash'])
  17. let t = now()
  18. let x = (c, n) => {
  19. let s = ''
  20. while (s.length < n) { s = s + c }
  21. return s
  22. }
  23. accounts.put({ email = '[email protected]' timeZone = 'Europe/Vienna' created = t - 90000 }) // public 1
  24. accounts.put({ email = '[email protected]' timeZone = 'Asia/Tokyo' created = t - 80000 }) // public 2
  25. identities.put({ account = 1 identityName = 'Default' nickname = 'Al' firstname = 'Alice' lastname = 'Example' created = t - 89000 updated = t - 1000 }) // 1
  26. identities.put({ account = 1 identityName = 'Work' nickname = '' firstname = '' lastname = '' created = t - 70000 updated = t - 70000 }) // 2
  27. identities.put({ account = 2 identityName = 'Default' nickname = '' firstname = '' lastname = '' created = t - 79000 updated = t - 79000 }) // 3
  28. let gone = identities.put({ account = 1 identityName = 'Old' nickname = '' firstname = '' lastname = '' created = t - 60000 updated = t - 60000 }) // 4, deleted below
  29. apps.put({ owner = 1 name = 'Fixture app' origins = 'http://127.0.0.1:8396' apiKey = 'pk_' + x('1', 32) secretHash = sha256('sk_' + x('2', 48)) created = t - 50000 updated = t - 50000 }) // 1
  30. apps.put({ owner = 2 name = 'Bob app' origins = 'http://127.0.0.1:8397' apiKey = 'pk_' + x('3', 32) secretHash = sha256('sk_' + x('4', 48)) created = t - 40000 updated = t - 40000 }) // 2
  31. conns.put({ pair = '1:1' app = 1 identity = 1 appIdentity = x('a', 32) created = t - 49000 })
  32. conns.put({ pair = '1:2' app = 1 identity = 2 appIdentity = x('b', 32) created = t - 48000 })
  33. conns.put({ pair = '1:4' app = 1 identity = 4 appIdentity = x('c', 32) created = t - 47000 })
  34. conns.put({ pair = '2:3' app = 2 identity = 3 appIdentity = x('d', 32) created = t - 39000 })
  35. identities.delete(gone)
  36. sends.put({ email = '[email protected]' at = t - 1000 })
  37. otp.put({ email = '[email protected]' hash = sha256('[email protected]:123456') expires = t + 600000 tries = 0 })
  38. requests.put({ rid = x('f', 32) app = 1 returnUrl = 'http://127.0.0.1:8396/callback' expires = t + 1800000 })
  39. grants.put({ hash = sha256(x('e', 48)) app = 1 identity = 2 appIdentity = x('b', 32) expires = t + 3600000 })
  40. console.log('oldstore: accounts ' + accounts.count() + ' identities ' + identities.count() + ' apps ' + apps.count() + ' connections ' + conns.count() + ' otp ' + otp.count() + ' sends ' + sends.count() + ' requests ' + requests.count() + ' grants ' + grants.count())

Branches

Latest commits

  • cc063ea2deploy.sh: never send .git or .gitignore to Byrodinmre
  • 81b15b7bState of 2026-09-27, before the move to gitoriamre