jenkins-bot has submitted this change and it was merged.
Change subject: Added l10n for EoWp to clean_sandbox.py
......................................................................
Added l10n for EoWp to clean_sandbox.py
Change-Id: I69d0d90565141c48f5aad584ea4bd81ac722da4a
---
M scripts/clean_sandbox.py
1 file changed, 2 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py
index 5df1da7..679c25a 100755
--- a/scripts/clean_sandbox.py
+++ b/scripts/clean_sandbox.py
@@ -63,6 +63,7 @@
u'and editing skills below this line. As this page is for editing '
u'experiments, this page will automatically be cleaned every 12 '
u'hours. -->',
+ 'eo': '{{Bonvolu ne forigi tiun ĉi linion (Provejo)}}',
'fa': u'{{subst:Wikipedia:ربات/sandbox}}',
'fi': u'{{subst:Hiekka}}',
'he': u'{{ארגז חול}}\n<!-- נא לערוך מתחת לשורה זו בלבד, תודה. -->',
@@ -107,6 +108,7 @@
'da': u'Project:Sandkassen',
'de': u'Project:Spielwiese',
'en': u'Project:Sandbox',
+ 'eo': 'Project:Provejo',
'fa': [u'Project:صفحه تمرین', u'Project:آشنایی با ویرایش'],
'fi': u'Project:Hiekkalaatikko',
'fr': u'Project:Bac à sable',
--
To view, visit https://gerrit.wikimedia.org/r/227392
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I69d0d90565141c48f5aad584ea4bd81ac722da4a
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Avicennasis <Avicennasis(a)gmail.com>
Gerrit-Reviewer: Avicennasis <Avicennasis(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] oauth and user flag of OAuthEditTest
......................................................................
[IMPROV] oauth and user flag of OAuthEditTest
Change-Id: Ie7a86131bc08839d14bd80f0126bd9c394fbfeb4
---
M tests/aspects.py
M tests/edit_tests.py
M tests/oauth_tests.py
3 files changed, 9 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
XZise: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index 994a3de..4c09d1c 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -593,6 +593,9 @@
for site in cls.sites.values():
cls.require_site_user(site['family'], site['code'], sysop)
+ if hasattr(cls, 'oauth') and cls.oauth:
+ continue
+
try:
site['site'].login(sysop)
except NoUsername:
@@ -620,6 +623,9 @@
# logged in.
for site in self.sites.values():
site = site['site']
+
+ if hasattr(self, 'oauth') and self.oauth:
+ continue
if not site.logged_in(sysop):
site.login(sysop)
@@ -783,7 +789,7 @@
bases = tuple([CheckHostnameMixin] + list(bases))
if 'write' in dct and dct['write']:
- if 'user' not in dct and 'oauth' not in dct:
+ if 'user' not in dct:
dct['user'] = True
bases = tuple([SiteWriteMixin] + list(bases))
diff --git a/tests/edit_tests.py b/tests/edit_tests.py
index 0e9ce7e..5ea3db9 100644
--- a/tests/edit_tests.py
+++ b/tests/edit_tests.py
@@ -82,7 +82,6 @@
code = 'test'
write = True
- oauth = True
def setUp(self):
"""Set up test by checking site and initialization."""
diff --git a/tests/oauth_tests.py b/tests/oauth_tests.py
index 8a7955e..a0210de 100644
--- a/tests/oauth_tests.py
+++ b/tests/oauth_tests.py
@@ -28,6 +28,8 @@
"""Run tests related to OAuth authentication."""
+ oauth = True
+
@classmethod
def setUpClass(cls):
"""Check if mwoauth is installed."""
--
To view, visit https://gerrit.wikimedia.org/r/232469
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie7a86131bc08839d14bd80f0126bd9c394fbfeb4
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: VcamX <vcamx3(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] http: Disable certificate validation
......................................................................
[FIX] http: Disable certificate validation
With 952665ac the certificate validation has been enabled for all sites and the
test checking if it can be overwritten wasn't working anymore as the site was
using a valid certificate.
This is reimplementing the feature and ignores the warning emitted that the
validation has been disabled.
This is now working against a site which uses an outdated certificate for
testing purposes. This also removes the test designed to actually highlight
that the certificate is actually valid.
Bug: T105689
Bug: T101138
Change-Id: I0fe9023ca96438c24fdaa71531b17746f09a57e1
---
M pywikibot/comms/http.py
M tests/http_tests.py
2 files changed, 27 insertions(+), 52 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 53083a0..39d4d4a 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -287,9 +287,14 @@
cookies = cookie_jar
timeout = config.socket_timeout
try:
+ ignore_validation = http_request.kwargs.pop(
+ 'disable_ssl_certificate_validation', False)
+ # Note that the connections are pooled which mean that a future
+ # HTTPS request can succeed even if the certificate is invalid and
+ # verify=True, when a request with verify=False happened before
response = session.request(method, uri, data=body, headers=headers,
cookies=cookies, auth=auth, timeout=timeout,
- verify=True)
+ verify=not ignore_validation)
except Exception as e:
http_request.data = e
else:
diff --git a/tests/http_tests.py b/tests/http_tests.py
index 6874b17..d967c3a 100644
--- a/tests/http_tests.py
+++ b/tests/http_tests.py
@@ -10,7 +10,9 @@
__version__ = '$Id$'
import os
+import re
import sys
+import warnings
import requests
@@ -21,7 +23,6 @@
from tests import _images_dir
from tests.aspects import unittest, TestCase, DeprecationTestCase
-from tests.utils import expected_failure_if
if sys.version_info[0] > 2:
unicode = str
@@ -124,63 +125,32 @@
"""HTTPS certificate test."""
- sites = {
- 'omegawiki': {
- 'hostname': 'www.omegawiki.org',
- },
- 'vikidia': {
- 'hostname': 'en.vikidia.org',
- },
- }
+ hostname = 'testssl-expire.disig.sk'
def test_https_cert_error(self):
- """Test http.request fails on invalid omegawiki SSL certificate."""
+ """Test if http.fetch respects disable_ssl_certificate_validation."""
self.assertRaises(pywikibot.FatalServerError,
- http.request,
- site=None,
- uri='https://www.omegawiki.org/')
+ http.fetch,
+ uri='https://testssl-expire.disig.sk/index.en.html')
- @expected_failure_if(sys.version_info[0] > 2) # bug 72236
- def test_https_ignore_cert_error(self):
- """Test http.request ignoring invalid vikidia SSL certificate."""
- # As the connection is cached, the above test will cause
- # subsequent requests to go to the existing, broken, connection.
- # So, this uses a different host, which hopefully hasnt been
- # connected previously by other tests.
- r = http.request(site=None,
- uri='https://en.vikidia.org/wiki/Main_Page',
- disable_ssl_certificate_validation=True)
+ with warnings.catch_warnings(record=True) as warning_log:
+ response = http.fetch(
+ uri='https://testssl-expire.disig.sk/index.en.html',
+ disable_ssl_certificate_validation=True)
+ r = response.content
self.assertIsInstance(r, unicode)
- self.assertIn('<title>Vikidia</title>', r)
+ self.assertTrue(re.search(r'<title>.*</title>', r))
- def test_https_cert_invalid(self):
- """Verify vikidia SSL certificate is invalid."""
- try:
- from pyasn1_modules import pem, rfc2459
- from pyasn1.codec.der import decoder
- except ImportError:
- raise unittest.SkipTest('pyasn1 and pyasn1_modules not available.')
+ # Verify that it now fails again
+ http.session.close() # but first clear the connection
+ self.assertRaises(pywikibot.FatalServerError,
+ http.fetch,
+ uri='https://testssl-expire.disig.sk/index.en.html')
- import ssl
- import io
-
- cert = ssl.get_server_certificate(addr=('en.vikidia.org', 443))
- s = io.StringIO(unicode(cert))
- substrate = pem.readPemFromFile(s)
- cert = decoder.decode(substrate, asn1Spec=rfc2459.Certificate())[0]
- tbs_cert = cert.getComponentByName('tbsCertificate')
- issuer = tbs_cert.getComponentByName('issuer')
- organisation = None
- for rdn in issuer.getComponent():
- for attr in rdn:
- attr_type = attr.getComponentByName('type')
- if attr_type == rfc2459.id_at_organizationName:
- value, _ = decoder.decode(attr.getComponentByName('value'),
- asn1Spec=rfc2459.X520name())
- organisation = str(value.getComponent())
- break
-
- self.assertEqual(organisation, 'TuxFamily.org non-profit organization')
+ # Verify that the warning occurred
+ self.assertEqual(len(warning_log), 1)
+ self.assertEqual(warning_log[0].category.__name__,
+ 'InsecureRequestWarning')
class TestHttpStatus(TestCase):
--
To view, visit https://gerrit.wikimedia.org/r/215507
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0fe9023ca96438c24fdaa71531b17746f09a57e1
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] cache: Wrap items into a list
......................................................................
[FIX] cache: Wrap items into a list
With 954825e1 the Request class expects that each URL parameter contains a list
to simplify the handling of it. With eedef173 the maintenance script itself
used the new `_params` variable but wasn't actually converting the entries into
lists so that the Request class thought (again due to 954825e1) the strings
itself were lists and thus joined each character.
Change-Id: Ie36a9adcb46675b576226d92e0b2c483b7e2f0d5
---
M scripts/maintenance/cache.py
1 file changed, 5 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/cache.py b/scripts/maintenance/cache.py
index 7669f17..a799d51 100755
--- a/scripts/maintenance/cache.py
+++ b/scripts/maintenance/cache.py
@@ -171,7 +171,11 @@
self.site._username = [username, username]
if not params:
raise ParseError('No request params')
- self._params = dict(eval(params))
+ self._params = {}
+ for key, value in eval(params):
+ if isinstance(value, bytes):
+ value = value.decode(self.site.encoding())
+ self._params[key] = value.split('|')
def _delete(self):
"""Delete the cache entry."""
--
To view, visit https://gerrit.wikimedia.org/r/232303
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie36a9adcb46675b576226d92e0b2c483b7e2f0d5
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Request: Ensure that keys are ASCII
......................................................................
[FIX] Request: Ensure that keys are ASCII
When in Python 2 the keys are defined via explicit arguments they are `bytes`
while they can be `unicode` instances when added later or using the
`parameters` parameter or the **-notation.
This is encoding the key using ASCII on Python 2 to normalize the keys and
making the cache easier to compare two requests. If requests with the same
parameters where created using different methods it may not use the same cache
name for all of them.
In Python 3 it's just checking that it's possible encode the keys using ASCII
bot not actually encode it as by default keyword arguments are also named
using `unicode` instances.
The `tests.dry_api_tests.DryCachedRequestTests` are now using the parameters
notation (which was added in b44e59ae) together with having the arguments
explicitly added and using the **-notation.
Change-Id: Idd3ce9588510295ca5742fb31f27ab219f3d2426
---
M pywikibot/data/api.py
M tests/dry_api_tests.py
2 files changed, 48 insertions(+), 7 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index a7b7f6d..d838f0c 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1736,6 +1736,11 @@
pywikibot.error(
u"_encoded_items: '%s' could not be encoded as '%s':"
u" %r" % (key, self.site.encoding(), value))
+ if PY2:
+ key = key.encode('ascii')
+ else:
+ assert key.encode('ascii')
+ assert isinstance(key, str)
params[key] = value
return params
diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py
index 5266256..6319154 100644
--- a/tests/dry_api_tests.py
+++ b/tests/dry_api_tests.py
@@ -48,21 +48,49 @@
def setUp(self):
super(DryCachedRequestTests, self).setUp()
- self.parms = {'site': self.basesite,
- 'action': 'query',
+ self.parms = {'action': 'query',
'meta': 'userinfo'}
- self.req = CachedRequest(expiry=1, **self.parms)
- self.expreq = CachedRequest(expiry=0, **self.parms)
- self.diffreq = CachedRequest(expiry=1, site=self.basesite, action='query', meta='siteinfo')
- self.diffsite = CachedRequest(expiry=1, site=self.altsite, action='query', meta='userinfo')
+ self.req = CachedRequest(expiry=1, site=self.basesite,
+ parameters=self.parms)
+ self.expreq = CachedRequest(expiry=0, site=self.basesite,
+ parameters=self.parms)
+ self.diffreq = CachedRequest(
+ expiry=1, site=self.basesite,
+ parameters={'action': 'query', 'meta': 'siteinfo'})
+ self.diffsite = CachedRequest(
+ expiry=1, site=self.altsite,
+ parameters={'action': 'query', 'meta': 'userinfo'})
+ # When using ** the paramters are still unicode
+ self.deprecated_explicit = CachedRequest(
+ expiry=1, site=self.basesite, action='query', meta='userinfo')
+ self.deprecated_asterisks = CachedRequest(
+ expiry=1, site=self.basesite, **self.parms)
def test_expiry_formats(self):
self.assertEqual(self.req.expiry,
- CachedRequest(datetime.timedelta(days=1), **self.parms).expiry)
+ CachedRequest(datetime.timedelta(days=1), site=self.basesite,
+ parameters=self.parms).expiry)
def test_expired(self):
self.assertFalse(self.req._expired(datetime.datetime.now()))
self.assertTrue(self.req._expired(datetime.datetime.now() - datetime.timedelta(days=2)))
+
+ def test_parameter_types(self):
+ """Test _uniquedescriptionstr is identical using different ways."""
+ # This test is done as create_file_name and cachefile_path only use
+ # the hashed name which is not very helpful
+ self.assertEqual(self.req._uniquedescriptionstr(),
+ self.req._uniquedescriptionstr())
+ self.assertEqual(self.req._uniquedescriptionstr(),
+ self.expreq._uniquedescriptionstr())
+ self.assertEqual(self.req._uniquedescriptionstr(),
+ self.deprecated_explicit._uniquedescriptionstr())
+ self.assertEqual(self.req._uniquedescriptionstr(),
+ self.deprecated_asterisks._uniquedescriptionstr())
+ self.assertNotEqual(self.req._uniquedescriptionstr(),
+ self.diffreq._uniquedescriptionstr())
+ self.assertNotEqual(self.req._uniquedescriptionstr(),
+ self.diffsite._uniquedescriptionstr())
def test_get_cache_dir(self):
retval = self.req._get_cache_dir()
@@ -71,11 +99,19 @@
def test_create_file_name(self):
self.assertEqual(self.req._create_file_name(), self.req._create_file_name())
self.assertEqual(self.req._create_file_name(), self.expreq._create_file_name())
+ self.assertEqual(self.req._create_file_name(),
+ self.deprecated_explicit._create_file_name())
+ self.assertEqual(self.req._create_file_name(),
+ self.deprecated_asterisks._create_file_name())
self.assertNotEqual(self.req._create_file_name(), self.diffreq._create_file_name())
def test_cachefile_path(self):
self.assertEqual(self.req._cachefile_path(), self.req._cachefile_path())
self.assertEqual(self.req._cachefile_path(), self.expreq._cachefile_path())
+ self.assertEqual(self.req._cachefile_path(),
+ self.deprecated_explicit._cachefile_path())
+ self.assertEqual(self.req._cachefile_path(),
+ self.deprecated_asterisks._cachefile_path())
self.assertNotEqual(self.req._cachefile_path(), self.diffreq._cachefile_path())
self.assertNotEqual(self.req._cachefile_path(), self.diffsite._cachefile_path())
--
To view, visit https://gerrit.wikimedia.org/r/232002
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idd3ce9588510295ca5742fb31f27ab219f3d2426
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>