def get_proxy(self, authenticated):
     """Return the proxy for XMLRPC requests."""
     if authenticated:
         # auth info must be in url
         # TODO: if there's no registrant email perhaps we should
         # just connect anonymously?
         scheme, hostinfo, path = urlsplit(self.service_url)[:3]
         if '@' in hostinfo:
             raise AssertionError(hostinfo)
         if self.registrant_email is None:
             raise AssertionError()
         if self.registrant_password is None:
             raise AssertionError()
         # TODO: perhaps fully quote the password to make it very slightly
         # obscured
         # TODO: can we perhaps add extra Authorization headers
         # directly to the request, rather than putting this into
         # the url?  perhaps a bit more secure against accidentally
         # revealing it.  std66 s3.2.1 discourages putting the
         # password in the url.
         hostinfo = '%s:%s@%s' % (urlutils.quote(self.registrant_email),
                                  urlutils.quote(self.registrant_password),
                                  hostinfo)
         url = urlunsplit((scheme, hostinfo, path, '', ''))
     else:
         url = self.service_url
     return xmlrpclib.ServerProxy(url, transport=self.transport)
Esempio n. 2
0
 def _get_compose_commandline(self, to, subject, attach_path, body=None,
                              from_=None):
     """See ExternalMailClient._get_compose_commandline"""
     compose_url = []
     if from_ is not None:
         compose_url.append('from=' + urlutils.quote(from_))
     if subject is not None:
         # Don't use urlutils.quote_plus because Claws doesn't seem
         # to recognise spaces encoded as "+".
         compose_url.append(
             'subject=' + urlutils.quote(self._encode_safe(subject)))
     if body is not None:
         compose_url.append(
             'body=' + urlutils.quote(self._encode_safe(body)))
     # to must be supplied for the claws-mail --compose syntax to work.
     if to is None:
         raise errors.NoMailAddressSpecified()
     compose_url = 'mailto:%s?%s' % (
         self._encode_safe(to), '&'.join(compose_url))
     # Collect command-line options.
     message_options = ['--compose', compose_url]
     if attach_path is not None:
         message_options.extend(
             ['--attach', self._encode_path(attach_path, 'attachment')])
     return message_options
Esempio n. 3
0
 def get_proxy(self, authenticated):
     """Return the proxy for XMLRPC requests."""
     if authenticated:
         # auth info must be in url
         # TODO: if there's no registrant email perhaps we should
         # just connect anonymously?
         scheme, hostinfo, path = urlsplit(self.service_url)[:3]
         if '@' in hostinfo:
             raise AssertionError(hostinfo)
         if self.registrant_email is None:
             raise AssertionError()
         if self.registrant_password is None:
             raise AssertionError()
         # TODO: perhaps fully quote the password to make it very slightly
         # obscured
         # TODO: can we perhaps add extra Authorization headers
         # directly to the request, rather than putting this into
         # the url?  perhaps a bit more secure against accidentally
         # revealing it.  std66 s3.2.1 discourages putting the
         # password in the url.
         hostinfo = '%s:%s@%s' % (urlutils.quote(
             self.registrant_email), urlutils.quote(
                 self.registrant_password), hostinfo)
         url = urlunsplit((scheme, hostinfo, path, '', ''))
     else:
         url = self.service_url
     return xmlrpclib.ServerProxy(url, transport=self.transport)
 def get_url(self, relpath=None):
     """Overrides get_url to inject our user."""
     base = super(TestFTPTestServerUI, self).get_url(relpath)
     parsed_url = transport.ConnectedTransport._split_url(base)
     new_url = parsed_url.clone()
     new_url.user = self.user
     new_url.quoted_user = urlutils.quote(self.user)
     new_url.password = self.password
     new_url.quoted_password = urlutils.quote(self.password)
     return str(new_url)
