Skip to content

Commit

Permalink
DEPENDENCIES, added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Jul 2, 2024
1 parent ee337de commit b1de341
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
13 changes: 8 additions & 5 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,20 @@ maven/mavencentral/org.jetbrains/annotations/24.1.0, Apache-2.0, approved, clear
maven/mavencentral/org.junit-pioneer/junit-pioneer/2.2.0, EPL-2.0, approved, #11857
maven/mavencentral/org.junit.jupiter/junit-jupiter-api/5.10.1, EPL-2.0, approved, #9714
maven/mavencentral/org.junit.jupiter/junit-jupiter-api/5.10.2, EPL-2.0, approved, #9714
maven/mavencentral/org.junit.jupiter/junit-jupiter-api/5.10.3, EPL-2.0, approved, #9714
maven/mavencentral/org.junit.jupiter/junit-jupiter-engine/5.10.1, EPL-2.0, approved, #9711
maven/mavencentral/org.junit.jupiter/junit-jupiter-engine/5.10.2, EPL-2.0, approved, #9711
maven/mavencentral/org.junit.jupiter/junit-jupiter-engine/5.10.3, EPL-2.0, approved, #9711
maven/mavencentral/org.junit.jupiter/junit-jupiter-params/5.10.1, EPL-2.0, approved, #15304
maven/mavencentral/org.junit.jupiter/junit-jupiter-params/5.10.2, EPL-2.0, approved, #15250
maven/mavencentral/org.junit.jupiter/junit-jupiter-params/5.10.3, EPL-2.0, approved, #15250
maven/mavencentral/org.junit.platform/junit-platform-commons/1.10.1, EPL-2.0, approved, #9715
maven/mavencentral/org.junit.platform/junit-platform-commons/1.10.2, EPL-2.0, approved, #9715
maven/mavencentral/org.junit.platform/junit-platform-commons/1.10.3, EPL-2.0, approved, #9715
maven/mavencentral/org.junit.platform/junit-platform-engine/1.10.1, EPL-2.0, approved, #9709
maven/mavencentral/org.junit.platform/junit-platform-engine/1.10.2, EPL-2.0, approved, #9709
maven/mavencentral/org.junit.platform/junit-platform-launcher/1.10.2, EPL-2.0, approved, #15216
maven/mavencentral/org.junit.platform/junit-platform-engine/1.10.3, EPL-2.0, approved, #9709
maven/mavencentral/org.junit.platform/junit-platform-launcher/1.10.3, EPL-2.0, approved, #15216
maven/mavencentral/org.junit/junit-bom/5.10.1, EPL-2.0, approved, #9844
maven/mavencentral/org.junit/junit-bom/5.10.2, EPL-2.0, approved, #9844
maven/mavencentral/org.junit/junit-bom/5.10.3, EPL-2.0, approved, #9844
maven/mavencentral/org.junit/junit-bom/5.9.2, EPL-2.0, approved, #4711
maven/mavencentral/org.jvnet.mimepull/mimepull/1.9.15, CDDL-1.1 OR GPL-2.0-only WITH Classpath-exception-2.0, approved, CQ21484
maven/mavencentral/org.mock-server/mockserver-client-java/5.15.0, Apache-2.0 AND LGPL-3.0-only, approved, #9324
Expand Down Expand Up @@ -400,4 +403,4 @@ maven/mavencentral/org.xmlresolver/xmlresolver/5.2.2, Apache-2.0, approved, clea
maven/mavencentral/org.xmlunit/xmlunit-core/2.9.1, Apache-2.0, approved, #6272
maven/mavencentral/org.xmlunit/xmlunit-placeholders/2.9.1, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.yaml/snakeyaml/1.33, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.yaml/snakeyaml/2.2, Apache-2.0 AND (Apache-2.0 OR BSD-3-Clause OR EPL-1.0 OR GPL-2.0-or-later OR LGPL-2.1-or-later), approved, #10232
maven/mavencentral/org.yaml/snakeyaml/2.2, Apache-2.0 AND (Apache-2.0 OR BSD-3-Clause OR EPL-1.0 OR GPL-2.0-or-later OR LGPL-2.1-or-later), approved, #10232
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ class CredentialQueryResolverImplTest {
private final Monitor monitor = mock();
private final CredentialQueryResolverImpl resolver = new CredentialQueryResolverImpl(storeMock, new EdcScopeToCriterionTransformer(), revocationServiceMock, monitor);

private static VerifiableCredentialResource.Builder createCredentialResource(VerifiableCredential cred) {
return VerifiableCredentialResource.Builder.newInstance()
.credential(new VerifiableCredentialContainer("foobar", CredentialFormat.JSON_LD, cred))
.holderId("test-holder")
.issuerId("test-issuer")
.participantId(TEST_PARTICIPANT_CONTEXT_ID);
}

@BeforeEach
void setUp() {
when(revocationServiceMock.checkValidity(any())).thenReturn(Result.success());
Expand Down Expand Up @@ -119,6 +111,22 @@ void query_singleScopeString() {
assertThat(res.getContent()).containsExactly(credential.getVerifiableCredential());
}

@Test
void query_verifyDifferentObjects() {
var credential1 = createCredentialResource(createCredential("TestCredential").build()).id("id1").build();
var credential2 = createCredentialResource(createCredential("TestCredential").build()).id("id1").build();

when(storeMock.query(any()))
.thenAnswer(i -> success(List.of(credential1)))
.thenAnswer(i -> success(List.of(credential2)));

var res = resolver.query(TEST_PARTICIPANT_CONTEXT_ID,
createPresentationQuery("org.eclipse.edc.vc.type:TestCredential:read"), List.of("org.eclipse.edc.vc.type:TestCredential:read"));

assertThat(res.succeeded()).withFailMessage(res::getFailureDetail).isTrue();
assertThat(res.getContent()).usingRecursiveFieldByFieldElementComparator().containsExactly(credential1.getVerifiableCredential());
}

@Test
void query_whenParticipantIdMismatch_expectEmptyResult() {
when(storeMock.query(any())).thenAnswer(i -> success(List.of()));
Expand Down Expand Up @@ -291,6 +299,14 @@ void query_whenRevokedCredential_doesNotInclude() {
verify(monitor).warning(eq("Credential '%s' not valid: revoked".formatted(credential.getId())));
}

private VerifiableCredentialResource.Builder createCredentialResource(VerifiableCredential cred) {
return VerifiableCredentialResource.Builder.newInstance()
.credential(new VerifiableCredentialContainer("foobar", CredentialFormat.JSON_LD, cred))
.holderId("test-holder")
.issuerId("test-issuer")
.participantId(TEST_PARTICIPANT_CONTEXT_ID);
}

private VerifiableCredential.Builder createCredential(String... type) {
return VerifiableCredential.Builder.newInstance()
.types(Arrays.asList(type))
Expand Down

0 comments on commit b1de341

Please sign in to comment.