mirror of
https://github.com/bitwarden/android.git
synced 2025-12-10 09:56:45 -06:00
[PM-26094] Update Credential Manager library and remove stubs (#5947)
This commit is contained in:
parent
2363b0d619
commit
5c5bd25d16
@ -120,12 +120,12 @@ class ImportItemsViewModel @Inject constructor(
|
|||||||
sendEvent(
|
sendEvent(
|
||||||
ImportItemsEvent.ShowRegisteredImportSources(
|
ImportItemsEvent.ShowRegisteredImportSources(
|
||||||
credentialTypes = listOf(
|
credentialTypes = listOf(
|
||||||
CredentialTypes.BASIC_AUTH,
|
CredentialTypes.CREDENTIAL_TYPE_BASIC_AUTH,
|
||||||
CredentialTypes.PUBLIC_KEY,
|
CredentialTypes.CREDENTIAL_TYPE_PUBLIC_KEY,
|
||||||
CredentialTypes.TOTP,
|
CredentialTypes.CREDENTIAL_TYPE_TOTP,
|
||||||
CredentialTypes.CREDIT_CARD,
|
CredentialTypes.CREDENTIAL_TYPE_CREDIT_CARD,
|
||||||
CredentialTypes.SSH_KEY,
|
CredentialTypes.CREDENTIAL_TYPE_SSH_KEY,
|
||||||
CredentialTypes.ADDRESS,
|
CredentialTypes.CREDENTIAL_TYPE_ADDRESS,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -61,12 +61,12 @@ class ImportItemsViewModelTest : BaseViewModelTest() {
|
|||||||
assertEquals(
|
assertEquals(
|
||||||
ImportItemsEvent.ShowRegisteredImportSources(
|
ImportItemsEvent.ShowRegisteredImportSources(
|
||||||
listOf(
|
listOf(
|
||||||
CredentialTypes.BASIC_AUTH,
|
CredentialTypes.CREDENTIAL_TYPE_BASIC_AUTH,
|
||||||
CredentialTypes.PUBLIC_KEY,
|
CredentialTypes.CREDENTIAL_TYPE_PUBLIC_KEY,
|
||||||
CredentialTypes.TOTP,
|
CredentialTypes.CREDENTIAL_TYPE_TOTP,
|
||||||
CredentialTypes.CREDIT_CARD,
|
CredentialTypes.CREDENTIAL_TYPE_CREDIT_CARD,
|
||||||
CredentialTypes.SSH_KEY,
|
CredentialTypes.CREDENTIAL_TYPE_SSH_KEY,
|
||||||
CredentialTypes.ADDRESS,
|
CredentialTypes.CREDENTIAL_TYPE_ADDRESS,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
awaitItem(),
|
awaitItem(),
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
package androidx.credentials.providerevents
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
|
||||||
import androidx.credentials.providerevents.exception.ImportCredentialsException
|
|
||||||
import androidx.credentials.providerevents.transfer.ImportCredentialsResponse
|
|
||||||
import androidx.credentials.providerevents.transfer.ProviderImportCredentialsRequest
|
|
||||||
import com.bitwarden.annotation.OmitFromCoverage
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A stub implementation of the Credential Provider Events IntentHandler class.
|
|
||||||
*/
|
|
||||||
@OmitFromCoverage
|
|
||||||
object IntentHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stub implementation of the setImportCredentialsException method.
|
|
||||||
*/
|
|
||||||
fun setImportCredentialsException(intent: Intent, exception: ImportCredentialsException) {
|
|
||||||
// Stub implementation
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stub implementation of the setImportCredentialsResponse method.
|
|
||||||
*/
|
|
||||||
fun setImportCredentialsResponse(
|
|
||||||
context: Activity,
|
|
||||||
uri: Uri,
|
|
||||||
response: ImportCredentialsResponse,
|
|
||||||
) {
|
|
||||||
// Stub implementation
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stub implementation of the retrieveImportCredentialsException method.
|
|
||||||
*/
|
|
||||||
@Suppress("FunctionOnlyReturningConstant")
|
|
||||||
fun retrieveProviderImportCredentialsRequest(
|
|
||||||
intent: Intent,
|
|
||||||
): ProviderImportCredentialsRequest? {
|
|
||||||
// Stub implementation
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,111 +0,0 @@
|
|||||||
package androidx.credentials.providerevents
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.pm.SigningInfo
|
|
||||||
import androidx.credentials.provider.CallingAppInfo
|
|
||||||
import androidx.credentials.providerevents.transfer.ImportCredentialsRequest
|
|
||||||
import androidx.credentials.providerevents.transfer.ImportCredentialsResponse
|
|
||||||
import androidx.credentials.providerevents.transfer.ProviderImportCredentialsResponse
|
|
||||||
import androidx.credentials.providerevents.transfer.RegisterExportRequest
|
|
||||||
import androidx.credentials.providerevents.transfer.RegisterExportResponse
|
|
||||||
import com.bitwarden.annotation.OmitFromCoverage
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Placeholder interface representing a provider events manager.
|
|
||||||
*/
|
|
||||||
interface ProviderEventsManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register as a credential export source.
|
|
||||||
*/
|
|
||||||
fun registerExport(request: RegisterExportRequest): RegisterExportResponse
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Begin the process of importing credentials.
|
|
||||||
*/
|
|
||||||
fun importCredentials(
|
|
||||||
context: Context,
|
|
||||||
request: ImportCredentialsRequest,
|
|
||||||
): ProviderImportCredentialsResponse
|
|
||||||
|
|
||||||
@OmitFromCoverage
|
|
||||||
@Suppress("UndocumentedPublicClass")
|
|
||||||
companion object {
|
|
||||||
/**
|
|
||||||
* Create a new instance of [ProviderEventsManager].
|
|
||||||
*/
|
|
||||||
fun create(context: Context): ProviderEventsManager = StubProviderEventsManager()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stub implementation of [ProviderEventsManager].
|
|
||||||
*/
|
|
||||||
@OmitFromCoverage
|
|
||||||
internal class StubProviderEventsManager : ProviderEventsManager {
|
|
||||||
override fun registerExport(request: RegisterExportRequest): RegisterExportResponse {
|
|
||||||
return RegisterExportResponse()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun importCredentials(
|
|
||||||
context: Context,
|
|
||||||
request: ImportCredentialsRequest,
|
|
||||||
): ProviderImportCredentialsResponse {
|
|
||||||
@SuppressLint("VisibleForTests")
|
|
||||||
return ProviderImportCredentialsResponse(
|
|
||||||
response = ImportCredentialsResponse(
|
|
||||||
responseJson = CANNED_RESPONSE,
|
|
||||||
),
|
|
||||||
callingAppInfo = CallingAppInfo(
|
|
||||||
packageName = context.packageName,
|
|
||||||
signingInfo = SigningInfo(),
|
|
||||||
origin = null,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val CANNED_RESPONSE = """
|
|
||||||
{
|
|
||||||
"id": "3zGV3pmoSs6mT7IEAPXfOw",
|
|
||||||
"username": "",
|
|
||||||
"email": "user@email.com",
|
|
||||||
"fullName": "Test User",
|
|
||||||
"collections": [],
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"id": "8cCs0RV_ViySk7KCACA",
|
|
||||||
"creationAt": 1739325421,
|
|
||||||
"modifiedAt": 1739325421,
|
|
||||||
"title": "test import credentials",
|
|
||||||
"favorite": false,
|
|
||||||
"scope": {
|
|
||||||
"urls": [
|
|
||||||
"https://www.sample-url.io/"
|
|
||||||
],
|
|
||||||
"androidApps": []
|
|
||||||
},
|
|
||||||
"credentials": [
|
|
||||||
{
|
|
||||||
"type": "basic-auth",
|
|
||||||
"username": {
|
|
||||||
"fieldType": "string",
|
|
||||||
"value": "MyUsername"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "passkey",
|
|
||||||
"credentialId": "xMA-5emp0WsQASnuNmuzQA",
|
|
||||||
"rpId": "www.sample-url.io",
|
|
||||||
"username": "user@email.com",
|
|
||||||
"userDisplayName": "user@email.com",
|
|
||||||
"userHandle": "lEn2KqNnS7SsUdVbrdoFiw",
|
|
||||||
"key": "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgQx8Smx_KdvQ7nJXt2_62Xrn-im9ibCOtsphj_xZo_uWhRANCAARUDaIFJIUaRyUehAy_d1_a-DK63Ws_d-zkYj-uqHdrGZI0dnhazQGva4tJZQFN35iLoLzFFj_CSjqeYAEOX7Ck"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
.trimIndent()
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
package androidx.credentials.providerevents.exception
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Placeholder class representing a cancellation exception for importing credentials.
|
|
||||||
*/
|
|
||||||
class ImportCredentialsCancellationException : Exception()
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
package androidx.credentials.providerevents.transfer
|
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Placeholder class representing an entry in the export request.
|
|
||||||
*/
|
|
||||||
data class ExportEntry(
|
|
||||||
val id: String,
|
|
||||||
val accountDisplayName: CharSequence?,
|
|
||||||
val userDisplayName: CharSequence,
|
|
||||||
val icon: Bitmap,
|
|
||||||
val supportedCredentialTypes: Set<String>,
|
|
||||||
)
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
package androidx.credentials.providerevents.transfer
|
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import androidx.credentials.provider.CallingAppInfo
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Placeholder class for the request received by the provider after the query phase of the import
|
|
||||||
* flow is complete i.e. the user was presented with a list of entries, and the user has now made
|
|
||||||
* a selection from the list of [ExportEntry] presented on the selector UI.
|
|
||||||
*/
|
|
||||||
data class ProviderImportCredentialsRequest(
|
|
||||||
val request: ImportCredentialsRequest,
|
|
||||||
val callingAppInfo: CallingAppInfo,
|
|
||||||
val uri: Uri,
|
|
||||||
val credId: String,
|
|
||||||
)
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
package androidx.credentials.providerevents.transfer
|
|
||||||
|
|
||||||
import androidx.credentials.provider.CallingAppInfo
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Placeholder class representing the response to an import request.
|
|
||||||
*/
|
|
||||||
data class ProviderImportCredentialsResponse(
|
|
||||||
val response: ImportCredentialsResponse,
|
|
||||||
val callingAppInfo: CallingAppInfo,
|
|
||||||
)
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
package androidx.credentials.providerevents.transfer
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Placeholder class representing a request to register as a credential export source.
|
|
||||||
*/
|
|
||||||
data class RegisterExportRequest(
|
|
||||||
val entries: List<ExportEntry>,
|
|
||||||
)
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
package androidx.credentials.providerevents.transfer
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Placeholder class representing a response to registering as a credential export source.
|
|
||||||
*/
|
|
||||||
class RegisterExportResponse
|
|
||||||
@ -26,6 +26,7 @@ internal class CredentialExchangeCompletionManagerImpl(
|
|||||||
is ExportCredentialsResult.Success -> {
|
is ExportCredentialsResult.Success -> {
|
||||||
IntentHandler.setImportCredentialsResponse(
|
IntentHandler.setImportCredentialsResponse(
|
||||||
context = activity,
|
context = activity,
|
||||||
|
intent = intent,
|
||||||
uri = exportResult.uri,
|
uri = exportResult.uri,
|
||||||
response = ImportCredentialsResponse(
|
response = ImportCredentialsResponse(
|
||||||
responseJson = exportResult.payload,
|
responseJson = exportResult.payload,
|
||||||
|
|||||||
@ -28,6 +28,7 @@ class CredentialExchangeCompletionManagerTest {
|
|||||||
context = any(),
|
context = any(),
|
||||||
uri = any(),
|
uri = any(),
|
||||||
response = any(),
|
response = any(),
|
||||||
|
intent = any(),
|
||||||
)
|
)
|
||||||
} just runs
|
} just runs
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ class CredentialExchangeCompletionManagerTest {
|
|||||||
context = mockActivity,
|
context = mockActivity,
|
||||||
uri = mockUri,
|
uri = mockUri,
|
||||||
response = any(),
|
response = any(),
|
||||||
|
intent = any(),
|
||||||
)
|
)
|
||||||
mockActivity.setResult(Activity.RESULT_OK, any())
|
mockActivity.setResult(Activity.RESULT_OK, any())
|
||||||
mockActivity.finish()
|
mockActivity.finish()
|
||||||
|
|||||||
@ -21,8 +21,8 @@ androidxBrowser = "1.9.0"
|
|||||||
androidxCamera = "1.4.2"
|
androidxCamera = "1.4.2"
|
||||||
androidxComposeBom = "2025.09.00"
|
androidxComposeBom = "2025.09.00"
|
||||||
androidxCore = "1.17.0"
|
androidxCore = "1.17.0"
|
||||||
androidxCredentials = "1.5.0"
|
androidxCredentials = "1.6.0-beta01"
|
||||||
androidxCredentialsProviderEvents = "1.0.0-alpha02"
|
androidxCredentialsProviderEvents = "1.0.0-alpha03"
|
||||||
androidxHiltNavigationCompose = "1.3.0"
|
androidxHiltNavigationCompose = "1.3.0"
|
||||||
androidxLifecycle = "2.9.3"
|
androidxLifecycle = "2.9.3"
|
||||||
androidxNavigation = "2.9.4"
|
androidxNavigation = "2.9.4"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user