ooni-probe-cli/internal/engine/experiment
Simone Basso eed51978ca
refactor(httpx): hide the real APIClient (#648)
As mentioned in https://github.com/ooni/probe/issues/1951, one of
the main issues I did see with httpx.APIClient is that in some cases
it's used in a very fragile way by probeservices.Client.

This happens in psiphon.go and tor.go, where we create a copy of
the APIClient and then modify it's Authorization field.

If we ever refactor probeservices.Client to take a pointer to
httpx.Client, we are now mutating the httpx.Client.

Of course, we don't want that to happen.

This diff attempts to address such a problem as follows:

1. we create a new APIClientTemplate type that holds the same
fields of an APIClient and allows to build an APIClient

2. we modify every user of APIClient to use APIClientTemplate

3. when we need an APIClient, we build it from the corresponding
template and, when we need to use a specific Authorization, we
use a build factory that sets APIClient.Authorization

4. we hide APIClient by renaming it apiClient and by defining
an interface called APIClient that allows to use it

So, now the codebase always uses the opaque APIClient interface to
issue API calls and always uses the APIClientTemplate to build an
opaque APIClient.

Boom! We have separated construction from usage and we are not
mutating in weird ways the APIClient anymore.
2022-01-05 14:15:42 +01:00
..
dash refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
dnscheck refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
example refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
fbmessenger refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
hhfm refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
hirl refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
httphostheader refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
ndt7 refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
psiphon refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
riseupvpn refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
run refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
signal refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
sniblocking refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
stunreachability refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
telegram refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
tlstool refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
tor refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
torsf refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
urlgetter refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
webconnectivity refactor(httpx): hide the real APIClient (#648) 2022-01-05 14:15:42 +01:00
websteps refactor(httpx): hide the real APIClient (#648) 2022-01-05 14:15:42 +01:00
webstepsx cleanup: remove redundant HTTPClient definition (#643) 2022-01-03 16:47:54 +01:00
whatsapp refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
README.md chore: merge probe-engine into probe-cli (#201) 2021-02-02 12:05:47 +01:00

Directory github.com/ooni/probe-engine/experiment

This directory contains the implementation of all the supported experiments, one for each directory. The OONI spec repository contains a description of all the specified experiments.

Note that in the OONI spec repository experiments are called nettests. Originally, they were also called nettests here but that created confusion with nettests in ooni/probe-cli. Therefore, we now use the term experiment to indicate the implementation and the term nettest to indicate the user facing view of such implementation.

Note that some experiments implemented here are not part of the OONI specification. For example, the urlgetter experiment is not in the OONI spec repository. The reason why this happens is that urlgetter is an experiment "library" that other experiments use to implement their functionality.

Likewise, the example experiment is a minimal experiment that does nothing and you could use to bootstrap the implementation of a new experiment. Of course, this experiment is not part of the OONI specification.