return True
- def __print_check_ssl_msg(self):
- self._print("Please check the logs of b10-cmdctl, there may "
- "have been a problem accepting SSL connections.")
-
def _try_login(self, username, password):
'''
Attempts to log into cmdctl by sending a POST with the given
data = response.read().decode()
# return here (will raise error after try block)
return (response, data)
- except ssl.SSLError as err:
- self._print("SSL error while sending login information: ", err)
- if err.errno == ssl.SSL_ERROR_EOF:
- self.__print_check_ssl_msg()
- except socket.error as err:
- self._print("Socket error while sending login information: ", err)
- # An SSL setup error can also bubble up as a plain CONNRESET...
- # (on some systems it usually does)
- if err.errno == errno.ECONNRESET:
- self.__print_check_ssl_msg()
+ except (ssl.SSLError, socket.error) as err:
+ self._print("Error while sending login information: ", err)
+ self._print("Please check the logs of b10-cmdctl, there may "
+ "have been a problem accepting SSL connections.")
pass
raise FailToLogin()
self.tool.send_POST = send_POST_raiseImmediately
self.assertRaises(FailToLogin, self.tool._try_login, "foo", "bar")
expected_printed_messages.append(
- 'Socket error while sending login information: test error')
+ 'Error while sending login information: test error')
+ expected_printed_messages.append(
+ 'Please check the logs of b10-cmdctl, there may have been a '
+ 'problem accepting SSL connections.'
+ )
self.__check_printed_messages(expected_printed_messages)
def create_send_POST_raiseOnRead(exception):
create_send_POST_raiseOnRead(socket.error("read error"))
self.assertRaises(FailToLogin, self.tool._try_login, "foo", "bar")
expected_printed_messages.append(
- 'Socket error while sending login information: read error')
+ 'Error while sending login information: read error')
+ expected_printed_messages.append(
+ 'Please check the logs of b10-cmdctl, there may have been a '
+ 'problem accepting SSL connections.'
+ )
self.__check_printed_messages(expected_printed_messages)
# connection reset
create_send_POST_raiseOnRead(exc)
self.assertRaises(FailToLogin, self.tool._try_login, "foo", "bar")
expected_printed_messages.append(
- 'Socket error while sending login information: '
- 'connection reset')
+ 'Error while sending login information: connection reset')
expected_printed_messages.append(
- 'Please check the logs of b10-cmdctl, there may be a '
- 'problem accepting SSL connections, such as a permission '
- 'problem on the server certificate file.'
+ 'Please check the logs of b10-cmdctl, there may have been a '
+ 'problem accepting SSL connections.'
)
self.__check_printed_messages(expected_printed_messages)
create_send_POST_raiseOnRead(exc)
self.assertRaises(FailToLogin, self.tool._try_login, "foo", "bar")
expected_printed_messages.append(
- 'SSL error while sending login information: .*')
+ 'Error while sending login information: .*')
+ expected_printed_messages.append(
+ 'Please check the logs of b10-cmdctl, there may have been a '
+ 'problem accepting SSL connections.'
+ )
self.__check_printed_messages(expected_printed_messages)
# 'EOF' SSL error
create_send_POST_raiseOnRead(exc)
self.assertRaises(FailToLogin, self.tool._try_login, "foo", "bar")
expected_printed_messages.append(
- 'SSL error while sending login information: .*')
+ 'Error while sending login information: .*')
expected_printed_messages.append(
- 'Please check the logs of b10-cmdctl, there may be a '
- 'problem accepting SSL connections, such as a permission '
- 'problem on the server certificate file.'
+ 'Please check the logs of b10-cmdctl, there may have been a '
+ 'problem accepting SSL connections.'
)
self.__check_printed_messages(expected_printed_messages)