I am getting this error when i am trying to use pa...
# pact-broker
s
I am getting this error when i am trying to use pactBroker instead of pactFolder .Failed to fetch the root HAL document au.com.dius.pact.core.pactbroker.InvalidNavigationRequest: Failed to fetch the root HAL document , any suggestion what i am doing wrong?
y
Do your broker require authentication, and have you provided it?
I would raise this in the #C9UN99H24 channel
m
Could you please share the setup? I’m guessing you’re passing a pact file URL to the broker path (which should just be the base host). But without seeing what you’re doing, it’s quite hard. DEBUG level logs would also suffice
s
import au.com.dius.pact.provider.junitsupport.StateChangeAction; import au.com.dius.pact.provider.junitsupport.loader.PactBroker; import au.com.dius.pact.provider.junitsupport.loader.PactBrokerAuth; import au.com.dius.pact.provider.junitsupport.loader.PactFolder; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment._RANDOM_PORT_) @Provider("AddressProvider") //@PactFolder("pacts") @PactBroker(url = "https://swedbankab.pactflow.io/", authentication = @PactBrokerAuth(token="Yz6NkQf-jjjjj")) public class PactProviderTest { @LocalServerPort public int port; @BeforeEach public void setUp(PactVerificationContext context){ context.setTarget(new HttpTestTarget("localhost",port)); System._setProperty_("pact.verifier.publishResults", "true"); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) public void verificationTest(PactVerificationContext context){ context.verifyInteraction(); } @State(value="address exist",action = StateChangeAction.SETUP) public void AddresExist(){} @State(value="address exist",action = StateChangeAction.TEARDOWN) public void AddressExitTearDown(){} }
Failed to fetch the root HAL document au.com.dius.pact.core.pactbroker.InvalidNavigationRequest: Failed to fetch the root HAL document at app<//au.com>.dius.pact.core.pactbroker.HalClient.navigate(HalClient.kt:253) at app<//au.com>.dius.pact.core.pactbroker.PactBrokerClient$fetchConsumersWithSelectorsV2$halClient$navigateResult$1.invoke(PactBrokerClient.kt:494) at app<//au.com>.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:35) at app<//au.com>.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumersWithSelectorsV2(PactBrokerClient.kt:494) at app<//au.com>.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:248) at app<//au.com>.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:128) at app<//au.com>.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$pactSources$1$pacts$1.invoke(PactJUnit5VerificationProvider.kt:78) at app<//au.com>.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:35) at app<//au.com>.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:78) at app<//au.com>.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:45) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:106) at java.base@17.0.5/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273) at java.base@17.0.5/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) at java.base@17.0.5/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base@17.0.5/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base@17.0.5/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base@17.0.5/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base@17.0.5/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base@17.0.5/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:110) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:44) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base@17.0.5/java.util.ArrayList.forEach(ArrayList.java:1511)
m
We need the debug logs where we can see the request. My guess is corporate proxy and you are being intercepted
See howtotls just in case
s
m
Also you posted your API token, you should immediately regenerate it
s
nope its a dummy one
m
Ok phew!
s
Failed to fetch the root HAL document I tried to setup proxy like this while running the tests but still getting below error $ ./gradlew test -Dhttp.proxyHost=ourhost.se -Dhttp.proxyPort=8080 -DnonProxyHosts=localhost,127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 PactProviderTest > verificationTest(PactVerificationContext) > initializationError FAILED au.com.dius.pact.core.pactbroker.InvalidNavigationRequest at HalClient.kt:253 Caused by: org.apache.hc.client5.http.HttpHostConnectException at Net.java:-2