自动测试需要用户身份验证的Android功能

时间:2018-04-23 22:58:30

标签: android security authentication testing

我正在尝试通过Keyguard Manager为Android应用程序进行用户身份验证,作为流程的一部分。这意味着必须对用户进行身份验证才能完成流程。这是通过启动Keyguard Manager createConfirmDeviceCredentialIntent生成的activityForResult并从中接收activityResult来完成的。

我想自动测试该流程。这会导致问题,因为我的自动测试无法对自身进行身份验证(即输入滑动模式或输入PIN)。如何让我的测试自动传递以将测试环境置于经过身份验证的状态?我可以在Keyguard Manager中模拟某些功能以自动通过身份验证检查吗?

Keyguard Manager

createConfirmDeviceCredentialIntent

1 个答案:

答案 0 :(得分:0)

The solution to this was more abstraction. Previously I had been doing encrpytion and decryption through static methods. I switched to using an Encryptor and Decryptor object which had a field "userAuthenticationRequired", and using a Builder to set that field as part of building an encryptor. This allowed me to test authentication by passing in an Encryptor with userAuthenticationRequired when running the app, and without that field as false when testing the app.