diff --git a/.github/workflows/pkg_test.yml b/.github/workflows/pkg_test.yml index 45a4a00c..60512e62 100644 --- a/.github/workflows/pkg_test.yml +++ b/.github/workflows/pkg_test.yml @@ -7,13 +7,16 @@ jobs: runs-on: "ubuntu-20.04" container: debian:10 steps: + - name: Change Owner of Container Working Directory + run: chown root:root . + - name: Install git run: | apt-get update -q apt-get install -y git - name: Check out repository code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 diff --git a/newapi/debian/changelog b/newapi/debian/changelog index a24ec779..e45f1895 100644 --- a/newapi/debian/changelog +++ b/newapi/debian/changelog @@ -1,3 +1,9 @@ +ooni-api (1.0.35) unstable; urgency=medium + + * Add feature flagging + + -- Federico Ceratto Mon, 09 Jan 2023 17:41:05 +0000 + ooni-api (1.0.34) unstable; urgency=medium * Implement MAT granularity diff --git a/newapi/ooniapi/probe_services.py b/newapi/ooniapi/probe_services.py index 15559a41..a996ce3c 100644 --- a/newapi/ooniapi/probe_services.py +++ b/newapi/ooniapi/probe_services.py @@ -176,6 +176,7 @@ def check_in() -> Response: properties: v: type: integer + description: response format version probe_cc: type: string description: probe CC inferred from GeoIP or ZZ @@ -188,8 +189,19 @@ def check_in() -> Response: utc_time: type: string description: current UTC time as YYYY-mm-ddTHH:MM:SSZ + conf: + type: object + description: auxiliary configuration parameters + psiphon: + type: object + tor: + type: object + features: + type: object + description: feature flags tests: type: object + description: test-specific configuration properties: web_connectivity: type: object @@ -256,10 +268,19 @@ def check_in() -> Response: try: torconf = _load_json(current_app.config["TOR_TARGETS_CONFFILE"]) psconf = _load_json(current_app.config["PSIPHON_CONFFILE"]) - conf = dict(tor=torconf, psiphon=psconf) + conf = dict(tor=torconf, psiphon=psconf, features={}) except Exception as e: log.error(str(e), exc_info=True) - conf = {} + conf = dict(features={}) + + try: + # set webconnectivity_0.5 feature flag for some probes + ipaddr = extract_probe_ipaddr() + n = int(ipaddr.split(".", 2)[1]) + if n in (34,): + conf["features"]["webconnectivity_0.5"] = True + except Exception: + pass resp["tests"] = { "web_connectivity": {"urls": test_items}, diff --git a/newapi/tests/integ/test_probe_services.py b/newapi/tests/integ/test_probe_services.py index 23a4cfb7..59e39ad5 100644 --- a/newapi/tests/integ/test_probe_services.py +++ b/newapi/tests/integ/test_probe_services.py @@ -102,7 +102,7 @@ def test_check_in_basic(client): assert cc == "US" # psiphon and tor configurations - assert sorted(c["conf"]) == ["psiphon", "tor"] + assert sorted(c["conf"]) == ["features", "psiphon", "tor"] def test_check_in_url_category_news(client): diff --git a/newapi/tests/integ/test_probe_services_nodb.py b/newapi/tests/integ/test_probe_services_nodb.py index d48948e3..829aa070 100644 --- a/newapi/tests/integ/test_probe_services_nodb.py +++ b/newapi/tests/integ/test_probe_services_nodb.py @@ -148,7 +148,7 @@ def test_check_in(client, mocks): assert cc == "US" # psiphon and tor configurations - assert sorted(c["conf"]) == ["psiphon", "tor"] + assert sorted(c["conf"]) == ["features", "psiphon", "tor"] def test_check_in_url_category_news(client, mocks):