Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit e91b6a0

Browse files
committed
fix: failing test cases
1 parent 02ccd31 commit e91b6a0

File tree

7 files changed

+30
-9
lines changed

7 files changed

+30
-9
lines changed

miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/config/RevocationSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
import java.net.URI;
2727

2828
@ConfigurationProperties(prefix = "miw.revocation")
29-
public record RevocationSettings(URI url) {
29+
public record RevocationSettings(URI url, URI bitStringStatusListContext) {
3030
}

miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/IssuersCredentialService.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.eclipse.tractusx.managedidentitywallets.commons.exception.ForbiddenException;
4343
import org.eclipse.tractusx.managedidentitywallets.commons.utils.Validate;
4444
import org.eclipse.tractusx.managedidentitywallets.config.MIWSettings;
45+
import org.eclipse.tractusx.managedidentitywallets.config.RevocationSettings;
4546
import org.eclipse.tractusx.managedidentitywallets.dao.entity.HoldersCredential;
4647
import org.eclipse.tractusx.managedidentitywallets.dao.entity.IssuersCredential;
4748
import org.eclipse.tractusx.managedidentitywallets.dao.entity.Wallet;
@@ -77,6 +78,7 @@
7778
import org.springframework.util.StringUtils;
7879

7980
import java.io.IOException;
81+
import java.net.URI;
8082
import java.net.http.HttpClient;
8183
import java.text.ParseException;
8284
import java.util.ArrayList;
@@ -115,6 +117,8 @@ public class IssuersCredentialService extends BaseService<IssuersCredential, Lon
115117

116118
private final RevocationService revocationService;
117119

120+
private final RevocationSettings revocationSettings;
121+
118122

119123
@Override
120124
protected BaseRepository<IssuersCredential, Long> getRepository() {
@@ -239,6 +243,14 @@ public CredentialsResponse issueCredentialUsingBaseWallet(String holderDid, Map<
239243
//get credential status in case of revocation
240244
VerifiableCredentialStatusList2021Entry statusListEntry = revocationService.getStatusListEntry(issuerWallet.getBpn(), token);
241245
builder.verifiableCredentialStatus(statusListEntry);
246+
247+
//add revocation context if missing
248+
List<URI> uris = miwSettings.vcContexts();
249+
if (!uris.contains(revocationSettings.bitStringStatusListContext())) {
250+
uris.add(revocationSettings.bitStringStatusListContext());
251+
builder.contexts(uris);
252+
}
253+
242254
}
243255

244256
CredentialCreationConfig holdersCredentialCreationConfig = builder.build();

miw/src/main/resources/application.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ miw:
110110
refresh-token-url: ${miw.security.token-url}
111111
revocation:
112112
url: ${REVOCATION_SERVICE_URL:http://localhost:8081}
113+
bitStringStatusListContext: ${BITSTRING_STATUS_LIST_CONTEXT_URL:https://w3c.github.io/vc-bitstring-status-list/contexts/v1.jsonld}
113114

114115

115116
sts:

miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/service/IssuersCredentialServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public static void beforeAll() throws SQLException {
153153
issuersCredentialRepository,
154154
miwSettings,
155155
new SpecificationUtil<IssuersCredential>(),
156-
holdersCredentialRepository, commonService, objectMapper, revocationService);
156+
holdersCredentialRepository, commonService, objectMapper, revocationService, revocationSettings);
157157
}
158158

159159
@BeforeEach

miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/TestUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.eclipse.tractusx.managedidentitywallets.commons.constant.StringPool;
3939
import org.eclipse.tractusx.managedidentitywallets.commons.exception.ForbiddenException;
4040
import org.eclipse.tractusx.managedidentitywallets.config.MIWSettings;
41+
import org.eclipse.tractusx.managedidentitywallets.config.RevocationSettings;
4142
import org.eclipse.tractusx.managedidentitywallets.constant.RestURI;
4243
import org.eclipse.tractusx.managedidentitywallets.dao.entity.Wallet;
4344
import org.eclipse.tractusx.managedidentitywallets.dao.repository.WalletRepository;
@@ -129,14 +130,14 @@ public static Wallet createWallet(String bpn, String did, WalletRepository walle
129130
return walletRepository.save(wallet);
130131
}
131132

132-
public static void checkVC(VerifiableCredential verifiableCredential, MIWSettings miwSettings) {
133-
//text context URL
134-
Assertions.assertEquals(verifiableCredential.getContext().size(), miwSettings.vcContexts().size() + 1);
135-
133+
public static void checkVC(VerifiableCredential verifiableCredential, MIWSettings miwSettings, RevocationSettings revocationSettings) {
136134
for (URI link : miwSettings.vcContexts()) {
137135
Assertions.assertTrue(verifiableCredential.getContext().contains(link));
138136
}
139137

138+
if (verifiableCredential.getVerifiableCredentialStatus() != null) {
139+
Assertions.assertTrue(verifiableCredential.getContext().contains(revocationSettings.bitStringStatusListContext()));
140+
}
140141
//check expiry date
141142
Assertions.assertEquals(0, verifiableCredential.getExpirationDate().compareTo(miwSettings.vcExpiryDate().toInstant()));
142143
}
@@ -261,7 +262,6 @@ public static Map<String, Object> getCredentialAsMap(String holderBpn, String ho
261262
//VC Subject
262263
VerifiableCredentialSubject verifiableCredentialSubject =
263264
new VerifiableCredentialSubject(subjectData);
264-
265265
//Using Builder
266266
VerifiableCredential credentialWithoutProof =
267267
verifiableCredentialBuilder

miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/HoldersCredentialTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.eclipse.tractusx.managedidentitywallets.commons.constant.CredentialStatus;
3030
import org.eclipse.tractusx.managedidentitywallets.commons.constant.StringPool;
3131
import org.eclipse.tractusx.managedidentitywallets.config.MIWSettings;
32+
import org.eclipse.tractusx.managedidentitywallets.config.RevocationSettings;
3233
import org.eclipse.tractusx.managedidentitywallets.config.TestContextInitializer;
3334
import org.eclipse.tractusx.managedidentitywallets.constant.RestURI;
3435
import org.eclipse.tractusx.managedidentitywallets.controller.IssuersCredentialController;
@@ -101,6 +102,9 @@ class HoldersCredentialTest {
101102
@Autowired
102103
private TestRestTemplate restTemplate;
103104

105+
@Autowired
106+
private RevocationSettings revocationSettings;
107+
104108
@MockInBean(RevocationService.class)
105109
private RevocationClient revocationClient;
106110

@@ -149,7 +153,7 @@ void issueCredentialTest200() throws JsonProcessingException {
149153

150154
List<HoldersCredential> credentials = holdersCredentialRepository.getByHolderDidAndType(did, type);
151155
Assertions.assertFalse(credentials.isEmpty());
152-
TestUtils.checkVC(credentials.get(0).getData(), miwSettings);
156+
TestUtils.checkVC(credentials.get(0).getData(), miwSettings, revocationSettings);
153157
Assertions.assertTrue(credentials.get(0).isSelfIssued());
154158
Assertions.assertFalse(credentials.get(0).isStored());
155159
}

miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/IssuersCredentialTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.eclipse.tractusx.managedidentitywallets.commons.constant.StringPool;
3232
import org.eclipse.tractusx.managedidentitywallets.commons.exception.ForbiddenException;
3333
import org.eclipse.tractusx.managedidentitywallets.config.MIWSettings;
34+
import org.eclipse.tractusx.managedidentitywallets.config.RevocationSettings;
3435
import org.eclipse.tractusx.managedidentitywallets.config.TestContextInitializer;
3536
import org.eclipse.tractusx.managedidentitywallets.constant.RestURI;
3637
import org.eclipse.tractusx.managedidentitywallets.dao.entity.HoldersCredential;
@@ -89,6 +90,9 @@ class IssuersCredentialTest {
8990
@Autowired
9091
private IssuersCredentialRepository issuersCredentialRepository;
9192

93+
@Autowired
94+
private RevocationSettings revocationSettings;
95+
9296

9397
@MockInBean(RevocationService.class)
9498
private RevocationClient revocationClient;
@@ -259,7 +263,7 @@ void issueCredentials200() throws com.fasterxml.jackson.core.JsonProcessingExcep
259263

260264
List<HoldersCredential> credentials = holdersCredentialRepository.getByHolderDidAndType(did, type);
261265
Assertions.assertFalse(credentials.isEmpty());
262-
TestUtils.checkVC(credentials.get(0).getData(), miwSettings);
266+
TestUtils.checkVC(credentials.get(0).getData(), miwSettings, revocationSettings);
263267
Assertions.assertFalse(credentials.get(0).isStored()); //stored must be false
264268
Assertions.assertFalse(credentials.get(0).isSelfIssued()); //stored must be false
265269

0 commit comments

Comments
 (0)