@superhero/eventflow-db 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/config.js +2 -5
- package/index.js +16 -0
- package/index.test.js +17 -2
- package/package.json +2 -2
- package/sql/certificate/revoke-past-validity.sql +12 -0
package/README.md
CHANGED
|
@@ -481,6 +481,10 @@ npm test
|
|
|
481
481
|
▶ Revoke a persisted certificate
|
|
482
482
|
✔ Reading a revoked certificate should reject with an error (3.894204ms)
|
|
483
483
|
✔ Revoke a persisted certificate (14.21005ms)
|
|
484
|
+
|
|
485
|
+
▶ Revoke certificates that past there validity period
|
|
486
|
+
✔ Reading a revoked certificate should reject with an error (2.925027ms)
|
|
487
|
+
✔ Revoke certificates that past there validity period (13.092224ms)
|
|
484
488
|
✔ Certificate management (44.130336ms)
|
|
485
489
|
✔ Persist a hub (339.721847ms)
|
|
486
490
|
|
package/config.js
CHANGED
package/index.js
CHANGED
|
@@ -739,4 +739,20 @@ export default class DB
|
|
|
739
739
|
throw error
|
|
740
740
|
}
|
|
741
741
|
}
|
|
742
|
+
|
|
743
|
+
async revokeCertificatesPastValidityPeriod()
|
|
744
|
+
{
|
|
745
|
+
try
|
|
746
|
+
{
|
|
747
|
+
const result = await this.gateway.query('certificate/revoke-past-validity')
|
|
748
|
+
return result.affectedRows
|
|
749
|
+
}
|
|
750
|
+
catch(reason)
|
|
751
|
+
{
|
|
752
|
+
const error = new Error('could not revoke certificates past validity period')
|
|
753
|
+
error.code = 'E_EVENTFLOW_DB_CERTIFICATE_REVOKE_PAST_VALIDITY'
|
|
754
|
+
error.cause = reason
|
|
755
|
+
throw error
|
|
756
|
+
}
|
|
757
|
+
}
|
|
742
758
|
}
|
package/index.test.js
CHANGED
|
@@ -280,8 +280,8 @@ suite('@superhero/eventflow-db', async () =>
|
|
|
280
280
|
|
|
281
281
|
await sub.test('Persisting a duplicate certificate should return false', async () =>
|
|
282
282
|
{
|
|
283
|
-
const
|
|
284
|
-
assert.equal(
|
|
283
|
+
const isPersisted = await db.persistCertificate(crt)
|
|
284
|
+
assert.equal(isPersisted, false, 'Duplicate certificate should not be persisted')
|
|
285
285
|
})
|
|
286
286
|
|
|
287
287
|
await sub.test('Read a persisted certificate by id', async () =>
|
|
@@ -316,6 +316,21 @@ suite('@superhero/eventflow-db', async () =>
|
|
|
316
316
|
)
|
|
317
317
|
})
|
|
318
318
|
})
|
|
319
|
+
|
|
320
|
+
await sub.test('Revoke certificates that past there validity period', async (sub) =>
|
|
321
|
+
{
|
|
322
|
+
await db.persistCertificate(crt)
|
|
323
|
+
const revoked = await db.revokeCertificatesPastValidityPeriod()
|
|
324
|
+
assert.ok(revoked, 'Certificates should be revoked')
|
|
325
|
+
await sub.test('Reading a revoked certificate should reject with an error', async () =>
|
|
326
|
+
{
|
|
327
|
+
await assert.rejects(
|
|
328
|
+
db.readCertificate(id),
|
|
329
|
+
{ code: 'E_EVENTFLOW_DB_CERTIFICATE_NOT_FOUND' },
|
|
330
|
+
'Revoked certificate should not be readable'
|
|
331
|
+
)
|
|
332
|
+
})
|
|
333
|
+
})
|
|
319
334
|
})
|
|
320
335
|
})
|
|
321
336
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superhero/eventflow-db",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Eventflow db is a set of common database logic in the eventflow ecosystem.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eventflow"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@superhero/locator": "4.2.0"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"test-build": "docker ps -q -f name=eventflow-mysql | grep -q . && docker stop eventflow-mysql; docker run --rm --name eventflow-mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=eventflow -p 3306:3306 --health-cmd=\"mysqladmin ping -h 127.0.0.1 -uroot -proot --silent || exit 1\" --health-interval=10s --health-timeout=5s --health-retries=5 -d mysql:latest; until [ \"$(docker inspect --format='{{.State.Health.Status}}' eventflow-mysql)\" == \"healthy\" ]; do sleep 1; done
|
|
23
|
+
"test-build": "docker ps -q -f name=eventflow-mysql | grep -q . && docker stop eventflow-mysql; docker run --rm --name eventflow-mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=eventflow -p 3306:3306 --health-cmd=\"mysqladmin ping -h 127.0.0.1 -uroot -proot --silent || exit 1\" --health-interval=10s --health-timeout=5s --health-retries=5 -d mysql:latest; until [ \"$(docker inspect --format='{{.State.Health.Status}}' eventflow-mysql)\" == \"healthy\" ]; do sleep 1; done",
|
|
24
24
|
"test": "node --trace-warnings --test --experimental-test-coverage"
|
|
25
25
|
},
|
|
26
26
|
"author": {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
UPDATE certificate AS c
|
|
2
|
+
LEFT JOIN
|
|
3
|
+
(
|
|
4
|
+
SELECT id, COUNT(*) AS new_version
|
|
5
|
+
FROM certificate
|
|
6
|
+
GROUP BY id
|
|
7
|
+
) sub
|
|
8
|
+
ON c.id = sub.id
|
|
9
|
+
SET c.revoked = UTC_TIMESTAMP(),
|
|
10
|
+
c.version = sub.new_version
|
|
11
|
+
WHERE c.version = 0
|
|
12
|
+
AND c.validity < UTC_TIMESTAMP()
|