Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/java/com/example/vpn/RootTunnelManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class RootTunnelManager(private val context: Context) {
Result.success(Unit)
}

private suspend fun teardownInterface() {
private suspend fun teardownInterface() = withContext(Dispatchers.IO) {
RootRunner.execute(
// 1. Remove isolated iptables rules without flushing system tables
"iptables -t nat -D OUTPUT -j AWG_OUTPUT || true",
Expand Down
17 changes: 12 additions & 5 deletions app/src/test/java/com/example/vpn/RootTunnelManagerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.example.vpn
import android.content.Context
import androidx.test.core.app.ApplicationProvider
import com.example.domain.model.VpnState
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -33,11 +33,18 @@ class RootTunnelManagerTest {
}

@Test
fun testRootModePreferenceToggle() {
fun testIsRootModeEnabledPreference() {
assertFalse(rootTunnelManager.isRootModeEnabled)
rootTunnelManager.isRootModeEnabled = true
assertTrue(rootTunnelManager.isRootModeEnabled)
rootTunnelManager.isRootModeEnabled = false
assertFalse(rootTunnelManager.isRootModeEnabled)
assertEquals(true, rootTunnelManager.isRootModeEnabled)
}

@Test
fun testDisconnectUpdatesStatusToDisconnected() = runBlocking {
val result = rootTunnelManager.disconnect()
assertEquals(true, result.isSuccess)
val status = rootTunnelManager.status.value
assertEquals(VpnState.DISCONNECTED, status.state)
assertFalse(status.isRootTunnel)
}
}
Loading