Skip to content

Commit

Permalink
feat (OONI Run v2): make probe service url configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed Apr 3, 2024
1 parent fd2159c commit bb21dc2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ android {
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android-dev"'
resValue "string", "APP_ID", 'org.openobservatory.ooniprobe.dev'
resValue "string", "APP_NAME", "OONI Dev"
buildConfigField 'String', 'OONI_API_BASE_URL', '"https://api.dev.ooni.io"'
buildConfigField 'String', 'COUNTLY_KEY', '"e6c2cfe53e85951d50567467cef3f9fa2eab32c3"'
}
experimental {
Expand All @@ -70,6 +71,7 @@ android {
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android-experimental"'
resValue "string", "APP_ID", 'org.openobservatory.ooniprobe.experimental'
resValue "string", "APP_NAME", "OONI Exp"
buildConfigField 'String', 'OONI_API_BASE_URL', '"https://api.dev.ooni.io"'
buildConfigField 'String', 'COUNTLY_KEY', '"e6c2cfe53e85951d50567467cef3f9fa2eab32c3"'
}
fdroid {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class TestDescriptorManager @Inject constructor(
)
val ooniContext = session.newContextWithTimeout(300)

val response: OONIRunDescriptor = session.ooniRunFetch(ooniContext, runId)
val response: OONIRunDescriptor =
session.ooniRunFetch(ooniContext, BuildConfig.OONI_API_BASE_URL, runId)
return TestDescriptor(
runId = runId,
name = response.name,
Expand Down Expand Up @@ -112,7 +113,7 @@ class TestDescriptorManager @Inject constructor(
}

fun delete(descriptor: InstalledDescriptor): Boolean {
preferenceManager.sp.all.entries.forEach {entry ->
preferenceManager.sp.all.entries.forEach { entry ->
if (entry.key.contains(descriptor.testDescriptor.runId.toString())) {
preferenceManager.sp.edit().remove(entry.key).apply()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public interface OONISession {
* @param id ooni run id
* @return [OONIRunFetchResponse] with the contents of the ooni run descriptor.
*/
OONIRunDescriptor ooniRunFetch(OONIContext ctx, long id) throws Exception;
OONIRunDescriptor ooniRunFetch(OONIContext ctx, String probeServicesURL, long id) throws Exception;

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class OONISessionConfig {
* usage of an alternative probe services. This setting
* should only be used to implement integration tests.
*/
String probeServicesURL;
public String probeServicesURL;

/**
* softwareName is a mandatory setting specifying the name of
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.openobservatory.engine;

import android.util.Log;

import com.google.gson.Gson;

import oonimkall.HTTPRequest;
import oonimkall.Oonimkall;
import oonimkall.Session;
Expand Down Expand Up @@ -30,11 +32,11 @@ public OONICheckInResults checkIn(OONIContext ctx, OONICheckInConfig config) thr
}

@Override
public OONIRunDescriptor ooniRunFetch(OONIContext ctx, long id) throws Exception {
public OONIRunDescriptor ooniRunFetch(OONIContext ctx, String probeServicesURL, long id) throws Exception {
HTTPRequest request = new HTTPRequest();
request.setMethod("GET");
request.setURL("https://run.test.ooni.org/api/v2/oonirun/links/" + id);
String response = session.httpDo(ctx.ctx,request).getBody();
request.setURL(probeServicesURL + "/api/v2/oonirun/links/" + id);
String response = session.httpDo(ctx.ctx, request).getBody();
Log.d(PESession.class.getName(), response);
return new Gson().fromJson(response, OONIRunDescriptor.class);
}
Expand Down

0 comments on commit bb21dc2

Please sign in to comment.