Skip to content

Commit

Permalink
Merge pull request #67 from ooni/run-tests
Browse files Browse the repository at this point in the history
Run Tests
  • Loading branch information
sdsantos authored Aug 20, 2024
2 parents b3668f4 + a727bc2 commit 209b8d4
Show file tree
Hide file tree
Showing 68 changed files with 1,670 additions and 377 deletions.
7 changes: 5 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
root = true

[*]

indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
insert_final_newline = true

[*.{kt,kts}]
ktlint_standard_multiline-expression-wrapping = disabled
ktlint_standard_string-template-indent = disabled
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class AndroidApplication : Application() {
networkTypeFinder =
AndroidNetworkTypeFinder(getSystemService(ConnectivityManager::class.java)),
buildDataStore = ::buildDataStore,
// TODO: isBatteryCharging
isBatteryCharging = { true },
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@

test_experimental.xml
test_performance.xml
test_instant_messaging.xml
test_websites.xml
logo.xml
test_circumvention.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<path
android:name="path"
android:pathData="M 69.026 57.094 L 55.667 57.094 L 55.667 42 L 69.026 42 L 69.026 31.031 L 89 49.145 L 69.026 67.258 L 69.026 57.094 Z M 9 42 L 24.365 42 L 24.365 57.094 L 9 57.094 L 9 42 Z M 32.333 10 L 47.698 10 L 47.698 90 L 32.333 90 L 32.333 10 Z"
android:fillColor="#000"
android:fillColor="#E64980"
android:strokeWidth="1"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<path
android:name="path"
android:pathData="M7,2V4H8V18A4,4 0 0,0 12,22A4,4 0 0,0 16,18V4H17V2H7M11,16C10.4,16 10,15.6 10,15C10,14.4 10.4,14 11,14C11.6,14 12,14.4 12,15C12,15.6 11.6,16 11,16M13,12C12.4,12 12,11.6 12,11C12,10.4 12.4,10 13,10C13.6,10 14,10.4 14,11C14,11.6 13.6,12 13,12M14,7H10V4H14V7Z"
android:fillColor="#000"
android:fillColor="#495057"
android:strokeWidth="1" />
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="36dp"
android:height="36dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
android:name="path"
android:pathData="M 53.826 59.739 L 43.739 48.957 L 23.913 59.739 L 45.826 36.435 L 56.261 47.217 L 75.739 36.435 L 53.826 59.739 Z M 50 10 C 27.739 10 10 26.696 10 47.217 C 10 58.696 15.565 69.478 24.957 76.087 L 24.957 90.348 L 38.522 82.696 C 42.348 83.739 46.174 84.087 50 84.087 C 71.913 84.087 90 67.391 90 47.217 C 90 27.043 71.913 10 50 10 Z"
android:fillColor="#000000"
android:strokeWidth="1"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<path
android:name="path"
android:pathData="M 16.316 85.187 L 31.477 71.359 C 32.165 70.72 33.07 70.353 34.016 70.33 L 86.226 70.33 C 87.227 70.333 88.188 69.943 88.897 69.247 C 89.605 68.552 90.002 67.607 90 66.623 L 90 16.711 C 90.003 15.726 89.606 14.78 88.898 14.084 C 88.189 13.387 87.228 12.997 86.226 13 L 13.774 13 C 12.772 12.997 11.811 13.387 11.102 14.084 C 10.394 14.78 9.997 15.726 10 16.711 L 10 82.488 C 9.992 83.962 10.878 85.299 12.253 85.886 C 13.628 86.474 15.226 86.199 16.316 85.187 Z"
android:fillColor="#000"
android:fillColor="#15aabf"
android:strokeWidth="1"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<path
android:name="path"
android:pathData="M 70 10 L 54.039 42.013 L 70 42.013 L 42.018 90 L 42.018 53.975 L 30 53.975 L 30 10 Z"
android:fillColor="#000"
android:fillColor="#be4bdb"
android:strokeWidth="1"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="36dp"
android:height="36dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
android:name="path"
android:pathData="M 50 10 C 72.261 10 90 27.739 90 50 C 90 72.261 72.261 90 50 90 C 27.739 90 10 72.261 10 50 C 10 27.739 27.739 10 50 10 Z M 68.626 23.165 L 30.361 23.165 C 28.292 25.253 26.569 27.342 25.19 29.778 L 40.358 29.778 L 34.153 76.424 C 36.911 77.468 39.669 78.165 42.427 78.861 L 43.806 64.937 L 45.184 63.892 L 64.49 63.892 L 69.661 59.367 L 73.797 29.082 C 72.074 26.994 70.35 24.905 68.626 23.165 Z M 63.615 32.278 L 64.684 33.307 L 61.833 53.529 L 60.408 54.557 L 46.156 54.557 L 45.443 53.529 L 48.293 33.307 L 49.362 32.278 L 63.615 32.278 Z"
android:fillColor="#000000"
android:strokeWidth="1"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="30dp"
android:height="30dp"
android:viewportWidth="30"
android:viewportHeight="30">
<path
android:name="path"
android:pathData="M 13.3 3.6 L 13.5 4.7 C 14.5 4.5 15.6 4.5 16.6 4.7 L 16.8 3.6 C 16.2 3.5 15.7 3.5 15.1 3.5 C 14.4 3.5 13.8 3.5 13.3 3.6 Z M 17.5 4.9 C 18.5 5.2 19.5 5.6 20.4 6.1 L 21 5.2 C 20 4.6 18.9 4.2 17.8 3.9 L 17.5 4.9 Z M 9.1 5.2 L 9.7 6.1 C 10.6 5.6 11.6 5.2 12.6 4.9 L 12.3 3.9 C 11.1 4.1 10 4.6 9.1 5.2 Z M 15 5.7 C 11.6 5.7 8.5 7.5 6.8 10.5 C 5.2 13.5 5.3 17.1 7.1 20 L 6.2 23.8 L 10 22.9 C 13.4 25 17.7 24.8 20.8 22.3 C 23.9 19.8 25.1 15.7 23.8 11.9 C 22.5 8.2 19 5.7 15 5.7 Z M 21.2 6.6 C 22 7.2 22.8 8 23.4 8.8 L 24.3 8.2 C 23.6 7.3 22.8 6.5 21.9 5.8 L 21.2 6.6 Z M 5.7 8.2 L 6.6 8.8 C 7.2 8 8 7.2 8.8 6.6 L 8.2 5.7 C 7.2 6.4 6.4 7.2 5.7 8.2 Z M 23.9 9.6 C 24.4 10.5 24.8 11.5 25.1 12.5 L 26.1 12.2 C 25.8 11.1 25.4 10 24.8 9 L 23.9 9.6 Z M 3.8 12.2 L 4.8 12.5 C 5.1 11.5 5.5 10.5 6 9.6 L 5.2 9.1 C 4.6 10 4.1 11.1 3.8 12.2 Z M 25.3 13.4 C 25.4 13.9 25.4 14.4 25.4 15 C 25.4 15.5 25.4 16 25.3 16.6 L 26.4 16.8 C 26.6 15.7 26.6 14.5 26.4 13.4 L 25.3 13.4 Z M 3.6 16.7 L 4.7 16.5 C 4.6 16 4.6 15.5 4.6 14.9 C 4.6 14.4 4.6 13.9 4.7 13.3 L 3.6 13.1 C 3.5 14.4 3.5 15.6 3.6 16.7 Z M 23.9 20.4 L 24.8 21 C 25.4 20 25.8 18.9 26.1 17.8 L 25.1 17.5 C 24.9 18.5 24.5 19.5 23.9 20.4 Z M 3.8 17.8 C 4 18.8 4.4 19.7 4.9 20.5 L 4.6 21.6 L 5.6 21.8 L 6 20.3 C 5.5 19.4 5.1 18.5 4.8 17.5 L 3.8 17.8 Z M 21.2 23.4 L 21.8 24.3 C 22.7 23.6 23.6 22.8 24.2 21.9 L 23.3 21.3 C 22.8 22 22 22.8 21.2 23.4 Z M 3.9 24.8 C 3.8 25.2 3.9 25.5 4.2 25.8 C 4.5 26.1 4.8 26.2 5.2 26.1 L 7.4 25.6 L 7.2 24.5 L 5 25 L 5.5 22.8 L 4.5 22.6 L 3.9 24.8 Z M 17.5 25.1 L 17.8 26.1 C 18.9 25.8 20 25.4 21 24.8 L 20.4 23.9 C 19.5 24.5 18.5 24.9 17.5 25.1 Z M 9.7 24 L 8.2 24.4 L 8.4 25.4 L 9.5 25.1 C 10.4 25.6 11.3 25.9 12.2 26.2 L 12.5 25.2 C 11.5 24.9 10.5 24.5 9.7 24 Z M 13.4 25.3 L 13.2 26.4 C 14.3 26.6 15.5 26.6 16.6 26.4 L 16.4 25.3 C 15.5 25.5 14.5 25.5 13.4 25.3 Z"
android:fillColor="#000"
android:strokeWidth="1"
android:fillType="evenOdd"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="36dp"
android:height="36dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
android:name="path"
android:pathData="M 88.667 50.333 C 88.667 55.333 87.667 60.667 85.333 65.333 C 81.333 74.667 74.333 81.667 65 85.667 C 55.333 89.667 44.667 89.667 35.333 85.667 C 26.333 81.667 19 74.667 15 65.333 C 11 55.667 11 45 15 35.667 C 19 26 26.333 19 35.333 15 C 45 11 55.667 11 65 15 C 74.333 19 81.333 26 85.333 35.333 C 88 40.333 88.667 45.333 88.667 50.333 Z M 63 68 L 69.333 38.333 C 69.667 37.333 69.333 36.667 69 35.333 C 68.333 34.667 67.667 34.667 67 35 L 30 49.333 C 29.333 49.667 29 50 28.333 50.333 C 28 50.667 28 51 28.333 51.333 C 28.667 51.667 29 52 29.667 52 L 39 55 L 60.667 41 C 61.333 40.667 61.667 40.667 62 40.667 C 62.333 40.667 62 41 62 41.333 L 44 57.333 L 43.667 67 C 44.333 67 45 66.667 45.333 66 L 50 61.333 L 59.667 68.333 C 61.333 70.667 62.667 70 63 68 Z"
android:fillColor="#000000"
android:strokeWidth="1"/>
</vector>
13 changes: 13 additions & 0 deletions composeApp/src/commonMain/composeResources/drawable/test_tor.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="36dp"
android:height="36dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
android:name="path"
android:pathData="M 50 81.333 L 50 76.667 C 64.667 76.667 76.667 64.667 76.667 50 C 76.667 35.333 64.667 23.333 50 23.333 L 50 18.667 C 67.333 18.667 81.333 32.667 81.333 50 C 81.333 67.333 67.333 81.333 50 81.333 Z M 50 65 C 58.333 65 65 58.333 65 50 C 65 41.667 58.333 35 50 35 L 50 30.333 C 61 30.333 69.667 39.333 69.667 50 C 69.667 61 61 69.667 50 69.667 L 50 65 Z M 50 42 C 54.333 42 58 45.667 58 50 C 58 54.333 54.333 58 50 58 L 50 42 Z M 11.667 50 C 11.667 71.333 28.667 88.333 50 88.333 C 71.333 88.333 88.333 71.333 88.333 50 C 88.333 28.667 71.333 11.667 50 11.667 C 28.667 11.667 11.667 28.667 11.667 50 Z"
android:fillColor="#000000"
android:strokeWidth="1"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<path
android:name="path"
android:pathData="M 67.5 57.667 C 67.811 55.054 68.045 52.442 68.045 49.75 C 68.045 47.058 67.811 44.446 67.5 41.833 L 80.655 41.833 C 81.277 44.367 81.667 47.019 81.667 49.75 C 81.667 52.481 81.277 55.133 80.655 57.667 L 67.5 57.667 Z M 60 79.333 C 62.425 74.916 64.284 70.141 65.577 65.167 L 77.5 65.167 C 73.62 71.733 67.436 76.826 60 79.333 Z M 59.36 57.667 L 40.64 57.667 C 40.24 55.054 40 52.442 40 49.75 C 40 47.058 40.24 44.406 40.64 41.833 L 59.36 41.833 C 59.72 44.406 60 47.058 60 49.75 C 60 52.442 59.72 55.054 59.36 57.667 Z M 50 81 C 46.741 76.202 44.11 70.884 42.5 65.167 L 57.5 65.167 C 55.89 70.884 53.259 76.202 50 81 Z M 34.329 34.333 L 22.5 34.333 C 26.348 27.728 32.587 22.634 40 20.167 C 37.569 24.584 35.747 29.359 34.329 34.333 Z M 22.5 65.167 L 34.329 65.167 C 35.747 70.141 37.569 74.916 40 79.333 C 32.587 76.826 26.348 71.733 22.5 65.167 Z M 19.345 57.667 C 18.723 55.133 18.333 52.481 18.333 49.75 C 18.333 47.019 18.723 44.367 19.345 41.833 L 32.5 41.833 C 32.189 44.446 31.955 47.058 31.955 49.75 C 31.955 52.442 32.189 55.054 32.5 57.667 L 19.345 57.667 Z M 50 18.5 C 53.259 23.286 55.89 28.63 57.5 34.333 L 42.5 34.333 C 44.11 28.63 46.741 23.286 50 18.5 Z M 77.5 34.333 L 65.577 34.333 C 64.284 29.359 62.425 24.584 60 20.167 C 67.436 22.674 73.62 27.728 77.5 34.333 Z M 50 11 C 27.88 11 10 28.625 10 50.167 C 10 60.554 14.214 70.517 21.716 77.862 C 29.217 85.207 39.391 89.333 50 89.333 C 72.091 89.333 90 71.798 90 50.167 C 90 39.779 85.786 29.817 78.284 22.472 C 70.783 15.126 60.609 11 50 11 Z"
android:fillColor="#000"
android:fillColor="#4c6ef5"
android:strokeWidth="1"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="36dp"
android:height="36dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path
android:name="path"
android:pathData="M 51.187 10 C 56.339 10 61.491 11.039 66.3 13.117 C 75.574 16.926 83.13 24.545 86.909 33.896 C 91.03 43.593 91.03 54.329 86.909 64.026 C 83.13 73.377 75.574 80.649 66.3 84.805 C 61.491 86.883 56.339 87.922 51.187 87.922 C 44.661 87.922 38.135 86.19 32.296 83.074 L 11 90 L 17.87 69.221 C 11.343 58.485 10.657 45.671 15.465 34.242 C 19.243 24.892 26.8 17.619 36.074 13.463 C 40.883 11.039 46.035 10 51.187 10 Z M 51.685 81 C 56.178 81 60.326 79.954 64.127 78.56 C 72.076 75.424 78.297 69.15 81.408 61.134 C 84.864 53.118 84.864 44.056 81.408 36.04 C 78.297 28.373 72.076 22.099 64.127 18.614 C 56.178 15.129 46.847 15.129 38.898 18.614 C 30.948 21.751 24.727 28.024 21.617 36.04 C 17.124 46.496 18.506 58.694 25.073 67.756 L 20.926 79.954 L 33.368 76.121 C 39.243 79.257 45.464 81 51.685 81 Z M 61.261 53.491 C 63 54.182 64.739 54.873 66.478 55.909 C 68.217 56.6 69.609 57.636 71 58.673 L 71 59.364 C 71 60.745 70.652 62.127 69.957 63.164 C 69.261 64.545 67.87 65.927 66.13 66.618 C 64.391 67.309 62.652 68 60.913 68 C 57.435 67.655 53.957 66.618 51.174 64.891 C 48.043 63.509 44.913 61.436 42.478 58.673 C 39.696 55.909 36.913 52.455 34.826 49.345 C 32.739 46.582 31.348 43.127 31 39.327 L 31 38.982 C 31 35.873 32.391 33.109 34.826 31.036 C 35.522 30.345 36.565 30 37.609 30 L 39.696 30 C 40.043 30 40.739 30 41.087 30.345 C 41.435 30.691 41.783 31.382 41.783 31.727 C 42.13 32.418 42.478 33.8 43.522 36.218 C 44.217 37.6 44.565 38.636 44.913 40.018 C 44.565 41.055 43.87 42.091 43.174 43.127 C 42.13 44.509 41.435 45.2 41.435 45.545 C 41.435 45.891 41.435 46.236 41.783 46.236 C 43.174 49 44.913 51.418 47 53.145 C 49.435 55.218 51.87 56.945 55 58.327 C 55.348 58.673 55.696 58.673 56.043 58.673 C 56.391 58.673 57.435 57.982 58.826 56.255 C 60.217 54.182 60.913 53.491 61.261 53.491 Z"
android:fillColor="#000000"
android:strokeWidth="1"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@
<string name="Dashboard_RunV2_Ooni_Title">OONI Tests</string>
<string name="Dashboard_RunV2_Title">OONI Run Links</string>

<string name="Test_Websites_Fullname">Websites</string>
<string name="Test_InstantMessaging_Fullname">Instant Messaging</string>
<string name="Test_Middleboxes_Fullname">Middleboxes</string>
<string name="Test_Performance_Fullname">Performance</string>
<string name="Test_Circumvention_Fullname">Circumvention</string>
<string name="Test_Experimental_Fullname">Experimental</string>
<string name="Test_HTTPInvalidRequestLine_Fullname">HTTP Invalid Request Line Test</string>
<string name="Test_HTTPHeaderFieldManipulation_Fullname">HTTP Header Field Manipulation Test</string>
<string name="Test_WebConnectivity_Fullname">Web Connectivity Test</string>
<string name="Test_NDT_Fullname">NDT Speed Test</string>
<string name="Test_Dash_Fullname">DASH Streaming Test</string>
<string name="Test_WhatsApp_Fullname">WhatsApp Test</string>
<string name="Test_Telegram_Fullname">Telegram Test</string>
<string name="Test_FacebookMessenger_Fullname">Facebook Messenger Test</string>
<string name="Test_Psiphon_Fullname">Psiphon Test</string>
<string name="Test_Tor_Fullname">Tor Test</string>
<string name="Test_Signal_Fullname">Signal Test</string>

<string name="TestResults_Overview_Title">Test Results</string>
<string name="TestResults_Overview_Tab_Label">Test Results</string>
<string name="TestResults_UnknownASN">Unknown</string>
Expand Down
23 changes: 13 additions & 10 deletions composeApp/src/commonMain/kotlin/org/ooni/engine/Engine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.ooni.engine.OonimkallBridge.SubmitMeasurementResults
import org.ooni.engine.models.NetworkType
import org.ooni.engine.models.Result
import org.ooni.engine.models.TaskEvent
import org.ooni.engine.models.TaskEventResult
import org.ooni.engine.models.TaskLogLevel
import org.ooni.engine.models.TaskOrigin
import org.ooni.engine.models.TaskSettings
import org.ooni.engine.models.WebConnectivityCategory
import org.ooni.engine.models.resultOf
import org.ooni.probe.config.Config
import org.ooni.probe.shared.Platform
import org.ooni.probe.shared.PlatformInfo
import kotlin.time.Duration

class Engine(
private val bridge: OonimkallBridge,
Expand All @@ -27,16 +30,18 @@ class Engine(
private val cacheDir: String,
private val taskEventMapper: TaskEventMapper,
private val networkTypeFinder: NetworkTypeFinder,
private val isBatteryCharging: suspend () -> Boolean,
private val platformInfo: PlatformInfo,
private val backgroundDispatcher: CoroutineDispatcher,
) {
fun startTask(
name: String,
inputs: List<String>?,
taskOrigin: TaskOrigin,
maxRuntime: Duration?,
): Flow<TaskEvent> =
channelFlow {
val taskSettings = buildTaskSettings(name, inputs, taskOrigin)
val taskSettings = buildTaskSettings(name, inputs, taskOrigin, maxRuntime)
val settingsSerialized = json.encodeToString(taskSettings)

var task: OonimkallBridge.Task? = null
Expand Down Expand Up @@ -69,21 +74,19 @@ class Engine(
session(sessionConfig).submitMeasurement(measurement)
}.mapError { MkException(it) }

suspend fun checkIn(
categories: List<String>,
taskOrigin: TaskOrigin,
): Result<OonimkallBridge.CheckInResults, Exception> =
suspend fun checkIn(taskOrigin: TaskOrigin): Result<OonimkallBridge.CheckInResults, MkException> =
resultOf(backgroundDispatcher) {
val sessionConfig = buildSessionConfig(taskOrigin)
session(sessionConfig).checkIn(
OonimkallBridge.CheckInConfig(
charging = true,
onWiFi = true,
charging = isBatteryCharging(),
onWiFi = networkTypeFinder() == NetworkType.Wifi,
platform = platformInfo.platform.value,
runType = taskOrigin.value,
softwareName = sessionConfig.softwareName,
softwareVersion = sessionConfig.softwareVersion,
webConnectivityCategories = categories,
// TODO: fetch enabled categories from preferences
webConnectivityCategories = WebConnectivityCategory.entries.map { it.code },
),
)
}.mapError { MkException(it) }
Expand All @@ -109,6 +112,7 @@ class Engine(
name: String,
inputs: List<String>?,
taskOrigin: TaskOrigin,
maxRuntime: Duration?,
) = TaskSettings(
name = name,
inputs = inputs.orEmpty(),
Expand All @@ -130,8 +134,7 @@ class Engine(
noCollector = true,
softwareName = buildSoftwareName(taskOrigin),
softwareVersion = platformInfo.version,
// TODO: fetch from preferences
maxRuntime = -1,
maxRuntime = maxRuntime?.inWholeSeconds?.toInt() ?: -1,
),
annotations =
TaskSettings.Annotations(
Expand Down
Loading

0 comments on commit 209b8d4

Please sign in to comment.