Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading contracts from Broker with basic auth does not work #129

Open
matus-m opened this issue Apr 18, 2019 · 0 comments
Open

Loading contracts from Broker with basic auth does not work #129

matus-m opened this issue Apr 18, 2019 · 0 comments

Comments

@matus-m
Copy link

matus-m commented Apr 18, 2019

Issue Overview

When using pact broker secured with basic auth, no pacts can be download.

Expected Behaviour

Pacts from broker should download without issues provided the configuration is ok.

Current Behaviour

Username and password are only used to download the consumer list, but when the actual pact contracts are loaded, the credentials are not used.

Problematic code: PactsRetriever

 protected List<Pact> loadContractFiles(List<URI> contracts, String providerName) {
        if (contracts != null) {
            List<URI> contractFiles = contracts.stream()
                .filter(uri -> uri.toString().endsWith(".json"))
                .collect(toList());

            if (contractFiles != null) {
                return contractFiles.stream()
                    .map(URI::toString)
                    .map(PactReader::loadPact)
                    .filter(pact -> pact.getProvider().getName().equals(providerName))
                    .collect(Collectors.toList());
            }
        }
        return new ArrayList<>();
    }

Here the lambda in stream processing calls PactReader::loadPact but does not specify any pact auth options, therefore the internal call to load pact from remote URL fails.

Steps To Reproduce

Try to fetch any pacts from broker secured with basic auth.

Additional Information

Could someone please comment on the general stability and development of this project? Is it used by someone?
There are many places in code, that do not look like it has been tested properly, for example the pact broker returns list of contract urls without .json suffix, however all this links will be filtered out by the filter inside loadContractFiles making it impossible to load any contracts form this broker. Or the getPacts method: it obvisouly intends to filter pacts only for given consumer if @Consumer annotation is present, however the code:

final Consumer consumerInfo = testClass.getAnnotation(Consumer.class);
final String consumerName = consumerInfo != null ? consumerInfo.value() : null;

couldnt ever work, because @Consumer annotation can not be applied to Types, only to fields.
Thanks for any input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant