def test_http_basic_auth(self):
        # ((user, password), expected) tuples
        test_inputs = (
            ((None, None), 'http://example.com'),
            (('user', None), 'http://user@example.com'),
            (('user', 'pass'), 'http://user:pass@example.com'),
        )
        for (user, password), expected in test_inputs:
            kwargs = {
                'url': 'http://example.com',
                'user': user,
                'password': password,
            }
            # Test http
            result = salt.utils.url.add_http_basic_auth(**kwargs)
            self.assertEqual(result, expected)
            # Test https
            kwargs['url'] = kwargs['url'].replace('http://', 'https://', 1)
            expected = expected.replace('http://', 'https://', 1)
            result = salt.utils.url.add_http_basic_auth(**kwargs)
            self.assertEqual(result, expected)
Tests that adding basic auth to a URL works as expected
dataset/ETHPy150Open saltstack/salt/tests/unit/utils/url_test.py/UrlTestCase.test_http_basic_auth