Skip to content

Commit 9ccbaf7

Browse files
refactor: retire get-all endpoints (#959)
1 parent 1235a96 commit 9ccbaf7

10 files changed

Lines changed: 68 additions & 11 deletions

File tree

e2e-tests/identity-api-tests/src/test/java/org/eclipse/edc/identityhub/tests/KeyPairResourceApiEndToEndTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,6 @@ void getAll_withDefaultPaging(IdentityHub identityHub) {
711711

712712
@Test
713713
void getAll_notAuthorized(IdentityHub identityHub) {
714-
var attackerToken = authorizeUser("attacker", identityHub);
715714

716715
range(0, 10)
717716
.forEach(i -> {
@@ -720,7 +719,19 @@ void getAll_notAuthorized(IdentityHub identityHub) {
720719
});
721720
identityHub.getIdentityEndpoint().baseRequest()
722721
.contentType(JSON)
723-
.header(attackerToken)
722+
.get("/v1alpha/keypairs")
723+
.then()
724+
.log().ifValidationFails()
725+
.statusCode(401);
726+
}
727+
728+
@Test
729+
void getAll_notAdmin(IdentityHub identityHub) {
730+
var userAuth = authorizeUser(PARTICIPANT_CONTEXT_ID, identityHub);
731+
732+
identityHub.getIdentityEndpoint().baseRequest()
733+
.contentType(JSON)
734+
.header(userAuth)
724735
.get("/v1alpha/keypairs")
725736
.then()
726737
.log().ifValidationFails()

e2e-tests/identity-api-tests/src/test/java/org/eclipse/edc/identityhub/tests/VerifiableCredentialApiEndToEndTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,46 @@ void getRequest_whenNotFound_shouldReturn404(IdentityHub identityHub) {
432432
.statusCode(404);
433433
}
434434

435+
@Test
436+
void getAll_whenAdmin(IdentityHub identityHub) {
437+
var superUserAuth = authorizeUser(SUPER_USER, identityHub);
438+
var user1 = "user1";
439+
var user2 = "user2";
440+
identityHub.createParticipant(user1);
441+
identityHub.createParticipant(user2);
442+
443+
var credential1 = createCredential();
444+
var credential2 = createCredential();
445+
identityHub.storeCredential(credential1, user1);
446+
identityHub.storeCredential(credential2, user2);
447+
448+
identityHub.getIdentityEndpoint().baseRequest()
449+
.contentType(JSON)
450+
.header(superUserAuth)
451+
.get("/v1alpha/credentials")
452+
.then()
453+
.log().ifValidationFails()
454+
.statusCode(200)
455+
.body(notNullValue());
456+
}
457+
458+
@Test
459+
void getAll_whenNotAdmin_expect403(IdentityHub identityHub) {
460+
var user = "user1";
461+
var userAuth = authorizeUser(user, identityHub);
462+
463+
var credential = createCredential();
464+
identityHub.storeCredential(credential, user);
465+
466+
identityHub.getIdentityEndpoint().baseRequest()
467+
.contentType(JSON)
468+
.header(userAuth)
469+
.get("/v1alpha/credentials")
470+
.then()
471+
.log().ifValidationFails()
472+
.statusCode(403);
473+
}
474+
435475
protected abstract Header authorizeUser(String participantContextId, IdentityHub identityHub);
436476

437477
private VerifiableCredentialManifest.Builder createManifest(String participantContextId, VerifiableCredential vc) {

extensions/api/identity-api/did-api/src/main/java/org/eclipse/edc/identityhub/api/didmanagement/v1/unstable/GetAllDidsApi.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public interface GetAllDidsApi {
4646
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetail.class)), mediaType = "application/json")),
4747
@ApiResponse(responseCode = "400", description = "The query was malformed or was not understood by the server.",
4848
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetail.class)), mediaType = "application/json")),
49-
}
49+
},
50+
deprecated = true
5051
)
5152
Collection<DidDocument> getAllDids(Integer offset, Integer limit);
5253
}

