Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
cab9f81e
Commit
cab9f81e
authored
1 year ago
by
Benoit Lavenier
Browse files
Options
Downloads
Patches
Plain Diff
[enh] Optimize BMA `/wot/certifiers-of/:search` and `/wot/certified-by/:search` - Close
#1440
parent
9a08389c
No related branches found
No related tags found
1 merge request
!1423
[enh] Optimize BMA `/wot/certifiers-of/:search` and `/wot/certified-by/:search` - Close #1440
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/dal/fileDAL.ts
+11
-0
11 additions, 0 deletions
app/lib/dal/fileDAL.ts
app/modules/bma/lib/controllers/wot.ts
+22
-6
22 additions, 6 deletions
app/modules/bma/lib/controllers/wot.ts
test/integration/identity/identity-test.ts
+42
-0
42 additions, 0 deletions
test/integration/identity/identity-test.ts
with
75 additions
and
6 deletions
app/lib/dal/fileDAL.ts
+
11
−
0
View file @
cab9f81e
...
...
@@ -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
<
{
...
...
This diff is collapsed.
Click to expand it.
app/modules/bma/lib/controllers/wot.ts
+
22
−
6
View file @
cab9f81e
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
test/integration/identity/identity-test.ts
+
42
−
0
View file @
cab9f81e
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment