【问题标题】:Running Pact provider tests against deployed HTTPS provider针对已部署的 HTTPS 提供程序运行 Pact 提供程序测试
【发布时间】:2019-08-01 17:04:43
【问题描述】:

我想为我的客户端和 API 设置 Pact 合同测试。我的 API 无法在本地运行,因此我希望能够在部署到生产环境之前针对已部署的 API 暂存版本运行提供程序测试。

我在网上看到的大多数提供程序测试示例都使用了 localhost。 尝试针对我部署的 HTTPS 端点运行提供程序测试时,测试失败并显示 read server hello A: unknown protocol。 是不支持 HTTPS 协议,还是我遗漏了什么?

func TestTenantProvider(t *testing.T) {

    // Create Pact connecting to local Daemon
    pact := &dsl.Pact{
        Consumer: "TenantConsumer",
        Provider: "TenantProvider",
    }


    // Verify the Provider with local Pact Files
    pact.VerifyProvider(t, types.VerifyRequest{
        ProviderBaseURL:        "https://my-staging-endpoint.com",
        PactURLs:               []string{filepath.ToSlash(fmt.Sprintf("%s/tenantconsumer-tenantprovider.json", pactDir))},
    })
}

使用pact-provider-verifier 命令行工具可以正常工作。

【问题讨论】:

    标签: pact pact-go


    【解决方案1】:

    它应该支持通过 HTTPS 进行验证,但目前我不相信我们在 Pact Go 中很容易支持带有自签名证书的 SSL(参见 https://github.com/pact-foundation/pact-go/issues/66)。

    理论上,您应该能够为您的 SSL 配置 [1] 设置一个环境变量,如下所示:

    要连接到使用自定义 SSL 证书的 Pact Broker,请将环境变量 $SSL_CERT_FILE 或 $SSL_CERT_DIR 设置为包含相应证书的路径。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-28
      • 1970-01-01
      • 2011-04-10
      • 2020-09-27
      相关资源
      最近更新 更多