Piwigo / Piwigo-Android

Piwigo Native Android App
GNU General Public License v3.0
140 stars 43 forks source link

Tests on travis-ci can't login properly #245

Closed coolo closed 4 years ago

coolo commented 4 years ago

The tests work okayish in local studio, but fail to get the right albums for the right users on travis-ci.

You see a login, you see a cookie, you see the cookie used -> still only guest status.

What I see on the server is that travis-ci uses many different IP addresses for its accesses, so I wonder if the cookie is bound to an IP address in the server. If that's the case, we're screwed.

coolo commented 4 years ago

https://travis-ci.com/coolo/Piwigo-Android/jobs/285193532 ran a single test changeGuestToLogin

These is the access_log for this test run:

35.196.158.85 - - [09/Feb/2020:07:36:07 +0000] "GET /ws.php?method=pwg.session.getStatus&format=json HTTP/1.1" 200 319 "-" "Piwigo-Android 1.0.3-dev-debug"
35.196.72.151 - - [09/Feb/2020:07:36:09 +0000] "GET /ws.php?method=pwg.session.getStatus&format=json HTTP/1.1" 200 319 "-" "Piwigo-Android 1.0.3-dev-debug"
104.196.57.92 - - [09/Feb/2020:07:36:10 +0000] "GET /ws.php?method=pwg.categories.getImages&cat_id=0&page=0&per_page=16&format=json HTTP/1.1" 200 98 "-" "Piwigo-Android 1.0.3-dev-debug"
34.74.79.111 - - [09/Feb/2020:07:36:10 +0000] "GET /ws.php?method=pwg.categories.getList&cat_id=0&thumbnail_size=medium&format=json HTTP/1.1" 200 479 "-" "Piwigo-Android 1.0.3-dev-debug"
35.227.97.188 - - [09/Feb/2020:07:36:10 +0000] "GET /ws.php?method=pwg.categories.getImages&cat_id=0&page=0&per_page=16&format=json HTTP/1.1" 200 98 "-" "Piwigo-Android 1.0.3-dev-debug"
35.227.97.188 - - [09/Feb/2020:07:36:10 +0000] "GET /ws.php?method=pwg.categories.getList&cat_id=0&thumbnail_size=medium&format=json HTTP/1.1" 200 479 "-" "Piwigo-Android 1.0.3-dev-debug"
104.196.57.92 - - [09/Feb/2020:07:36:10 +0000] "GET /ws.php?method=pwg.categories.getList&cat_id=0&thumbnail_size=medium&format=json HTTP/1.1" 200 479 "-" "Piwigo-Android 1.0.3-dev-debug"
104.196.57.92 - - [09/Feb/2020:07:36:10 +0000] "GET /ws.php?method=pwg.categories.getImages&cat_id=0&page=0&per_page=16&format=json HTTP/1.1" 200 98 "-" "Piwigo-Android 1.0.3-dev-debug"
104.196.57.92 - - [09/Feb/2020:07:36:11 +0000] "GET /_data/i/upload/2020/01/06/20200106092730-b1bbf706-me.jpg HTTP/1.1" 200 17885 "-" "okhttp/4.2.2"
104.196.57.92 - - [09/Feb/2020:07:36:15 +0000] "POST /ws.php?method=pwg.session.login&format=json HTTP/1.1" 200 27 "-" "Piwigo-Android 1.0.3-dev-debug"
104.196.57.92 - - [09/Feb/2020:07:36:16 +0000] "POST /ws.php?method=pwg.session.login&format=json HTTP/1.1" 200 27 "-" "Piwigo-Android 1.0.3-dev-debug"
35.237.56.208 - - [09/Feb/2020:07:36:17 +0000] "GET /ws.php?method=pwg.session.getStatus&format=json HTTP/1.1" 200 319 "-" "Piwigo-Android 1.0.3-dev-debug"
35.196.158.85 - - [09/Feb/2020:07:36:18 +0000] "GET /ws.php?method=pwg.categories.getImages&cat_id=0&page=0&per_page=16&format=json HTTP/1.1" 200 98 "-" "Piwigo-Android 1.0.3-dev-debug"
35.196.72.151 - - [09/Feb/2020:07:36:18 +0000] "GET /ws.php?method=pwg.categories.getList&cat_id=0&thumbnail_size=medium&format=json HTTP/1.1" 200 479 "-" "Piwigo-Android 1.0.3-dev-debug"

As you can see, greatly different IPs - but they are all *.bc.googleusercontent.com, as the travis-ci worker runs on GCE.

coolo commented 4 years ago

piwigo_activity got 2 logins. 07tn8jnn7nv36uvf39ngodrtg5 and ikt08oo91p0pkk6006rv405nbc, both recorded from 104.196.57.92 - that fits (one is from the LoginActivitity verifying the account and one is from MainActivity actually doing the login).

The latter is then also used (according to logcat output) for getStatus, but that request came from 35.237.56.208 and returned {"username":"guest","status":"guest"

coolo commented 4 years ago

wow, piwigo indeed defaults to session_use_ip_address - welcome to the world of load balancing proxies.

coolo commented 4 years ago

I changed the config of tg1 - but that fact will be the cause of many bug reports. When you start the app on train station 1, you get a cookie and if your train travels between cells, your phone gets a new IP address and we would have to relogin :(

coolo commented 4 years ago

And to make matters worse: we don't know if the cookie is still working or not. The API will just return what 'guest' would see, so periodic relogin is the only cure I see.

coolo commented 4 years ago

Now https://travis-ci.com/coolo/Piwigo-Android/jobs/285193532 passes - will reconfigure my own gallery right away :(

coolo commented 4 years ago

So technically this is solved - but as the IP is bound to the login, it makes even less sense to worry about logout or store the cookie in the account manager. Good that this is all gone :)