Android-SingleSignOn
Android-SingleSignOn copied to clipboard
395 e2e test
This PR adds an end to end test to the SSO lib to fix #395.
Must:
- [ ] Execution of
connectedDebugAndroidTestfails (E2ETest.java)
Nice 2 Have:
- [ ] Enable matrix testing in
e2e.yml - [ ] latest.apk should be cached when matrix testing is used (
e2e.yml) - [ ] Replace hard coded IP address
172.17.0.1of the Nextcloud docker instance - [ ] Reenable AVD caching for quicker test runs
- [ ] Pass details as arguments to
connectedDebugAndroidTestinstead of hard coded properties (E2ETest.java)
The E2E test has two steps after setting up the test environment:
- Setup account in the Nextcloud files app
- Import this account in the Sample app and verify a successful network call
The test completely uses UIAutomator (recommended by developer.android.com). It does not use Espresso or any other frameworks. Currently the first step works well, the second has an issue confirming the permission dialog because it can't find the OK button.
The workflow currently seems to work because i am running ./gradlew connectedDebugAndroidTest || true to suppress error mails, but it actually fails :wink: :
11-05 10:30:47.408 2823 2838 I E2E : Configure Nextcloud account
11-05 10:30:47.412 2823 2838 D E2E : Launching com.nextcloud.android.beta
11-05 10:31:06.372 2823 2838 D E2E : Login Button exists. Clicking on it…
11-05 10:31:07.832 2823 2838 D E2E : Login Button clicked.
11-05 10:31:08.390 2823 2838 D E2E : URL input exists.
11-05 10:31:08.391 2823 2838 D E2E : Entering URL…
11-05 10:31:09.149 2823 2838 D E2E : URL entered.
11-05 10:31:09.149 2823 2838 D E2E : Pressing enter…
11-05 10:31:09.341 2823 2838 D E2E : Enter pressed.
11-05 10:31:09.341 2823 2838 D E2E : Waiting for WebView…
11-05 10:31:37.525 2823 2838 D E2E : WebView exists.
11-05 10:31:37.526 2823 2838 D E2E : Waiting for WebView Login Button…
11-05 10:31:37.591 2823 2838 D E2E : WebView Login Button exists. Clicking on it…
11-05 10:31:39.260 2823 2838 D E2E : Waiting for Username Input…
11-05 10:32:09.669 2823 2838 D E2E : Username Input exists. Setting text…
11-05 10:32:09.788 2823 2838 D E2E : Username has been set.
11-05 10:32:09.799 2823 2838 D E2E : Waiting for Password Input…
11-05 10:32:10.283 2823 2838 D E2E : Password Input exists. Setting text…
11-05 10:32:11.169 2823 2838 D E2E : Waiting for WebView Submit Button…
11-05 10:32:11.720 2823 2838 D E2E : WebView Submit Button exists. Clicking on it…
11-05 10:32:13.182 2823 2838 D E2E : Waiting for WebView Grant Access Button…
11-05 10:32:14.047 2823 2838 D E2E : WebView Grant Access Button exists. Clicking on it…
11-05 10:32:18.175 2823 2838 I E2E : Import account into sample app
11-05 10:32:18.175 2823 2838 D E2E : Launching com.nextcloud.android.sso.sample
11-05 10:34:00.074 2823 2838 D E2E : Waiting for OK Button…
11-05 10:35:01.678 2823 2838 D E2E : OK Button exists. Clicking on it…
com.nextcloud.android.sso.sample.E2ETest > test_01_importAccountIntoSampleApp[test(AVD) - 7.0] FAILED
androidx.test.uiautomator.UiObjectNotFoundException: UiSelector[CONTAINS_TEXT=OK]
at androidx.test.uiautomator.UiObject.click(UiObject.java:416)
Any help for the remaining steps would be appreciated @David-Development @tobiasKaminsky
@stefan-niedermann I did some testing on my end as well.. It looks like the mDevice.waitForWindowUpdate(null, TIMEOUT); just before the OK check is causing that issue. If I replace it with a Thread.sleep(5000) it works just fine - however it shows me only accounts from my normal nextcloud app - not the beta app.. Need to investigate that a little bit further why it's not showing up on my emulator
@David-Development did as you suggested, but the pipeline still fails at the very same moment... :thinking:
@stefan-niedermann Does it also fail if you run it locally? Can you see what's happening?
Okay, i stumbled upon AccountImporter#checkAndroidAccountPermissions found this in a previous log:
2021-11-05T09:53:56 E com.nextcloud.android.sso.AccountImporter: Permission not granted yet!
2021-11-05T09:53:56 W System.err: com.nextcloud.android.sso.exceptions.AndroidGetAccountsPermissionNotGranted: In order to use the Nextcloud Single-Sign-On on this device, you need to grant permission to access your accounts
2021-11-05T09:53:57 W System.err: at com.nextcloud.android.sso.AccountImporter.checkAndroidAccountPermissions(AccountImporter.java:124)
2021-11-05T09:53:57 W System.err: at com.nextcloud.android.sso.AccountImporter.pickNewAccount(AccountImporter.java:86)
2021-11-05T09:53:57 W System.err: at com.nextcloud.android.sso.sample.MainActivity.lambda$onCreate$0$com-nextcloud-android-sso-sample-MainActivity(MainActivity.java:43)
2021-11-05T09:53:57 W System.err: at com.nextcloud.android.sso.sample.MainActivity$$ExternalSyntheticLambda0.onClick(Unknown Source)
2021-11-05T09:53:57 W System.err: at android.view.View.performClick(View.java:5610)
2021-11-05T09:53:57 W System.err: at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
2021-11-05T09:53:57 W System.err: at android.view.View$PerformClick.run(View.java:22265)
2021-11-05T09:53:57 W System.err: at android.os.Handler.handleCallback(Handler.java:751)
2021-11-05T09:53:57 W System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
2021-11-05T09:53:57 W System.err: at android.os.Looper.loop(Looper.java:154)
2021-11-05T09:53:57 W System.err: at android.app.ActivityThread.main(ActivityThread.java:6077)
2021-11-05T09:53:57 W System.err: at java.lang.reflect.Method.invoke(Native Method)
2021-11-05T09:53:57 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
2021-11-05T09:53:57 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
2021-11-05T09:53:57 W audio_hw_generic: Not supplying enough data to HAL, expected position 155345 , only wrote 154800
Therefore i now adjusted the AVD emulated device to Android O (API 26) to check whether this might be the cause of the issue - Maybe on older devices the OK button is actually not present because a permission dialog is there. Let's see how it goes...
Just fyi: This PR is waiting for a new dev version being published on https://download.nextcloud.com/android/dev/ - the currently latest version (nextcloud-dev-20211111.apk) does not contain the QueryParam fix which caused SSO 0.6.0 to not being able to connect to this files app version.
Since 3.18.0 RC6 has already been tagged, i think it's just a matter of time until we can continue here :slightly_smiling_face:
Codacy
Lint
| Type | master | PR |
| Warnings | 1 | 1 |
| Errors | 0 | 0 |
SpotBugs (new)
| Warning Type | Number |
|---|---|
| Bad practice Warnings | 3 |
| Correctness Warnings | 21 |
| Internationalization Warnings | 2 |
| Multithreaded correctness Warnings | 3 |
| Performance Warnings | 5 |
| Security Warnings | 5 |
| Dodgy code Warnings | 43 |
| Total | 82 |
SpotBugs (master)
| Warning Type | Number |
|---|---|
| Bad practice Warnings | 3 |
| Correctness Warnings | 21 |
| Internationalization Warnings | 2 |
| Multithreaded correctness Warnings | 3 |
| Performance Warnings | 5 |
| Security Warnings | 5 |
| Dodgy code Warnings | 43 |
| Total | 82 |
❗ REBASED ❗