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

Fix #388 An identity could appear revoked whereas is has not been written in the blockchain yet

parent e1601c04
No related branches found
No related tags found
No related merge requests found
......@@ -176,9 +176,10 @@ function IdentityService () {
}
}
else {
// Create
revoc.revoked = true;
yield dal.savePendingIdentity(revoc);
// Create identity given by the revocation
const idty = new Identity(revoc);
idty.revocation_sig = revoc.signature;
yield dal.savePendingIdentity(idty);
return jsonResultTrue();
}
}));
......
......@@ -34,9 +34,22 @@ const s1 = ucoin({
}
}, commonConf));
const s2 = ucoin({
memory: MEMORY_MODE,
name: 'bb12'
}, _.extend({
port: '9965',
pair: {
pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd',
sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP'
}
}, commonConf));
const cat = user('cat', { pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP'}, { server: s1 });
const tic = user('tic', { pub: 'DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV', sec: '468Q1XtTq7h84NorZdWBZFJrGkB18CbmbHr9tkp9snt5GiERP7ySs3wM8myLccbAAGejgMRC9rqnXuW3iAfZACm7'}, { server: s1 });
const toc = user('toc', { pub: 'DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo', sec: '64EYRvdPpTfLGGmaX5nijLXRqWXaVz8r1Z1GtaahXwVSJGQRn7tqkxLb288zwSYzELMEG5ZhXSBYSxsTsz1m9y8F'}, { server: s1 });
const tacOnS1 = user('tac', { pub: '2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc', sec: '2HuRLWgKgED1bVio1tdpeXrf7zuUszv1yPHDsDj7kcMC4rVSN9RC58ogjtKNfTbH1eFz7rn38U1PywNs3m6Q7UxE'}, { server: s1 });
const tacOnS2 = user('tac', { pub: '2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc', sec: '2HuRLWgKgED1bVio1tdpeXrf7zuUszv1yPHDsDj7kcMC4rVSN9RC58ogjtKNfTbH1eFz7rn38U1PywNs3m6Q7UxE'}, { server: s2 });
const commitS1 = commit(s1);
......@@ -46,6 +59,7 @@ describe("Revocation", function() {
return co(function *() {
yield s1.initWithDAL().then(bma).then((bmapi) => bmapi.openConnections());
yield s2.initWithDAL().then(bma).then((bmapi) => bmapi.openConnections());
yield cat.selfCert();
yield tic.selfCert();
yield toc.selfCert();
......@@ -92,6 +106,29 @@ describe("Revocation", function() {
});
}));
it('sending a revocation for tac should add an identity', () => co(function *() {
yield tacOnS1.selfCert();
const idty = yield tacOnS1.lookup(tacOnS1.pub);
yield tacOnS2.revoke(idty);
// On S1 server, tac is known as normal identity
yield expectAnswer(rp('http://127.0.0.1:9964/wot/lookup/tac', { json: true }), function(res) {
res.should.have.property('results').length(1);
res.results[0].should.have.property('uids').length(1);
res.results[0].uids[0].should.have.property('uid').equal('tac');
res.results[0].uids[0].should.have.property('revoked').equal(false);
res.results[0].uids[0].should.have.property('revocation_sig').equal(null);
});
// On S2 server, tac is known as identity with revocation pending (not written! so `revoked` field is false)
yield expectAnswer(rp('http://127.0.0.1:9965/wot/lookup/tac', { json: true }), function(res) {
res.should.have.property('results').length(1);
res.results[0].should.have.property('uids').length(1);
res.results[0].uids[0].should.have.property('uid').equal('tac');
res.results[0].uids[0].should.have.property('revoked').equal(false);
res.results[0].uids[0].should.have.property('revocation_sig').not.equal(null);
res.results[0].uids[0].should.have.property('revocation_sig').not.equal('');
});
}));
it('if we commit a revocation, cat should be revoked', () => co(function *() {
yield commitS1();
return expectAnswer(rp('http://127.0.0.1:9964/wot/lookup/cat', { json: true }), function(res) {
......
......@@ -96,8 +96,8 @@ function User (uid, options, node) {
return yield that.sendMembership("OUT");
});
this.revoke = () => co(function *() {
let res = yield that.lookup(pub);
this.revoke = (givenLookupIdty) => co(function *() {
let res = givenLookupIdty || (yield that.lookup(pub));
let idty = Identity.statics.fromJSON({
uid: res.results[0].uids[0].uid,
buid: res.results[0].uids[0].meta.timestamp,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment