且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何针对需要身份验证令牌的 API 验证协议?

更新时间:2023-11-30 23:28:52

Pact 的 Ruby 实现并不像 JVM 实现那样直接支持这一点.

The Ruby implementation of Pact doesn't support this directly as per the JVM implementation.

如果您使用的是 Pact Provider Proxy gem,则可以查看 https://github.com/realestate-com-au/pact/issues/49#issuecomment-65346357https://groups.google.com/forum/#!topic/pact-support/tSyKZMxsECk.

If you're using the Pact Provider Proxy gem, you could take a look at some of the options discussed at https://github.com/realestate-com-au/pact/issues/49#issuecomment-65346357 and https://groups.google.com/forum/#!topic/pact-support/tSyKZMxsECk.

示例可能类似于:

class ProxyApp

  def initialize real_app
    @real_app = real_app
  end

  def call env
    @real_app.call(env.merge('HTTP_AUTHORIZATION' => '12345'))
  end
end

Pact.service_provider "Some Provider" do
  app do
    ProxyApp.new(RealApp)
  end

  honours_pact_with "Some Consumer" do
    #...
  end
end