【问题标题】:Unable to fetch PACT from Pact Brocker in dotnet core while verifying provider side验证提供商端时无法从 dotnet 核心中的 Pact Broker 获取 PACT
【发布时间】:2018-10-31 17:13:51
【问题描述】:

我已经在 C# dotnet core 的消费者端实现了 PACT,并且我能够使用以下代码将 *.json pact 文件发布到 PactBrocker。

var pactPublisher = new PactPublisher("http://domain.pact.dius.com.au", new PactUriOptions("***", "***"));

pactPublisher.PublishToBroker($"..\pacts\userservice.api-event.api.json",
                        "1.0.2");

在提供者方面(再次在 C# dotnet 核心中),当我尝试使用单元测试用例(参见下面的代码)验证相同的已发布 Pact 时:

[Fact]
public void EnsureEventApiHonoursPactWithConsumer()
{        
    //Arrange
    // createing the "config" object

    //Act / Assert
    IPactVerifier pactVerifier = new PactVerifier(config);

          pactVerifier
            .ProviderState($"{_providerUri}/provider-states")
            .ServiceProvider("Event.API", _providerUri)
            .HonoursPactWith("UserService.API")
       .PactUri("http://domain.pact.dius.com.au/pacts/provider/Event.API/consumer/UserService.API/version/1.0.2", new PactUriOptions("***", "***")).Verify();
}

我在运行该单元测试时低于 错误

PactNet.PactFailureException : Pact 验证失败。查看输出 详情。如果输出为空,请提供自定义 config.Outputters (IOutput) 用于您的测试框架,因为我们不能 写入控制台。在 PactNet.Core.PactCoreHost`1.Start() 中 C:\projects\pact-net\PactNet\Core\PactCoreHost.cs:139 行

在 Event.Test.EventApiTests.EnsureEventApiHonoursPactWithConsumer() 在 C:\POC\pact2\Event.Api\Event.Test\EventAPITests.cs:55 行

读取文件时出错 http://domain.pact.dius.com.au/pacts/provider/Event.API/consumer/UserService.API/version/1.0.2

由于目标机器正在活动,无法建立连接 拒绝了。 - 连接(2)“domain.pact.dius.com.au”端口 80 C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `初始化'

C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:在 `打开'

C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:在 `block in connect'

C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/timeout.rb:74:in `超时'

C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:878:在 `连接'

C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:863:在 `do_start'

C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:852:在 `开始'

有人可以帮忙解决这个错误吗? PACT 代理服务器不在我的控制范围内。我是从http://pact.dius.com.au/ 网站获得的。

【问题讨论】:

    标签: .net pact-broker


    【解决方案1】:

    得到了答案。我在我办公室的代理环境中。它在我家很好用。我还需要点击 https(端口 443)而不是 http(端口 80)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-22
      相关资源
      最近更新 更多