diff --git a/app/lib/dal/fileDAL.ts b/app/lib/dal/fileDAL.ts index 599d48ed6b88f4a5d85012898e425bce134bcd69..9cf47b5a85d4191bcb7825d3e637096a5e12728c 100644 --- a/app/lib/dal/fileDAL.ts +++ b/app/lib/dal/fileDAL.ts @@ -743,6 +743,17 @@ export class FileDAL implements ServerDAO { return await this.iindexDAL.getFromPubkeyOrUid(search); } + async getWrittenIdtyByPubkeyForHashingAndIsMember( + pub: string + ): Promise<{ + uid: string; + created_on: string; + pub: string; + member: boolean; + } | null> { + return await this.iindexDAL.getFromPubkey(pub); + } + async getWrittenIdtyByPubkeyForRevocationCheck( pubkey: string ): Promise<{ diff --git a/app/modules/bma/lib/controllers/wot.ts b/app/modules/bma/lib/controllers/wot.ts index 61e869b06e7ae01296a122ab523f990b6cc943dc..9651cb9f2e374344ce0e771dcf6cb9db8533e4e5 100644 --- a/app/modules/bma/lib/controllers/wot.ts +++ b/app/modules/bma/lib/controllers/wot.ts @@ -132,9 +132,17 @@ export class WOTBinding extends AbstractController { async certifiersOf(req: any): Promise<HttpCertifications> { const search = await ParametersService.getSearchP(req); - const idty = (await this.server.dal.getWrittenIdtyByPubkeyOrUIdForHashingAndIsMember( - search - )) as FullIindexEntry; + let idty: FullIindexEntry; + if (req.query.pubkey) { + idty = (await this.server.dal.getWrittenIdtyByPubkeyForHashingAndIsMember( + search + )) as FullIindexEntry; + } + else { + idty = (await this.server.dal.getWrittenIdtyByPubkeyOrUIdForHashingAndIsMember( + search + )) as FullIindexEntry; + } const certs = await this.server.dal.certsToTarget( idty.pub, IdentityDTO.getTargetHash(idty) @@ -229,9 +237,17 @@ export class WOTBinding extends AbstractController { async certifiedBy(req: any): Promise<HttpCertifications> { const search = await ParametersService.getSearchP(req); - const idty = (await this.server.dal.getWrittenIdtyByPubkeyOrUIdForHashingAndIsMember( - search - )) as FullIindexEntry; + let idty: FullIindexEntry; + if (req.query.pubkey) { + idty = (await this.server.dal.getWrittenIdtyByPubkeyForHashingAndIsMember( + search + )) as FullIindexEntry; + } + else { + idty = (await this.server.dal.getWrittenIdtyByPubkeyOrUIdForHashingAndIsMember( + search + )) as FullIindexEntry; + } const certs = await this.server.dal.certsFrom(idty.pub); const theCerts: HttpCertification[] = []; for (const cert of certs) { diff --git a/test/integration/identity/identity-test.ts b/test/integration/identity/identity-test.ts index 6966e9971ebf9b7d850756824698fa2cf949ca04..847ff19e8e20b6d0e86c7cd36e6ad1591068e76e 100644 --- a/test/integration/identity/identity-test.ts +++ b/test/integration/identity/identity-test.ts @@ -192,6 +192,13 @@ describe("Identities collision", function() { }); }); + it('should have certifiers-of/:pubkey of cat giving results', function() { + return expectAnswer(rp('http://127.0.0.1:7799/wot/certifiers-of/HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd?pubkey', { json: true }), function(res:HttpCertifications) { + res.should.have.property('pubkey').equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd'); + res.should.have.property('uid').equal('cat'); + }); + }); + it('should have certifiers-of/tic giving results', function() { return expectAnswer(rp('http://127.0.0.1:7799/wot/certifiers-of/tic', { json: true }), function(res:HttpCertifications) { res.should.have.property('pubkey').equal('DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV'); @@ -213,6 +220,13 @@ describe("Identities collision", function() { }); }); + it('should have certifiers-of/:pubkey of tic giving results', function() { + return expectAnswer(rp('http://127.0.0.1:7799/wot/certifiers-of/DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV?pubkey', { json: true }), function(res:HttpCertifications) { + res.should.have.property('pubkey').equal('DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV'); + res.should.have.property('uid').equal('tic'); + }); + }); + it('should have certifiers-of/toc giving results', function() { return expectAnswer(rp('http://127.0.0.1:7799/wot/certifiers-of/toc', { json: true }), function(res:HttpCertifications) { res.should.have.property('pubkey').equal('DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo'); @@ -234,6 +248,13 @@ describe("Identities collision", function() { }); }); + it('should have certifiers-of/:pubkey of toc giving results', function() { + return expectAnswer(rp('http://127.0.0.1:7799/wot/certifiers-of/DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo?pubkey', { json: true }), function(res:HttpCertifications) { + res.should.have.property('pubkey').equal('DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo'); + res.should.have.property('uid').equal('toc'); + }); + }); + it('requirements of cat', function() { return expectAnswer(rp('http://127.0.0.1:7799/wot/requirements/cat', { json: true }), function(res:HttpRequirements) { res.should.have.property('identities').be.an.Array; @@ -298,6 +319,13 @@ describe("Identities collision", function() { }); }); + it('should have certified-by/:pubkey of tic giving results', function() { + return expectAnswer(rp('http://127.0.0.1:7799/wot/certified-by/DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV?pubkey', { json: true }), function(res:HttpCertifications) { + res.should.have.property('pubkey').equal('DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV'); + res.should.have.property('uid').equal('tic'); + }); + }); + it('should have certified-by/tac giving results', function() { return expectAnswer(rp('http://127.0.0.1:7799/wot/certified-by/tac', { json: true }), function(res:HttpCertifications) { res.should.have.property('pubkey').equal('2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc'); @@ -308,6 +336,13 @@ describe("Identities collision", function() { }); }); + it('should have certified-by/:pubkey of tac giving results', function() { + return expectAnswer(rp('http://127.0.0.1:7799/wot/certified-by/2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc?pubkey', { json: true }), function(res:HttpCertifications) { + res.should.have.property('pubkey').equal('2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc'); + res.should.have.property('uid').equal('tac'); + }); + }); + it('should have certified-by/cat giving results', function() { return expectAnswer(rp('http://127.0.0.1:7799/wot/certified-by/cat', { json: true }), function(res:HttpCertifications) { res.should.have.property('pubkey').equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd'); @@ -343,6 +378,13 @@ describe("Identities collision", function() { }); }); + it('should have certified-by/:pubkey of cat giving results', function() { + return expectAnswer(rp('http://127.0.0.1:7799/wot/certified-by/HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd?pubkey', { json: true }), function(res:HttpCertifications) { + res.should.have.property('pubkey').equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd'); + res.should.have.property('uid').equal('cat'); + }); + }); + it('requirements of man2', function() { return expectAnswer(rp('http://127.0.0.1:7799/wot/requirements/man2', { json: true }), function(res:HttpRequirements) { res.should.have.property('identities').be.an.Array;