Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android gRPC communication #6251

Closed
wants to merge 213 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
33df3a4
WIP
Rawa Nov 2, 2023
b41916a
temp
dlon Nov 2, 2023
c6faa6b
Working gRPC
Rawa Nov 3, 2023
018394c
Minor changes
Rawa Nov 3, 2023
5df78d6
Rebase fixes
Pururun Mar 14, 2024
a849439
Fix crash on startup
Pururun Mar 18, 2024
3df43db
Fix privacy login timeout error
Pururun Mar 18, 2024
204596c
WIP
Pururun Mar 26, 2024
deace38
wip
Rawa Mar 26, 2024
485ad65
wip
Rawa Mar 26, 2024
f2572f2
Some changes
Pururun Mar 26, 2024
ec9f6a8
Minor changes
Pururun Mar 26, 2024
13bb320
Tear out messenger layer
Rawa Mar 27, 2024
d429b7c
Clean up code
Rawa Mar 28, 2024
d6fb317
Sort of working service, no promises
Rawa Mar 28, 2024
39f9d38
Added support for selecting location
Pururun Mar 28, 2024
bd9b3b8
Clean up rust code
Rawa Apr 2, 2024
4ab3960
Create custom list working with either and gRPC
Rawa Apr 2, 2024
942f84e
Hook up relay list
Rawa Apr 3, 2024
5719438
Fix formatting
Rawa Apr 3, 2024
455aeee
Fix build
Rawa Apr 3, 2024
484ad0f
Migrate server ip override to gRPC
Pururun Apr 8, 2024
9fe5134
Migrate settings repository to gRPC
Pururun Apr 9, 2024
930a1dd
Fix account repository
Rawa Apr 9, 2024
9e211e2
Migrate relay list and related repositories
Pururun Apr 9, 2024
d11348b
Migrate device repository
Pururun Apr 10, 2024
d09e825
Migrate DeviceRepository
Rawa Apr 10, 2024
cb51222
Fix error
Rawa Apr 10, 2024
bbcadf2
Fix di
Rawa Apr 10, 2024
2b4ed3d
Make play calls go through managementservice
Pururun Apr 10, 2024
267057a
Format
Pururun Apr 10, 2024
1badb5c
Improve domain model
Rawa Apr 10, 2024
9b467d4
Fix wireguard custom port
Pururun Apr 10, 2024
0b8fc2e
Fix custom dns options
Pururun Apr 10, 2024
af24e01
Add arrow optics
Rawa Apr 11, 2024
75aa661
Migrate voucher repository to gRPC
Pururun Apr 11, 2024
9bf227c
Clean up build process and update libs
Rawa Apr 11, 2024
b65d149
Clean up old Unix domain socket on Android
MarkusPettersson98 Apr 11, 2024
0c8e113
Fix account expiry notification
Pururun Apr 12, 2024
a0746c3
Clean up gradle file
Rawa Apr 16, 2024
7f83af6
Clean up ManagementService a bit
Rawa Apr 16, 2024
64cb81d
Remove unused imports
Rawa Apr 16, 2024
8893d83
Open account page with account token correctly
Pururun Apr 16, 2024
acee460
fix domain mapper
Rawa Apr 16, 2024
aef2a40
Migrate mullvad tile and add rudimentary vpn permission handling
Pururun Apr 16, 2024
410841b
format and fix bugs
Rawa Apr 17, 2024
7b928c9
minor changes
Rawa Apr 17, 2024
bd2821b
wip
Rawa Apr 17, 2024
396d501
update constriants
Rawa Apr 17, 2024
48ced81
Add split tunneling repository
Pururun Apr 17, 2024
fe12695
Fix out address
Rawa Apr 17, 2024
daf9277
Migrate split tunneling settings to the daemon.
Pururun Apr 19, 2024
d9f3494
Properly connect to a vpn after accepting vpn permission
Pururun Apr 19, 2024
3fb90cc
Update filtered custom list behavior
Pururun Apr 19, 2024
0d1ac7d
Rebase cleanup
Pururun Apr 23, 2024
2587a94
Working tunnelstate notificaiton
Rawa Apr 24, 2024
8706119
Removed seperate processes and updated split tunneling migration
Pururun Apr 24, 2024
41a89f1
Expose play purchase API via gRPC
MarkusPettersson98 Apr 22, 2024
22edc77
Add support for google play payment
Pururun Apr 25, 2024
35164f9
Improve notifications
Rawa Apr 25, 2024
0007eac
Add basic account expiry notification
Rawa Apr 25, 2024
0ca16d4
Break out account module
Rawa Apr 25, 2024
1ea3d68
Make VoucherRepository update account expiry on redeem
Rawa Apr 25, 2024
6c8174e
minor clean up
Rawa Apr 25, 2024
916353d
Fix `rustc` warnings & TODOs, and remove dead code
MarkusPettersson98 Apr 25, 2024
87e8fe2
Add Android support for managing split-tunneling state in the daemon
MarkusPettersson98 Apr 23, 2024
59b0601
Migrate Android split tunnel apps to daemon settings
MarkusPettersson98 Apr 26, 2024
f349024
Whatever
Pururun Apr 24, 2024
79178ac
Add app migration logic
Pururun Apr 29, 2024
5176640
Update migrate split tunneling enabled file content
Pururun Apr 29, 2024
7fb4ed5
Remove set exclude apps
Pururun Apr 29, 2024
143a794
Migrate Android split tunnel apps to daemon settings
MarkusPettersson98 Apr 26, 2024
79a4a33
Fixed some unit tests
Pururun Apr 30, 2024
fe7b639
Fix merge issue
Pururun Apr 30, 2024
ad78be8
Fix warning
Pururun Apr 30, 2024
1f78f1d
Fixed most of the unit tests
Pururun Apr 30, 2024
b61bf04
Fix remaining unit tests
Pururun May 2, 2024
068efe5
Fixed ui tests
Pururun May 2, 2024
de8aba1
Fix relay comparator test
Pururun May 2, 2024
945ccf8
Fix setting api endpint configuration from intent
Pururun May 2, 2024
3f211ea
Handle VPN permission requests from notification
Pururun May 3, 2024
03da6b3
Removed a TODO
Pururun May 3, 2024
d4a4886
Fixed billing pamyent repository test
Pururun May 3, 2024
7ab738e
Fixed some minor stuff
Pururun May 3, 2024
efd687c
Fix minor issue
Pururun May 3, 2024
966939c
Fix connection proxy test
Pururun May 3, 2024
b5b6c30
Properly reconnect to gRPC when daemon is restarted
Pururun May 3, 2024
a45b9f0
Remove unused function
Pururun May 3, 2024
ad4b209
Show the correct name in connect screen
Pururun May 3, 2024
fe41eed
Fix some konsist tests
Pururun May 6, 2024
489908e
Fix acoount expiry notifications
Pururun May 6, 2024
27832d7
Fixed up tunnel state notification
Pururun May 6, 2024
67d8162
Added cache for last known location
Pururun May 6, 2024
d7085a0
Add relay list filter repository tests
Pururun May 6, 2024
1aa0fda
Fixed TODO in DeviceListScreen
Pururun May 6, 2024
6ba15ae
Fix connect screen tests
Pururun May 6, 2024
51239db
Fix lint issues
Pururun May 7, 2024
2fcdb9d
Fixed some detekt issues
Pururun May 7, 2024
5bdb1a2
Add missing unit tests to github action
Pururun May 7, 2024
a553e7e
Clean up a bit
Rawa May 7, 2024
8a02a53
Service update
Rawa May 8, 2024
ac2dbfa
Remove unused import
Rawa May 8, 2024
2ee995f
Clean up grpc comms
Rawa May 8, 2024
144143d
Fix tile service sometimes not updating & always on vpn start/stop
Rawa May 8, 2024
7c2ba6e
Clean up daemon setup
Rawa May 10, 2024
e71f402
Migrated TODO to linear issues
Pururun May 13, 2024
1cd3bfb
Don't force foreground on connect intent
Rawa May 13, 2024
753a492
Improve app version
Rawa May 13, 2024
16d24d3
Wip unbind
Rawa May 13, 2024
03f9e4c
fix compile
Rawa May 13, 2024
187403b
Fix dns error issue
Rawa May 13, 2024
d7ac46d
Fix rustc warnings and compile error on macOS
MarkusPettersson98 May 13, 2024
94cbfb5
Clean up
Rawa May 13, 2024
06430f6
Clean up device & account repository
Rawa May 14, 2024
acfb2a3
Fix welcome view model
Rawa May 14, 2024
847bfee
Manage account url
Rawa May 14, 2024
5e1bb30
Show error when failing to delete a custom list
Pururun May 14, 2024
b428ae2
Tidy up most of the logs
Pururun May 14, 2024
659860f
update notification behaviour
Rawa May 14, 2024
a1c3627
Ensure we still show in revoked
Rawa May 14, 2024
afdd0ec
Fix minor issue
Pururun May 14, 2024
30c7f8c
Add back the verification file
Pururun May 14, 2024
f586632
Remove event notifier
Rawa May 14, 2024
1b99268
Tidy up xml files
Pururun May 14, 2024
539b562
Use port instead of int in custom port dialog and cell
Pururun May 14, 2024
395baf7
Disable edit custom list action until all data is loaded
Pururun May 14, 2024
1ffee69
Fix detekt issues
Pururun May 14, 2024
667284d
Fix unit tests
Pururun May 14, 2024
c2c363f
Update verification file
Pururun May 14, 2024
cad5ccc
Remove old markTunAsStale
Rawa May 14, 2024
ccc6d1e
Make var a val
Rawa May 14, 2024
4f34ec8
Remove unnecessary dependency
Pururun May 15, 2024
569449e
Remove unused extensions
Rawa May 15, 2024
da86978
Fix some snackbar things
Pururun May 15, 2024
66b8d66
Improved stuff
Pururun May 15, 2024
eb283f7
Clarified some things
Pururun May 15, 2024
5ed262c
Deleted selected location repository
Pururun May 15, 2024
1b29b98
Cleaned up some code
Pururun May 15, 2024
5f1b24e
Improve code
Pururun May 15, 2024
04062cd
Fix map not null
Pururun May 15, 2024
2e760b0
Use port instead of int
Pururun May 15, 2024
de16acc
Added comment
Pururun May 15, 2024
28317ba
Fixing stuff
Pururun May 15, 2024
f3aa63b
Improve things
Pururun May 15, 2024
79327bf
Fix flow
Rawa May 15, 2024
891b7d7
Fix import
Rawa May 15, 2024
99a0759
Fix import
Rawa May 15, 2024
53c84d3
simply creation of fake deviceId
Rawa May 15, 2024
9455dea
use correct wwwauthtoken dummy format
Rawa May 15, 2024
9ba2fd2
Rename AppVersionInfoCache
Rawa May 15, 2024
340fa26
Fix various things
Pururun May 15, 2024
e2b7891
Simplify return statement
Rawa May 15, 2024
4facac1
Change to non nullable SharedFlow
Rawa May 15, 2024
e9b3a55
Fixed stuff
Pururun May 15, 2024
b5b27da
Woho
Pururun May 15, 2024
8271c88
Other fixes
Pururun May 15, 2024
3f96d6f
Fix expiry date comparision
Pururun May 15, 2024
2fd261d
Clean up mtu dialog
Rawa May 15, 2024
f8310a2
Fix import
Rawa May 15, 2024
7309261
More fixes
Rawa May 15, 2024
df439ac
Some fixes
Pururun May 15, 2024
9cef887
Add explicit clear mtu
Pururun May 15, 2024
725313b
Remove unnecessary library
Pururun May 15, 2024
2c69fbd
Some fixes
Pururun May 15, 2024
81a95b4
Simplify NewDeviceNotificationUseCase
Rawa May 16, 2024
32302d3
Fix return type
Rawa May 16, 2024
f901bc3
Some fixes
Pururun May 16, 2024
4d634e4
Clarify login
Rawa May 16, 2024
510b395
Revert "Some fixes"
Pururun May 16, 2024
dcf472a
Change clear to reset
Pururun May 16, 2024
e36bad0
Updated some names of unit tests
Pururun May 17, 2024
6da0f80
Fix error
Rawa May 17, 2024
6d5c371
Clean up vpn permission
Rawa May 17, 2024
e32975c
Rename fun
Rawa May 17, 2024
1d7a6d2
Optin debounce
Rawa May 17, 2024
802350a
Remove stuff
Pururun May 17, 2024
36ceb7c
Remove old jnix code
Rawa May 17, 2024
a6b5192
Minor clean up
Rawa May 17, 2024
8a96474
Seperate jnix from mullvadvpn.model
Rawa May 17, 2024
05a57d8
Clean up device
Rawa May 17, 2024
6cf54ce
Bake in ext fun
Rawa May 17, 2024
10bd8a1
Remove unnecessary trim
Rawa May 17, 2024
f6a5ca6
Remove some more types
Rawa May 17, 2024
555f172
Remove some more types
Rawa May 17, 2024
bf555ec
Minor clean up of talpid
Rawa May 17, 2024
b06468f
Improved vpn permission handling
Pururun May 17, 2024
5f8bd33
Fix bugs
Rawa May 17, 2024
e58912c
Added temporary progaurd rules
Pururun May 17, 2024
5bf17b7
Minor fix
Pururun May 19, 2024
634ba11
Fix rpc path
Pururun May 19, 2024
7bda289
Fix progaurd and other bugs
Pururun May 19, 2024
d8fa0ca
Fix EOF
Rawa May 20, 2024
656f54d
Fix manifest
Rawa May 20, 2024
b54cdb4
Refactor mappers
Rawa May 20, 2024
4a8c0b9
Remove nullable
Rawa May 20, 2024
c9557f6
Sort import
Rawa May 20, 2024
b193067
Dns state
Rawa May 20, 2024
513dad1
Remove stuff
Pururun May 20, 2024
a7c0f1f
Refactor constants
Rawa May 20, 2024
6d053e9
Revert no daemon debouce
Rawa May 20, 2024
080a9ba
Fix EOF
Rawa May 20, 2024
1e47e87
Clean up domain and fix edit name
Rawa May 20, 2024
a5c4822
Fixed some things
Pururun May 21, 2024
29d035b
Fix nit
Rawa May 21, 2024
71a71f9
Fixes
Rawa May 21, 2024
c3a0eae
Move model to lib.model
Rawa May 21, 2024
8b825cd
Fix formatting
Rawa May 21, 2024
3e1e8d5
Fix imports
Rawa May 21, 2024
9920999
Do stuff
Rawa May 22, 2024
314436e
Fix fix
Rawa May 22, 2024
934d7f0
remove dep and fix test
Rawa May 22, 2024
8f7c020
Add new string
Rawa May 22, 2024
82c075c
format xml
Rawa May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/workflows/android-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ jobs:
:app:testOssProdDebugUnitTest
:service:testOssProdDebugUnitTest
:lib:billing:testDebugUnitTest
:lib:daemon-grpc:testDebugUnitTest
:lib:shared:testDebugUnitTest
- gradle-task: :test:arch:test --rerun-tasks
- gradle-task: detekt
- gradle-task: lint
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ android {
"META-INF/LGPL2.1",
// Fixes packaging error caused by: jetified-junit-*
"META-INF/LICENSE.md",
"META-INF/LICENSE-notice.md"
"META-INF/LICENSE-notice.md",
"META-INF/io.netty.versions.properties",
"META-INF/INDEX.LIST"
)
}
}
Expand Down Expand Up @@ -305,18 +307,19 @@ afterEvaluate {
play { serviceAccountCredentials.set(file("play-api-key.json")) }

dependencies {
implementation(project(Dependencies.Mullvad.vpnService))
implementation(project(Dependencies.Mullvad.tileService))

implementation(project(Dependencies.Mullvad.commonLib))
implementation(project(Dependencies.Mullvad.daemonGrpc))
implementation(project(Dependencies.Mullvad.endpointLib))
implementation(project(Dependencies.Mullvad.ipcLib))
implementation(project(Dependencies.Mullvad.intentLib))
implementation(project(Dependencies.Mullvad.mapLib))
implementation(project(Dependencies.Mullvad.modelLib))
implementation(project(Dependencies.Mullvad.paymentLib))
implementation(project(Dependencies.Mullvad.resourceLib))
implementation(project(Dependencies.Mullvad.sharedLib))
implementation(project(Dependencies.Mullvad.talpidLib))
implementation(project(Dependencies.Mullvad.tileService))
implementation(project(Dependencies.Mullvad.themeLib))
implementation(project(Dependencies.Mullvad.paymentLib))
implementation(project(Dependencies.Mullvad.mapLib))
implementation(project(Dependencies.Mullvad.vpnService))

// Play implementation
playImplementation(project(Dependencies.Mullvad.billingLib))
Expand All @@ -342,6 +345,8 @@ dependencies {
implementation(Dependencies.Kotlin.stdlib)
implementation(Dependencies.KotlinX.coroutinesAndroid)

implementation(Dependencies.Arrow.core)

// UI tooling
implementation(Dependencies.Compose.uiToolingPreview)
debugImplementation(Dependencies.Compose.uiTooling)
Expand Down
15 changes: 2 additions & 13 deletions android/app/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.4" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.4)" variant="all" version="8.1.4">

<issue
id="MissingSuperCall"
message="Overriding method should call `super.onActivityResult`"
errorLine1=" override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {"
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt"
line="70"
column="18"/>
</issue>
<issues format="6" by="lint 8.3.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.3.0)" variant="all" version="8.3.0">

<issue
id="UseCheckPermission"
Expand All @@ -30,7 +19,7 @@
errorLine2=" ~~~~~">
<location
file="src/main/AndroidManifest.xml"
line="25"
line="23"
column="39"/>
</issue>

Expand Down
12 changes: 12 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@
-dontwarn org.joda.time.**
-keep class org.joda.time.** { *; }
-keep interface org.joda.time.** { *; }

# grpc
-keep class io.grpc.okhttp.OkHttpChannelBuilder { *; }
-keep class mullvad_daemon.management_interface.** { *; }
-keep class com.google.protobuf.Timestamp { *; }
-dontwarn com.google.j2objc.annotations.ReflectionSupport
-dontwarn com.google.j2objc.annotations.RetainedWith
-dontwarn com.squareup.okhttp.CipherSuite
-dontwarn com.squareup.okhttp.ConnectionSpec
-dontwarn com.squareup.okhttp.TlsVersion


Original file line number Diff line number Diff line change
@@ -1,61 +1,108 @@
package net.mullvad.mullvadvpn.compose.data

import net.mullvad.mullvadvpn.model.CustomListName
import net.mullvad.mullvadvpn.model.PortRange
import net.mullvad.mullvadvpn.model.RelayEndpointData
import net.mullvad.mullvadvpn.model.RelayList
import net.mullvad.mullvadvpn.model.RelayListCity
import net.mullvad.mullvadvpn.model.RelayListCountry
import net.mullvad.mullvadvpn.model.WireguardEndpointData
import net.mullvad.mullvadvpn.model.WireguardRelayEndpointData
import net.mullvad.mullvadvpn.relaylist.RelayItem
import net.mullvad.mullvadvpn.relaylist.toRelayCountries
import net.mullvad.mullvadvpn.lib.model.CustomList
import net.mullvad.mullvadvpn.lib.model.CustomListId
import net.mullvad.mullvadvpn.lib.model.CustomListName
import net.mullvad.mullvadvpn.lib.model.GeoLocationId
import net.mullvad.mullvadvpn.lib.model.Ownership
import net.mullvad.mullvadvpn.lib.model.PortRange
import net.mullvad.mullvadvpn.lib.model.Provider
import net.mullvad.mullvadvpn.lib.model.ProviderId
import net.mullvad.mullvadvpn.lib.model.RelayItem
import net.mullvad.mullvadvpn.lib.model.RelayList
import net.mullvad.mullvadvpn.lib.model.WireguardEndpointData

private val DUMMY_RELAY_1 =
net.mullvad.mullvadvpn.model.Relay(
hostname = "Relay host 1",
RelayItem.Location.Relay(
id =
GeoLocationId.Hostname(
city = GeoLocationId.City(GeoLocationId.Country("RCo1"), "Relay City 1"),
"Relay host 1"
),
active = true,
endpointData = RelayEndpointData.Wireguard(WireguardRelayEndpointData),
owned = true,
provider = "PROVIDER"
provider =
Provider(
providerId = ProviderId("PROVIDER RENTED"),
ownership = Ownership.Rented,
)
)
private val DUMMY_RELAY_2 =
net.mullvad.mullvadvpn.model.Relay(
hostname = "Relay host 2",
RelayItem.Location.Relay(
id =
GeoLocationId.Hostname(
city = GeoLocationId.City(GeoLocationId.Country("RCo2"), "Relay City 2"),
"Relay host 2"
),
active = true,
endpointData = RelayEndpointData.Wireguard(WireguardRelayEndpointData),
owned = true,
provider = "PROVIDER"
provider =
Provider(providerId = ProviderId("PROVIDER OWNED"), ownership = Ownership.MullvadOwned)
)
private val DUMMY_RELAY_CITY_1 =
RelayItem.Location.City(
name = "Relay City 1",
id = GeoLocationId.City(countryCode = GeoLocationId.Country("RCo1"), cityCode = "RCi1"),
relays = listOf(DUMMY_RELAY_1),
expanded = false
)
private val DUMMY_RELAY_CITY_2 =
RelayItem.Location.City(
name = "Relay City 2",
id = GeoLocationId.City(countryCode = GeoLocationId.Country("RCo2"), cityCode = "RCi2"),
relays = listOf(DUMMY_RELAY_2),
expanded = false
)
private val DUMMY_RELAY_CITY_1 = RelayListCity("Relay City 1", "RCi1", arrayListOf(DUMMY_RELAY_1))
private val DUMMY_RELAY_CITY_2 = RelayListCity("Relay City 2", "RCi2", arrayListOf(DUMMY_RELAY_2))
private val DUMMY_RELAY_COUNTRY_1 =
RelayListCountry("Relay Country 1", "RCo1", arrayListOf(DUMMY_RELAY_CITY_1))
RelayItem.Location.Country(
name = "Relay Country 1",
id = GeoLocationId.Country("RCo1"),
expanded = false,
cities = listOf(DUMMY_RELAY_CITY_1)
)
private val DUMMY_RELAY_COUNTRY_2 =
RelayListCountry("Relay Country 2", "RCo2", arrayListOf(DUMMY_RELAY_CITY_2))
RelayItem.Location.Country(
name = "Relay Country 2",
id = GeoLocationId.Country("RCo2"),
expanded = false,
cities = listOf(DUMMY_RELAY_CITY_2)
)

private val DUMMY_WIREGUARD_PORT_RANGES = ArrayList<PortRange>()
private val DUMMY_WIREGUARD_ENDPOINT_DATA = WireguardEndpointData(DUMMY_WIREGUARD_PORT_RANGES)

val DUMMY_RELAY_COUNTRIES =
val DUMMY_RELAY_COUNTRIES = listOf(DUMMY_RELAY_COUNTRY_1, DUMMY_RELAY_COUNTRY_2)

val DUMMY_RELAY_LIST =
RelayList(
arrayListOf(DUMMY_RELAY_COUNTRY_1, DUMMY_RELAY_COUNTRY_2),
DUMMY_WIREGUARD_ENDPOINT_DATA,
)
.toRelayCountries()
DUMMY_RELAY_COUNTRIES,
DUMMY_WIREGUARD_ENDPOINT_DATA,
)

val DUMMY_CUSTOM_LISTS =
val DUMMY_RELAY_ITEM_CUSTOM_LISTS =
listOf(
RelayItem.CustomList(
CustomListName.fromString("First list"),
false,
"1",
customListName = CustomListName.fromString("First list"),
expanded = false,
id = CustomListId("1"),
locations = DUMMY_RELAY_COUNTRIES
),
RelayItem.CustomList(
CustomListName.fromString("Empty list"),
customListName = CustomListName.fromString("Empty list"),
expanded = false,
"2",
id = CustomListId("2"),
locations = emptyList()
)
)

val DUMMY_CUSTOM_LISTS =
listOf(
CustomList(
name = CustomListName.fromString("First list"),
id = CustomListId("1"),
locations = DUMMY_RELAY_COUNTRIES.map { it.id }
),
CustomList(
name = CustomListName.fromString("Empty list"),
id = CustomListId("2"),
locations = emptyList()
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension
import net.mullvad.mullvadvpn.compose.setContentWithTheme
import net.mullvad.mullvadvpn.compose.state.CreateCustomListUiState
import net.mullvad.mullvadvpn.compose.test.CREATE_CUSTOM_LIST_DIALOG_INPUT_TEST_TAG
import net.mullvad.mullvadvpn.model.CustomListsError
import net.mullvad.mullvadvpn.lib.model.CreateCustomListError
import net.mullvad.mullvadvpn.usecase.customlists.CreateCustomListWithLocationsError
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.RegisterExtension
Expand Down Expand Up @@ -44,7 +45,13 @@ class CreateCustomListDialogTest {
fun givenCustomListExistsShouldShowCustomListExitsErrorText() =
composeExtension.use {
// Arrange
val state = CreateCustomListUiState(error = CustomListsError.CustomListExists)
val state =
CreateCustomListUiState(
error =
CreateCustomListWithLocationsError.Create(
CreateCustomListError.CustomListAlreadyExists
)
)
setContentWithTheme { CreateCustomListDialog(state = state) }

// Assert
Expand All @@ -56,7 +63,13 @@ class CreateCustomListDialogTest {
fun givenOtherCustomListErrorShouldShowAnErrorOccurredErrorText() =
composeExtension.use {
// Arrange
val state = CreateCustomListUiState(error = CustomListsError.OtherError)
val state =
CreateCustomListUiState(
error =
CreateCustomListWithLocationsError.Create(
CreateCustomListError.Unknown(Throwable())
)
)
setContentWithTheme { CreateCustomListDialog(state = state) }

// Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import io.mockk.MockKAnnotations
import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension
import net.mullvad.mullvadvpn.compose.setContentWithTheme
import net.mullvad.mullvadvpn.compose.test.CUSTOM_PORT_DIALOG_INPUT_TEST_TAG
import net.mullvad.mullvadvpn.model.PortRange
import net.mullvad.mullvadvpn.lib.model.Port
import net.mullvad.mullvadvpn.lib.model.PortRange
import net.mullvad.mullvadvpn.onNodeWithTagAndText
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
Expand All @@ -29,9 +30,9 @@ class CustomPortDialogTest {
@SuppressLint("ComposableNaming")
@Composable
private fun testWireguardCustomPortDialog(
initialPort: Int? = null,
initialPort: Port? = null,
allowedPortRanges: List<PortRange> = emptyList(),
onSave: (Int?) -> Unit = { _ -> },
onSave: (Port?) -> Unit = { _ -> },
onDismiss: () -> Unit = {},
) {

Expand All @@ -47,21 +48,20 @@ class CustomPortDialogTest {
fun testShowWireguardCustomPortDialogInvalidInt() =
composeExtension.use {
// Input a number to make sure that a too long number does not show and it does not
// crash
// the app
// crash the app

// Arrange
setContentWithTheme { testWireguardCustomPortDialog() }

// Act
onNodeWithTag(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG).performTextInput(invalidCustomPort)
onNodeWithTag(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG).performTextInput(INVALID_CUSTOM_PORT)

// Assert
onNodeWithTagAndText(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG, invalidCustomPort)
onNodeWithTagAndText(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG, INVALID_CUSTOM_PORT)
.assertDoesNotExist()
}

companion object {
const val invalidCustomPort = "21474836471"
const val INVALID_CUSTOM_PORT = "21474836471"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import io.mockk.mockk
import io.mockk.verify
import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension
import net.mullvad.mullvadvpn.compose.setContentWithTheme
import net.mullvad.mullvadvpn.compose.state.DeleteCustomListUiState
import net.mullvad.mullvadvpn.lib.model.CustomListName
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.RegisterExtension
Expand All @@ -27,8 +29,13 @@ class DeleteCustomListConfirmationDialogTest {
fun givenNameShouldShowDeleteNameTitle() =
composeExtension.use {
// Arrange
val name = "List should be deleted"
setContentWithTheme { DeleteCustomListConfirmationDialog(name = name) }
val name = CustomListName.fromString("List should be deleted")
setContentWithTheme {
DeleteCustomListConfirmationDialog(
name = name,
state = DeleteCustomListUiState(null)
)
}

// Assert
onNodeWithText(DELETE_TITLE.format(name)).assertExists()
Expand All @@ -38,10 +45,14 @@ class DeleteCustomListConfirmationDialogTest {
fun whenDeleteIsClickedShouldCallOnDelete() =
composeExtension.use {
// Arrange
val name = "List should be deleted"
val name = CustomListName.fromString("List should be deleted")
val mockedOnDelete: () -> Unit = mockk(relaxed = true)
setContentWithTheme {
DeleteCustomListConfirmationDialog(name = name, onDelete = mockedOnDelete)
DeleteCustomListConfirmationDialog(
name = name,
state = DeleteCustomListUiState(null),
onDelete = mockedOnDelete
)
}

// Act
Expand All @@ -55,10 +66,14 @@ class DeleteCustomListConfirmationDialogTest {
fun whenCancelIsClickedShouldCallOnBack() =
composeExtension.use {
// Arrange
val name = "List should be deleted"
val name = CustomListName.fromString("List should be deleted")
val mockedOnBack: () -> Unit = mockk(relaxed = true)
setContentWithTheme {
DeleteCustomListConfirmationDialog(name = name, onBack = mockedOnBack)
DeleteCustomListConfirmationDialog(
name = name,
state = DeleteCustomListUiState(null),
onBack = mockedOnBack
)
}

// Act
Expand Down
Loading
Loading