mirror of
https://github.com/bitwarden/android.git
synced 2025-03-15 18:58:59 +03:00
Apply formatter to entire repo (#329)
This commit is contained in:
parent
c72053f935
commit
43793d6d41
11 changed files with 112 additions and 108 deletions
|
@ -1,10 +1,10 @@
|
|||
package com.x8bit.bitwarden.data.vault.datasource.network.di
|
||||
|
||||
import com.x8bit.bitwarden.data.vault.datasource.network.service.SyncService
|
||||
import com.x8bit.bitwarden.data.vault.datasource.network.service.SyncServiceImpl
|
||||
import com.x8bit.bitwarden.data.platform.datasource.network.retrofit.Retrofits
|
||||
import com.x8bit.bitwarden.data.vault.datasource.network.service.CiphersService
|
||||
import com.x8bit.bitwarden.data.vault.datasource.network.service.CiphersServiceImpl
|
||||
import com.x8bit.bitwarden.data.vault.datasource.network.service.SyncService
|
||||
import com.x8bit.bitwarden.data.vault.datasource.network.service.SyncServiceImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
|
|
|
@ -8,12 +8,12 @@ import androidx.navigation.navOptions
|
|||
import androidx.navigation.navigation
|
||||
import com.x8bit.bitwarden.ui.auth.feature.createaccount.createAccountDestinations
|
||||
import com.x8bit.bitwarden.ui.auth.feature.createaccount.navigateToCreateAccount
|
||||
import com.x8bit.bitwarden.ui.auth.feature.environment.environmentDestination
|
||||
import com.x8bit.bitwarden.ui.auth.feature.environment.navigateToEnvironment
|
||||
import com.x8bit.bitwarden.ui.auth.feature.landing.LANDING_ROUTE
|
||||
import com.x8bit.bitwarden.ui.auth.feature.landing.landingDestinations
|
||||
import com.x8bit.bitwarden.ui.auth.feature.login.loginDestinations
|
||||
import com.x8bit.bitwarden.ui.auth.feature.login.navigateToLogin
|
||||
import com.x8bit.bitwarden.ui.auth.feature.environment.navigateToEnvironment
|
||||
import com.x8bit.bitwarden.ui.auth.feature.environment.environmentDestination
|
||||
|
||||
const val AUTH_GRAPH_ROUTE: String = "auth_graph"
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.Text
|
||||
|
||||
/**
|
||||
* Displays a dialog with a title and "Cancel" button.
|
||||
|
|
|
@ -31,9 +31,9 @@ import com.x8bit.bitwarden.R
|
|||
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.Text
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenLogoutConfirmationDialog
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenExternalLinkRow
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenListHeaderText
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenLogoutConfirmationDialog
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenScaffold
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenSelectionDialog
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenSelectionRow
|
||||
|
|
|
@ -64,6 +64,7 @@ class GeneratorViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
override fun handleAction(action: GeneratorAction) {
|
||||
when (action) {
|
||||
is GeneratorAction.RegenerateClick -> {
|
||||
|
@ -102,8 +103,7 @@ class GeneratorViewModel @Inject constructor(
|
|||
handleUsernameTypeOptionSelect(action)
|
||||
}
|
||||
|
||||
is GeneratorAction.MainType.Username.UsernameType.PlusAddressedEmail.EmailTextChange ->
|
||||
{
|
||||
is GeneratorAction.MainType.Username.UsernameType.PlusAddressedEmail.EmailTextChange -> {
|
||||
handlePlusAddressedEmailTextInputChange(action)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import com.x8bit.bitwarden.R
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.x8bit.bitwarden.data.tools.generator.datasource.disk
|
||||
|
||||
import com.x8bit.bitwarden.data.tools.generator.repository.model.PasscodeGenerationOptions
|
||||
import com.x8bit.bitwarden.data.platform.base.FakeSharedPreferences
|
||||
import com.x8bit.bitwarden.data.tools.generator.repository.model.PasscodeGenerationOptions
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
|
|
@ -176,18 +176,18 @@ class GeneratorRepositoryTest {
|
|||
coVerify(exactly = 0) { generatorDiskSource.getPasscodeGenerationOptions(any()) }
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `getPasscodeGenerationOptions should return null when no data is stored for active user`() = runTest {
|
||||
val userId = "activeUserId"
|
||||
coEvery { authDiskSource.userState } returns USER_STATE
|
||||
coEvery { generatorDiskSource.getPasscodeGenerationOptions(userId) } returns null
|
||||
fun `getPasscodeGenerationOptions should return null when no data is stored for active user`() =
|
||||
runTest {
|
||||
val userId = "activeUserId"
|
||||
coEvery { authDiskSource.userState } returns USER_STATE
|
||||
coEvery { generatorDiskSource.getPasscodeGenerationOptions(userId) } returns null
|
||||
|
||||
val result = repository.getPasscodeGenerationOptions()
|
||||
val result = repository.getPasscodeGenerationOptions()
|
||||
|
||||
assertNull(result)
|
||||
coVerify { generatorDiskSource.getPasscodeGenerationOptions(userId) }
|
||||
}
|
||||
assertNull(result)
|
||||
coVerify { generatorDiskSource.getPasscodeGenerationOptions(userId) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `savePasscodeGenerationOptions should store options correctly`() = runTest {
|
||||
|
@ -220,32 +220,34 @@ class GeneratorRepositoryTest {
|
|||
coVerify { generatorDiskSource.storePasscodeGenerationOptions(userId, optionsToSave) }
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `savePasscodeGenerationOptions should not store options when there is no active user`() = runTest {
|
||||
val optionsToSave = PasscodeGenerationOptions(
|
||||
length = 14,
|
||||
allowAmbiguousChar = false,
|
||||
hasNumbers = true,
|
||||
minNumber = 0,
|
||||
hasUppercase = true,
|
||||
minUppercase = null,
|
||||
hasLowercase = false,
|
||||
minLowercase = null,
|
||||
allowSpecial = false,
|
||||
minSpecial = 1,
|
||||
allowCapitalize = false,
|
||||
allowIncludeNumber = false,
|
||||
wordSeparator = "-",
|
||||
numWords = 3,
|
||||
)
|
||||
fun `savePasscodeGenerationOptions should not store options when there is no active user`() =
|
||||
runTest {
|
||||
val optionsToSave = PasscodeGenerationOptions(
|
||||
length = 14,
|
||||
allowAmbiguousChar = false,
|
||||
hasNumbers = true,
|
||||
minNumber = 0,
|
||||
hasUppercase = true,
|
||||
minUppercase = null,
|
||||
hasLowercase = false,
|
||||
minLowercase = null,
|
||||
allowSpecial = false,
|
||||
minSpecial = 1,
|
||||
allowCapitalize = false,
|
||||
allowIncludeNumber = false,
|
||||
wordSeparator = "-",
|
||||
numWords = 3,
|
||||
)
|
||||
|
||||
coEvery { authDiskSource.userState } returns null
|
||||
coEvery { authDiskSource.userState } returns null
|
||||
|
||||
repository.savePasscodeGenerationOptions(optionsToSave)
|
||||
repository.savePasscodeGenerationOptions(optionsToSave)
|
||||
|
||||
coVerify(exactly = 0) { generatorDiskSource.storePasscodeGenerationOptions(any(), any()) }
|
||||
}
|
||||
coVerify(exactly = 0) {
|
||||
generatorDiskSource.storePasscodeGenerationOptions(any(), any())
|
||||
}
|
||||
}
|
||||
|
||||
private val USER_STATE = UserStateJson(
|
||||
activeUserId = "activeUserId",
|
||||
|
|
|
@ -1430,57 +1430,59 @@ class VaultRepositoryTest {
|
|||
|
||||
@Test
|
||||
@Suppress("MaxLineLength")
|
||||
fun `createCipher with ciphersService createCipher failure should return CreateCipherResult failure`() = runTest {
|
||||
val mockCipherView = createMockCipherView(number = 1)
|
||||
coEvery {
|
||||
vaultSdkSource.encryptCipher(cipherView = mockCipherView)
|
||||
} returns createMockSdkCipher(number = 1).asSuccess()
|
||||
coEvery {
|
||||
ciphersService.createCipher(
|
||||
body = createMockCipherJsonRequest(number = 1),
|
||||
fun `createCipher with ciphersService createCipher failure should return CreateCipherResult failure`() =
|
||||
runTest {
|
||||
val mockCipherView = createMockCipherView(number = 1)
|
||||
coEvery {
|
||||
vaultSdkSource.encryptCipher(cipherView = mockCipherView)
|
||||
} returns createMockSdkCipher(number = 1).asSuccess()
|
||||
coEvery {
|
||||
ciphersService.createCipher(
|
||||
body = createMockCipherJsonRequest(number = 1),
|
||||
)
|
||||
} returns IllegalStateException().asFailure()
|
||||
|
||||
val result = vaultRepository.createCipher(cipherView = mockCipherView)
|
||||
|
||||
assertEquals(
|
||||
CreateCipherResult.Error,
|
||||
result,
|
||||
)
|
||||
} returns IllegalStateException().asFailure()
|
||||
|
||||
val result = vaultRepository.createCipher(cipherView = mockCipherView)
|
||||
|
||||
assertEquals(
|
||||
CreateCipherResult.Error,
|
||||
result,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Suppress("MaxLineLength")
|
||||
fun `createCipher with ciphersService createCipher success should return CreateCipherResult success`() = runTest {
|
||||
val mockCipherView = createMockCipherView(number = 1)
|
||||
coEvery {
|
||||
vaultSdkSource.encryptCipher(cipherView = mockCipherView)
|
||||
} returns createMockSdkCipher(number = 1).asSuccess()
|
||||
coEvery {
|
||||
ciphersService.createCipher(
|
||||
body = createMockCipherJsonRequest(number = 1),
|
||||
fun `createCipher with ciphersService createCipher success should return CreateCipherResult success`() =
|
||||
runTest {
|
||||
val mockCipherView = createMockCipherView(number = 1)
|
||||
coEvery {
|
||||
vaultSdkSource.encryptCipher(cipherView = mockCipherView)
|
||||
} returns createMockSdkCipher(number = 1).asSuccess()
|
||||
coEvery {
|
||||
ciphersService.createCipher(
|
||||
body = createMockCipherJsonRequest(number = 1),
|
||||
)
|
||||
} returns createMockCipher(number = 1).asSuccess()
|
||||
coEvery {
|
||||
syncService.sync()
|
||||
} returns Result.success(createMockSyncResponse(1))
|
||||
coEvery {
|
||||
vaultSdkSource.decryptCipherList(listOf(createMockSdkCipher(1)))
|
||||
} returns listOf(createMockCipherView(1)).asSuccess()
|
||||
coEvery {
|
||||
vaultSdkSource.decryptFolderList(listOf(createMockSdkFolder(1)))
|
||||
} returns listOf(createMockFolderView(1)).asSuccess()
|
||||
coEvery {
|
||||
vaultSdkSource.decryptSendList(listOf(createMockSdkSend(1)))
|
||||
} returns listOf(createMockSendView(1)).asSuccess()
|
||||
|
||||
val result = vaultRepository.createCipher(cipherView = mockCipherView)
|
||||
|
||||
assertEquals(
|
||||
CreateCipherResult.Success,
|
||||
result,
|
||||
)
|
||||
} returns createMockCipher(number = 1).asSuccess()
|
||||
coEvery {
|
||||
syncService.sync()
|
||||
} returns Result.success(createMockSyncResponse(1))
|
||||
coEvery {
|
||||
vaultSdkSource.decryptCipherList(listOf(createMockSdkCipher(1)))
|
||||
} returns listOf(createMockCipherView(1)).asSuccess()
|
||||
coEvery {
|
||||
vaultSdkSource.decryptFolderList(listOf(createMockSdkFolder(1)))
|
||||
} returns listOf(createMockFolderView(1)).asSuccess()
|
||||
coEvery {
|
||||
vaultSdkSource.decryptSendList(listOf(createMockSdkSend(1)))
|
||||
} returns listOf(createMockSendView(1)).asSuccess()
|
||||
|
||||
val result = vaultRepository.createCipher(cipherView = mockCipherView)
|
||||
|
||||
assertEquals(
|
||||
CreateCipherResult.Success,
|
||||
result,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
//region Helper functions
|
||||
|
||||
|
|
|
@ -911,30 +911,30 @@ class GeneratorViewModelTest : BaseViewModelTest() {
|
|||
assertEquals(expectedState, viewModel.stateFlow.value)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `ToggleIncludeNumberChange should update the includeNumber property correctly`() = runTest {
|
||||
viewModel.actionChannel.trySend(
|
||||
GeneratorAction
|
||||
.MainType
|
||||
.Username
|
||||
.UsernameType
|
||||
.RandomWord
|
||||
.ToggleIncludeNumberChange(
|
||||
includeNumber = true,
|
||||
),
|
||||
)
|
||||
fun `ToggleIncludeNumberChange should update the includeNumber property correctly`() =
|
||||
runTest {
|
||||
viewModel.actionChannel.trySend(
|
||||
GeneratorAction
|
||||
.MainType
|
||||
.Username
|
||||
.UsernameType
|
||||
.RandomWord
|
||||
.ToggleIncludeNumberChange(
|
||||
includeNumber = true,
|
||||
),
|
||||
)
|
||||
|
||||
val expectedState = defaultRandomWordState.copy(
|
||||
selectedType = GeneratorState.MainType.Username(
|
||||
GeneratorState.MainType.Username.UsernameType.RandomWord(
|
||||
includeNumber = true,
|
||||
val expectedState = defaultRandomWordState.copy(
|
||||
selectedType = GeneratorState.MainType.Username(
|
||||
GeneratorState.MainType.Username.UsernameType.RandomWord(
|
||||
includeNumber = true,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
assertEquals(expectedState, viewModel.stateFlow.value)
|
||||
}
|
||||
assertEquals(expectedState, viewModel.stateFlow.value)
|
||||
}
|
||||
}
|
||||
//region Helper Functions
|
||||
|
||||
|
|
|
@ -99,7 +99,8 @@ class NewSendViewModelTest : BaseViewModelTest() {
|
|||
input = "input",
|
||||
isHideByDefaultChecked = false,
|
||||
),
|
||||
), awaitItem(),
|
||||
),
|
||||
awaitItem(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue