PactSwift icon indicating copy to clipboard operation
PactSwift copied to clipboard

feature: Allows custom headers for provider verification (#95)

Open surpher opened this issue 3 years ago • 2 comments

📝 Summary of Changes

Changes proposed in this pull request:

  • ProviderVerifier Options initialiser accepts customHeader argument.
  • customHeader is a dictionary of Strings.
  • Only passes key-values that contain ASCII 32-127 characters only.
  • When non-allowed characters are passed they are ignored and logged into console.
  • Introduces a CharacterSet.headerASCIIAllowed containing only allowed characters.
  • Unit tests Options initialisation with allowed and non-allowed characters for header
  • Resolves #95

⚠️ Items of Note

Not verified with a provider.

💁 Example

let providerOptions = ProviderVerifier.Options(
	provider: .init(port: 8080),
	pactsSource: .directories(["/tmp/pacts"]),
	customHeader: ["Foo": "Bar 123abc_", "Bar": "BAZ"]
)

🔨 How To Test

  1. Checkout the branch feature/provider_verification_headers_option.
  2. Set up a provider project and prepare Options.
  3. Include customHeader dictionary in Options.
  4. Run provider verification tests.
  5. Custom headers should be honoured.

surpher avatar Oct 01 '22 09:10 surpher

Converted to draft due to pactffi version used in PactSwiftMockServer doesn't support this argument. Need to get the pactffi updated, release an updated PactSwiftMockServer and only then this will work.

Watch this space.

surpher avatar Oct 07 '22 07:10 surpher

PactSwiftMockServer v0.4.4 includes pactffi 0.3.15 that supports custom headers for non-handle based implementations.

This PR should be ready to verify it meets feature request's expectations.

surpher avatar Nov 28 '22 23:11 surpher