Skip to content
Snippets Groups Projects
Commit 24f39ee8 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] #788 Add revocation data to /wot/requirements

parent b684499b
Branches
Tags
No related merge requests found
...@@ -327,6 +327,9 @@ function BlockchainService (server) { ...@@ -327,6 +327,9 @@ function BlockchainService (server) {
meta: { meta: {
timestamp: idty.buid timestamp: idty.buid
}, },
revocation_sig: idty.revocation_sig,
revoked: idty.revoked,
revoked_on: idty.revoked_on,
expired: expired, expired: expired,
outdistanced: outdistanced, outdistanced: outdistanced,
certifications: certs, certifications: certs,
......
...@@ -186,6 +186,8 @@ function IdentityService () { ...@@ -186,6 +186,8 @@ function IdentityService () {
const revoc = new Revocation(obj); const revoc = new Revocation(obj);
const raw = revoc.rawWithoutSig(); const raw = revoc.rawWithoutSig();
return that.pushFIFO(() => co(function *() { return that.pushFIFO(() => co(function *() {
try {
logger.info('⬇ REVOCATION %s %s', revoc.pubkey, revoc.uid);
let verified = keyring.verify(raw, revoc.revocation, revoc.pubkey); let verified = keyring.verify(raw, revoc.revocation, revoc.pubkey);
if (!verified) { if (!verified) {
throw 'Wrong signature for revocation'; throw 'Wrong signature for revocation';
...@@ -200,6 +202,7 @@ function IdentityService () { ...@@ -200,6 +202,7 @@ function IdentityService () {
throw 'Revocation already registered'; throw 'Revocation already registered';
} else { } else {
yield dal.setRevocating(existing, revoc.revocation); yield dal.setRevocating(existing, revoc.revocation);
logger.info('✔ REVOCATION %s %s', revoc.pubkey, revoc.uid);
return jsonResultTrue(); return jsonResultTrue();
} }
} }
...@@ -213,8 +216,13 @@ function IdentityService () { ...@@ -213,8 +216,13 @@ function IdentityService () {
throw constants.ERRORS.SANDBOX_FOR_IDENTITY_IS_FULL; throw constants.ERRORS.SANDBOX_FOR_IDENTITY_IS_FULL;
} }
yield dal.savePendingIdentity(idty); yield dal.savePendingIdentity(idty);
logger.info('✔ REVOCATION %s %s', revoc.pubkey, revoc.uid);
return jsonResultTrue(); return jsonResultTrue();
} }
} catch (e) {
logger.info('✘ REVOCATION %s %s', revoc.pubkey, revoc.uid);
throw e;
}
})); }));
}; };
} }
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
"colors": "1.1.2", "colors": "1.1.2",
"commander": "2.9.0", "commander": "2.9.0",
"daemonize2": "0.4.2", "daemonize2": "0.4.2",
"duniter-bma": "^0.2.6", "duniter-bma": "^0.2.7",
"duniter-common": "0.1.0", "duniter-common": "0.1.0",
"duniter-crawler": "^0.2.5", "duniter-crawler": "^0.2.5",
"duniter-keypair": "^0.3.0", "duniter-keypair": "^0.3.0",
......
...@@ -346,6 +346,25 @@ describe("Identities collision", function() { ...@@ -346,6 +346,25 @@ describe("Identities collision", function() {
}); });
}); });
it('requirements of man3 after revocation', () => co(function*() {
yield man3.revoke();
return expectAnswer(rp('http://127.0.0.1:7799/wot/requirements/man3', { json: true }), function(res) {
res.should.have.property('identities').be.an.Array;
res.should.have.property('identities').have.length(1);
res.identities[0].should.have.property('pubkey').equal('5bfpAfZJ4xYspUBYseASJrofhRm6e6JMombt43HBaRzW');
res.identities[0].should.have.property('uid').equal('man3');
res.identities[0].should.have.property('meta').property('timestamp');
res.identities[0].should.have.property('expired').equal(false);
res.identities[0].should.have.property('outdistanced').equal(true);
res.identities[0].should.have.property('certifications').length(0);
res.identities[0].should.have.property('membershipPendingExpiresIn').equal(0);
res.identities[0].should.have.property('membershipExpiresIn').equal(0);
res.identities[0].should.have.property('revoked').equal(false);
res.identities[0].should.have.property('revoked_on').equal(null);
res.identities[0].should.have.property('revocation_sig').not.equal(null);
});
}));
it('memberships of tic', function() { it('memberships of tic', function() {
return expectAnswer(rp('http://127.0.0.1:7799/blockchain/memberships/tic', { json: true }), function(res) { return expectAnswer(rp('http://127.0.0.1:7799/blockchain/memberships/tic', { json: true }), function(res) {
res.should.have.property('pubkey').equal('DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV'); res.should.have.property('pubkey').equal('DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment