OpenFeign/feign

feign-mock is too strict with request headers when matching requests

Open

#1.552 aberto em 20 de dez. de 2021

Ver no GitHub
 (0 comments) (0 reactions) (0 assignees)Java (1.911 forks)batch import
help wantedproposal

Métricas do repositório

Stars
 (9.070 stars)
Métricas de merge de PR
 (Mesclagem média 3d 8h) (59 fundiu PRs em 30d)

Description

I am using https://github.com/OpenFeign/feign/tree/master/mock to write unit tests. When one would want to match/verify request headers, the current implementation seems too strict as it checks for exact equality. Ideally, it should be matching a subset of the headers as there can be headers the tester doesn't care about or generated headers like Content-Length.

I know the workaround for this is to write a RequestInterceptor and do assertions there, but that is not ideal as it adds a lot of boilerplate code in tests. For each test, one needs to write a test-specific RequestInterceptor.

I would like to propose making the header matching in RequestKey.java#L171 match a subset of the headers instead of exact equality.

Bonus Request: match with RegEx

Guia do colaborador