coraza icon indicating copy to clipboard operation
coraza copied to clipboard

e2e: Expose expected config and e2e test cases

Open fionera opened this issue 1 year ago • 5 comments

Summary

Currently all users of the e2e tests have to copy the expected coraza config. As a user of the e2e test suite I would like to just access the expected config and test cases directly.

Basic example

Replace this with a public const inside https://github.com/corazawaf/coraza/blob/main/http/e2e/e2e.go Additionally all the e2e test cases could be exposed to be able to use the go built-in testing framework instead of calling an external binary.

Motivation

Reducing complexity and overhead for tests

fionera avatar Feb 19 '24 15:02 fionera

I agree directives should be somehow consumable rather than just documented. For go envs is as easy as consuming a constant, for non go maybe not that easy e.g. coraza-proxy-wasm although introduction of magefiles also help with that.

I am not 100% sure about exposing e2e test cases because they could change and exposing them means we have to maintain them in a public API manner. I'd rather keep that as it is.

jcchavezs avatar Feb 19 '24 16:02 jcchavezs

What do you mean with non-go? The coraza-proxy-wasm project is still written in go an can run the e2e tests by calling the entrypoint. Regarding api stability, I would just expose a small structure where the caller has to provide a http.Transport or connection and then use the normal go test function signature

fionera avatar Feb 19 '24 16:02 fionera

coraza-proxy-wasm is writen in Go but the e2e runs launching an envoy. In general the e2e package should be easy to run and not requiring you to get too deep into the internals. What I think we could do is to expose the runner aswel so it can be consumed as a library too.

jcchavezs avatar Feb 20 '24 08:02 jcchavezs

Actually it is possible to run this as a library, see https://github.com/jcchavezs/coraza-http-wasm/blob/main/e2e_test.go#L78

jcchavezs avatar Feb 21 '24 22:02 jcchavezs

Yes but I would like to call these cases directly to have the correct test names etc.

fionera avatar Feb 22 '24 00:02 fionera