jenkins-bot has submitted this change and it was merged.
Change subject: Fix implicit token usage in EditTaskTest
......................................................................
Fix implicit token usage in EditTaskTest
• Don't mix login and anonymous edit tokens in EditTaskTest. Since
cookies are merged across domains, each test case now just clears all
cookies. This was the behavior of the test last year. However, it was
modified to be more exact by limiting the domain which introduced the
subtle bug of including the login session token.
• Fix SharedPreferenceCookieManager.clearCookiesForDomain() to clear in
memory cookies for the given domain. Previously this only updated
nonvolatile storage.
Change-Id: I58b046d9b81313d2fb00a6546438f8990b2000dd
---
M app/src/androidTest/java/org/wikipedia/test/EditTaskTest.java
M app/src/main/java/org/wikipedia/SharedPreferenceCookieManager.java
2 files changed, 11 insertions(+), 1 deletion(-)
Approvals:
Mholloway: Looks good to me, but someone else must approve
Dbrant: Looks good to me, approved
jenkins-bot: Verified
diff --git a/app/src/androidTest/java/org/wikipedia/test/EditTaskTest.java
b/app/src/androidTest/java/org/wikipedia/test/EditTaskTest.java
index 1d78f77..3f8cb36 100644
--- a/app/src/androidTest/java/org/wikipedia/test/EditTaskTest.java
+++ b/app/src/androidTest/java/org/wikipedia/test/EditTaskTest.java
@@ -3,6 +3,7 @@
import android.support.annotation.NonNull;
import android.support.test.runner.AndroidJUnit4;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wikipedia.Site;
@@ -26,6 +27,12 @@
private static final Site TEST_WIKI_SITE = new Site("test.wikipedia.org");
private static final String ABUSE_FILTER_ERROR_PAGE_TITLE =
"Test_page_for_app_testing/AbuseFilter";
+
+ @Before
+ public void setUp() {
+ // Cookies for a logged in session cannot be used with the anonymous
edit token.
+ app().getCookieManager().clearAllCookies();
+ }
@Test
public void testEdit() {
@@ -174,4 +181,4 @@
return result;
}
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/wikipedia/SharedPreferenceCookieManager.java
b/app/src/main/java/org/wikipedia/SharedPreferenceCookieManager.java
index f9dd91c..6b59bca 100644
--- a/app/src/main/java/org/wikipedia/SharedPreferenceCookieManager.java
+++ b/app/src/main/java/org/wikipedia/SharedPreferenceCookieManager.java
@@ -99,8 +99,11 @@
throw new UnsupportedOperationException("We poor. We no have
CookieStore");
}
+ // This will remove cookies for the domain specified but cookies from
other domains may still be
+ // merged into requests.
public void clearCookiesForDomain(String domain) {
Prefs.removeCookiesForDomain(domain);
+ cookieJar.remove(domain);
}
public void clearAllCookies() {
--
To view, visit https://gerrit.wikimedia.org/r/264082
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I58b046d9b81313d2fb00a6546438f8990b2000dd
Gerrit-PatchSet: 3
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Dbrant <[email protected]>
Gerrit-Reviewer: Mholloway <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits