• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FIWARE / contract-management / #48

06 Aug 2025 11:35AM UTC coverage: 1.655% (-0.2%) from 1.815%
#48

Pull #8

wistefan
fixes
Pull Request #8: Support multiple creds

2 of 60 new or added lines in 3 files covered. (3.33%)

25 existing lines in 3 files now uncovered.

558 of 33725 relevant lines covered (1.65%)

0.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.48
/src/main/java/org/fiware/iam/til/TrustedIssuersListAdapter.java
1
package org.fiware.iam.til;
2

3
import io.micronaut.http.HttpResponse;
4
import io.micronaut.http.HttpStatus;
5
import io.micronaut.http.client.exceptions.HttpClientResponseException;
6
import io.micronaut.http.exceptions.HttpException;
7
import jakarta.inject.Singleton;
8
import lombok.RequiredArgsConstructor;
9
import lombok.extern.slf4j.Slf4j;
10
import org.fiware.iam.exception.TMForumException;
11
import org.fiware.iam.exception.TrustedIssuersException;
12
import org.fiware.iam.til.api.IssuerApiClient;
13
import org.fiware.iam.til.model.ClaimVO;
14
import org.fiware.iam.til.model.CredentialsVO;
15
import org.fiware.iam.til.model.TrustedIssuerVO;
16
import reactor.core.publisher.Mono;
17

18
import java.util.*;
19

20
@Singleton
21
@RequiredArgsConstructor
22
@Slf4j
1✔
23
public class TrustedIssuersListAdapter {
24

25
        private final IssuerApiClient apiClient;
26

27
        public Mono<?> allowIssuer(String issuerDid, List<CredentialsVO> credentialsConfig) {
28

29
                return getIssuer(issuerDid)
1✔
30
                                .onErrorResume(e -> {
1✔
31
                                        if (e instanceof HttpClientResponseException hcr && hcr.getStatus() == HttpStatus.NOT_FOUND) {
×
32
                                                log.debug("Requested issuer {} does not exist.", issuerDid);
×
33
                                                return Mono.just(Optional.empty());
×
34
                                        }
35
                                        throw new TrustedIssuersException("Client error on issuer retrieval.", e);
×
36
                                })
37
                                .flatMap(optionalIssuer -> {
1✔
38
                                        if (optionalIssuer.isPresent()) {
1✔
39
                                                TrustedIssuerVO trustedIssuerVO = optionalIssuer.get();
1✔
40
                                                Set<CredentialsVO> credentialsVOSet = new HashSet<>(trustedIssuerVO.getCredentials());
1✔
41
                                                credentialsVOSet.addAll(credentialsConfig);
1✔
42
                                                trustedIssuerVO.setCredentials(new ArrayList<>(credentialsVOSet));
1✔
43
                                                log.debug("Updating existing issuer with {}", trustedIssuerVO);
1✔
44
                                                return apiClient.updateIssuer(issuerDid, trustedIssuerVO);
1✔
45
                                        } else {
46
                                                TrustedIssuerVO newIssuer = new TrustedIssuerVO().did(issuerDid).credentials(credentialsConfig);
1✔
47
                                                log.debug("Adding new issuer with {}", newIssuer);
1✔
48
                                                return apiClient.createTrustedIssuer(newIssuer);
1✔
49
                                        }
50
                                })
51
                                .onErrorMap(e -> {
1✔
52
                                        throw new TrustedIssuersException("Was not able to allow the issuer.", e);
1✔
53
                                });
54

55
        }
56

57
        public Mono<HttpResponse<?>> denyIssuer(String issuerDid) {
58

59
//                return getIssuer(issuerDid)
60
//                                .onErrorResume(e -> {
61
//                                        log.info("Was not able to get the issuer.", e);
62
//                                        return Mono.just(Optional.empty());
63
//                                })
64
//                                .flatMap(optionalIssuer -> {
65
//                                        if (optionalIssuer.isPresent()) {
66
//                                                TrustedIssuerVO updatedIssuer = optionalIssuer.get().removeCredentialsItem(credentialToBeRemoved);
67
//                                                log.debug("Updating existing issuer with {}", updatedIssuer);
68
//                                                return apiClient.updateIssuer(issuerDid, updatedIssuer);
69
//                                        }
70
//                                        return Mono.just(HttpResponse.noContent());
71
//                                })
72
//                                .onErrorMap(e -> {
73
//                                        throw new TrustedIssuersException("Was not able to deny the issuer.", e);
74
//                                });
NEW
75
                return Mono.just(HttpResponse.noContent());
×
76
        }
77

78
        private Mono<Optional<TrustedIssuerVO>> getIssuer(String issuerDid) {
79
                return apiClient.getIssuer(issuerDid)
1✔
80
                                .map(trustedIssuerVOHttpResponse -> {
1✔
81
                                        if (trustedIssuerVOHttpResponse.code() != HttpStatus.OK.getCode()) {
1✔
82
                                                log.debug("Could not find issuer {} in Trusted Issuers List. Status {}", issuerDid, trustedIssuerVOHttpResponse.code());
1✔
83
                                                return Optional.empty();
1✔
84
                                        }
85
                                        return Optional.ofNullable(trustedIssuerVOHttpResponse.body());
1✔
86
                                });
87

88
        }
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc