Open Doppiopreeda opened 3 years ago
Hi, currently it is indeed possible to use only one configuration file.
The content (request or response body) supports including other files (even recursively), i.e., you can have "respond":{ "content": "./data/my_response.json" }
and that file can similarly include other files as key values or array members. (IIRC there might be a requirement that the file string begins with a .
and ends with json
to avoid accidental expansions.)
However, for the configuration file itself, including other files is not as simple as one might think, since some things (such as the order of evaluation of regexp path matches) depend on the order they are listed in the file, and the keys "~"
and "*"
are often repeated in each file. So simply merging the dictionaries together is not trivial, as it is unclear how to define the order across multiple files or how to merge the same keys.
If your specific case does not have such conflicts or ambiguities, I would suggest that you simply make a script (e.g., in Python) that reads the files and merges their contents together (e.g., with update
or just by iterating over keys in each file and adding them to the same dictionary). You can then put this script + launching moxy into a wrapper script and it will effectively be like Moxy read the multiple files.
(If you have a good idea for how to support this directly in Moxy while solving the ambiguities, pull requests are welcome. =)
Firstly , I would like to thank you to produce this very great and easy to use work for community.
I have a quick question regarding mock configuration
background: currently we're using mitmproxy-mock in our test scenario and we have multiple cases which need to be mock differently my aim is to separate the mock config to be multiple files per test cases so, that the maintainer can easily find the right place when there is the changes need to be done.
question: as i check , right now it is support only 1 single file to be mock config, Is it possible to support multiple file in same folder ?
Best, Oz