Exemple #1
0
    def test_from_parsedurl_on_url_with_quoted_credentials(self):
        original_username = '******'
        quoted_username = urlquote(original_username)

        original_password = '******'
        quoted_password = urlquote(original_password)

        url = 'https://{username}:{password}@github.com/jelmer/dulwich'.format(
            username=quoted_username, password=quoted_password)

        c = HttpGitClient.from_parsedurl(urlparse.urlparse(url))
        self.assertEqual(original_username, c._username)
        self.assertEqual(original_password, c._password)

        basic_auth = c.pool_manager.headers['authorization']
        auth_string = '%s:%s' % (original_username, original_password)
        b64_credentials = self.b64encode(auth_string)
        expected_basic_auth = 'Basic %s' % str(b64_credentials)
        self.assertEqual(basic_auth, expected_basic_auth)
Exemple #2
0
    def test_from_parsedurl_on_url_with_quoted_credentials(self):
        original_username = '******'
        quoted_username = urlquote(original_username)

        original_password = '******'
        quoted_password = urlquote(original_password)

        url = 'https://{username}:{password}@github.com/jelmer/dulwich'.format(
            username=quoted_username, password=quoted_password)

        c = HttpGitClient.from_parsedurl(urlparse.urlparse(url))
        self.assertEqual(original_username, c._username)
        self.assertEqual(original_password, c._password)
        [pw_handler] = [
            h for h in c.opener.handlers
            if getattr(h, 'passwd', None) is not None
        ]
        self.assertEqual((original_username, original_password),
                         pw_handler.passwd.find_user_password(
                             None, 'https://github.com/jelmer/dulwich'))
Exemple #3
0
    def test_from_parsedurl_on_url_with_quoted_credentials(self):
        original_username = '******'
        quoted_username = urlquote(original_username)

        original_password = '******'
        quoted_password = urlquote(original_password)

        url = 'https://{username}:{password}@github.com/jelmer/dulwich'.format(
            username=quoted_username,
            password=quoted_password
        )

        c = HttpGitClient.from_parsedurl(urlparse.urlparse(url))
        self.assertEqual(original_username, c._username)
        self.assertEqual(original_password, c._password)

        basic_auth = c.pool_manager.headers['authorization']
        auth_string = '%s:%s' % (original_username, original_password)
        b64_credentials = self.b64encode(auth_string)
        expected_basic_auth = 'Basic %s' % str(b64_credentials)
        self.assertEqual(basic_auth, expected_basic_auth)
Exemple #4
0
    def test_from_parsedurl_on_url_with_quoted_credentials(self):
        original_username = '******'
        quoted_username = urlquote(original_username)

        original_password = '******'
        quoted_password = urlquote(original_password)

        url = 'https://{username}:{password}@github.com/jelmer/dulwich'.format(
            username=quoted_username,
            password=quoted_password
        )

        c = HttpGitClient.from_parsedurl(urlparse.urlparse(url))
        self.assertEqual(original_username, c._username)
        self.assertEqual(original_password, c._password)
        [pw_handler] = [
            h for h in c.opener.handlers if getattr(h, 'passwd', None) is not None]
        self.assertEqual(
            (original_username, original_password),
            pw_handler.passwd.find_user_password(
                None, 'https://github.com/jelmer/dulwich'))