Browse Source

Py3: Faulty login handler didn't report NNTP-code

And added tests.

Closes #1241
pull/1253/head
Safihre 6 years ago
parent
commit
845c608d2b
  1. 4
      sabnzbd/downloader.py
  2. 2
      sabnzbd/newswrapper.py
  3. 10
      tests/test_functional_config.py

4
sabnzbd/downloader.py

@ -40,7 +40,7 @@ import sabnzbd.config as config
import sabnzbd.cfg as cfg
from sabnzbd.bpsmeter import BPSMeter
import sabnzbd.scheduler
from sabnzbd.misc import from_units, nntp_to_msg
from sabnzbd.misc import from_units, nntp_to_msg, int_conv
from sabnzbd.utils.happyeyeballs import happyeyeballs
@ -625,7 +625,7 @@ class Downloader(Thread):
block = False
penalty = 0
msg = error.response
ecode = int(msg[:3])
ecode = int_conv(msg[:3])
display_msg = ' [%s]' % msg
logging.debug('Server login problem: %s, %s', ecode, msg)
if ecode in (502, 400, 481, 482) and clues_too_many(msg):

2
sabnzbd/newswrapper.py

@ -313,7 +313,7 @@ class NewsWrapper(object):
if code == 501 and self.user_sent:
# Change to a sensible text
code = 481
self.data[0] = T('Authentication failed, check username/password.')
self.data[0] = "%d %s" % (code, T('Authentication failed, check username/password.'))
self.user_ok = True
self.pass_sent = True

10
tests/test_functional_config.py

@ -217,7 +217,17 @@ class SABnzbdConfigServers(SABnzbdBaseTest):
pass_inp.send_keys("bad")
self.driver.find_elements_by_css_selector(".testServer")[1].click()
self.wait_for_ajax()
check_result = self.driver.find_elements_by_css_selector('.result-box')[1].text.lower()
assert "authentication failed" in check_result or "invalid username or password" in check_result
# Test no username and password
pass_inp.clear()
username_inp = self.driver.find_elements_by_css_selector("input[data-hide='username']")[1]
username_inp.clear()
self.driver.find_elements_by_css_selector(".testServer")[1].click()
self.wait_for_ajax()
check_result = self.driver.find_elements_by_css_selector('.result-box')[1].text.lower()
assert "server requires username and password" in check_result
# Finish
self.remove_server()

Loading…
Cancel
Save