Esempio n. 5
0
def check_mode_r(test, base, file_mode, dir_mode, include_base=True):
    """Check that all permissions match

    :param test: The TestCase being run
    :param base: The path to the root directory to check
    :param file_mode: The mode for all files
    :param dir_mode: The mode for all directories
    :param include_base: If false, only check the subdirectories
    """
    t = test.get_transport()
    if include_base:
        test.assertTransportMode(t, base, dir_mode)
    for root, dirs, files in os.walk(base):
        for d in dirs:
            p = '/'.join([urlutils.quote(x) for x in root.split('/\\') + [d]])
            test.assertTransportMode(t, p, dir_mode)
        for f in files:
            p = os.path.join(root, f)
            p = '/'.join([urlutils.quote(x) for x in root.split('/\\') + [f]])
            test.assertTransportMode(t, p, file_mode)
Esempio n. 6
0
 def test_commandline_is_8bit(self):
     claws = mail_client.Claws(None)
     cmdline = claws._get_compose_commandline(u'*****@*****.**',
                                              u'\xb5cosm of fun!', u'file%')
     subject_string = urlutils.quote(u'\xb5cosm of fun!'.encode(
         osutils.get_user_encoding(), 'replace'))
     self.assertEqual([
         '--compose',
         'mailto:[email protected]?subject=%s' % subject_string,
         '--attach', 'file%'
     ], cmdline)
     for item in cmdline:
         self.assertFalse(isinstance(item, unicode),
                          'Command-line item %r is unicode!' % item)
Esempio n. 7
0
 def test_commandline_is_8bit(self):
     claws = mail_client.Claws(None)
     cmdline = claws._get_compose_commandline(
         u'*****@*****.**', u'\xb5cosm of fun!', u'file%')
     subject_string = urlutils.quote(
         u'\xb5cosm of fun!'.encode(osutils.get_user_encoding(), 'replace'))
     self.assertEqual(
         ['--compose',
          'mailto:[email protected]?subject=%s' % subject_string,
          '--attach',
          'file%'],
         cmdline)
     for item in cmdline:
         self.assertFalse(isinstance(item, unicode),
             'Command-line item %r is unicode!' % item)
Esempio n. 8
0
 def _get_compose_commandline(self, to, subject, attach_path, body=None):
     """See ExternalMailClient._get_compose_commandline"""
     message_options = {}
     if to is not None:
         message_options['to'] = self._encode_safe(to)
     if subject is not None:
         message_options['subject'] = self._encode_safe(subject)
     if attach_path is not None:
         message_options['attachment'] = urlutils.local_path_to_url(
             attach_path)
     if body is not None:
         options_list = ['body=%s' % urlutils.quote(self._encode_safe(body))]
     else:
         options_list = []
     options_list.extend(["%s='%s'" % (k, v) for k, v in
                     sorted(message_options.iteritems())])
     return ['-compose', ','.join(options_list)]
Esempio n. 9
0
 def test_quote_tildes(self):
     self.assertEqual('%7Efoo', urlutils.quote('~foo'))
     self.assertEqual('~foo', urlutils.quote('~foo', safe='/~'))
Esempio n. 10
0
 def test_quote(self):
     self.assertEqual('abc%20def', urlutils.quote('abc def'))
     self.assertEqual('abc%2Fdef', urlutils.quote('abc/def', safe=''))
     self.assertEqual('abc/def', urlutils.quote('abc/def', safe='/'))
Esempio n. 11
0
 def test_quote_tildes(self):
     self.assertEqual('%7Efoo', urlutils.quote('~foo'))
     self.assertEqual('~foo', urlutils.quote('~foo', safe='/~'))
Esempio n. 12
0
 def test_quote(self):
     self.assertEqual('abc%20def', urlutils.quote('abc def'))
     self.assertEqual('abc%2Fdef', urlutils.quote('abc/def', safe=''))
     self.assertEqual('abc/def', urlutils.quote('abc/def', safe='/'))