extensions/api/identity-api/did-api/src/main/java/org/eclipse/edc/identityhub/api/didmanagement/v1/unstable/GetAllDidsApiController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public GetAllDidsApiController(DidDocumentService documentService) {
4747
@Override
4848
@GET
4949
@RequiredScope("identity-api:read")
50-
@RolesAllowed({ParticipantPrincipal.ROLE_ADMIN, ParticipantPrincipal.ROLE_PROVISIONER})
50+
@RolesAllowed({ ParticipantPrincipal.ROLE_ADMIN })
51+
@Deprecated(forRemoval = true, since = "0.17.0")
5152
public Collection<DidDocument> getAllDids(@DefaultValue("0") @QueryParam("offset") Integer offset,
5253
@DefaultValue("50") @QueryParam("limit") Integer limit) {
5354
if (offset < 0 || limit < 0) {

extensions/api/identity-api/identity-api-configuration/src/main/resources/identity-api-version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"version": "1.0.0-alpha",
44
"urlPath": "/v1alpha",
5-
"lastUpdated": "2026-03-25T11:00:00Z",
5+
"lastUpdated": "2026-03-30T11:00:00Z",
66
"maturity": null
77
}
88
]

extensions/api/identity-api/keypair-api/src/main/java/org/eclipse/edc/identityhub/api/keypair/v1/unstable/GetAllKeyPairsApi.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public interface GetAllKeyPairsApi {
4646
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetail.class)), mediaType = "application/json")),
4747
@ApiResponse(responseCode = "400", description = "The query was malformed or was not understood by the server.",
4848
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetail.class)), mediaType = "application/json")),
49-
}
49+
},
50+
deprecated = true
5051
)
5152
Collection<KeyPairResource> getAllKeyPairs(Integer offset, Integer limit);
5253
}

extensions/api/identity-api/keypair-api/src/main/java/org/eclipse/edc/identityhub/api/keypair/v1/unstable/GetAllKeyPairsApiController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ public GetAllKeyPairsApiController(KeyPairService keyPairService) {
4646

4747
@GET
4848
@RequiredScope("identity-api:read")
49-
@RolesAllowed({ParticipantPrincipal.ROLE_ADMIN})
49+
@RolesAllowed({ ParticipantPrincipal.ROLE_ADMIN })
5050
@Override
51+
@Deprecated(forRemoval = true, since = "0.17.0")
5152
public Collection<KeyPairResource> getAllKeyPairs(@DefaultValue("0") @QueryParam("offset") Integer offset,
5253
@DefaultValue("50") @QueryParam("limit") Integer limit) {
5354
return keyPairService.query(QuerySpec.Builder.newInstance().offset(offset).limit(limit).build())

extensions/api/identity-api/verifiable-credentials-api/src/main/java/org/eclipse/edc/identityhub/api/verifiablecredentials/v1/unstable/GetAllCredentialsApi.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ public interface GetAllCredentialsApi {
3737
operationId = "getAllCredentials",
3838
parameters = {
3939
@Parameter(name = "offset", description = "the paging offset. defaults to 0"),
40-
@Parameter(name = "limit", description = "the page size. defaults to 50")},
40+
@Parameter(name = "limit", description = "the page size. defaults to 50") },
4141
responses = {
4242
@ApiResponse(responseCode = "200", description = "The list of VerifiableCredential resources.",
4343
content = @Content(array = @ArraySchema(schema = @Schema(implementation = VerifiableCredentialResource.class)))),
4444
@ApiResponse(responseCode = "401", description = "The request could not be completed, because either the authentication was missing or was not valid.",
4545
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetail.class)), mediaType = "application/json")),
4646
@ApiResponse(responseCode = "400", description = "The query was malformed or was not understood by the server.",
4747
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetail.class)), mediaType = "application/json")),
48-
}
48+
},
49+
deprecated = true
4950
)
5051
Collection<VerifiableCredentialResource> getAllCredentials(Integer offset, Integer limit);
5152
}

extensions/api/identity-api/verifiable-credentials-api/src/main/java/org/eclipse/edc/identityhub/api/verifiablecredentials/v1/unstable/GetAllCredentialsApiController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ public GetAllCredentialsApiController(CredentialStore credentialStore) {
4646

4747
@GET
4848
@RequiredScope("identity-api:read")
49-
@RolesAllowed({ParticipantPrincipal.ROLE_ADMIN, ParticipantPrincipal.ROLE_PARTICIPANT})
49+
@RolesAllowed({ ParticipantPrincipal.ROLE_ADMIN })
5050
@Override
51+
@Deprecated(forRemoval = true, since = "0.17.0")
5152
public Collection<VerifiableCredentialResource> getAllCredentials(@DefaultValue("0") @QueryParam("offset") Integer offset,
5253
@DefaultValue("50") @QueryParam("limit") Integer limit) {
5354
var res = credentialStore.query(QuerySpec.Builder.newInstance().limit(limit).offset(offset).build());

protocols/dcp/dcp-identityhub/credentials-api-configuration/src/main/resources/credentials-api-version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"version": "1.0.0",
44
"urlPath": "/v1",
5-
"lastUpdated": "2026-03-24T09:00:00Z",
5+
"lastUpdated": "2026-03-30T09:00:00Z",
66
"maturity": "stable"
77
}
88
]

0 commit comments

Comments
 (0)