Example #1
0
def test_reject_auth():
    for username in ['', 'hello']:
        for password in ['', 'world']:
            with pytest.raises(exception.UserException):
                calling_format._s3connection_opts_from_uri(
                    'https+path://{0}:{1}@localhost:443'
                    .format(username, password))
Example #2
0
def test_reject_auth():
    for username in ['', 'hello']:
        for password in ['', 'world']:
            with pytest.raises(exception.UserException):
                calling_format._s3connection_opts_from_uri(
                    'https+path://{0}:{1}@localhost:443'.format(
                        username, password))
Example #3
0
def test_https():
    for proto in ['http', 'https']:
        for convention in ['virtualhost', 'path', 'subdomain']:
            opts = calling_format._s3connection_opts_from_uri(
                '{0}+{1}://'.format(proto, convention))

            assert (proto == 'https') == opts['is_secure']
            assert (proto == 'http') == (not opts['is_secure'])

            cf = opts['calling_format']

            if convention == 'virtualhost':
                assert isinstance(cf, connection.VHostCallingFormat)
            elif convention == 'path':
                assert isinstance(cf, connection.OrdinaryCallingFormat)
            elif convention == 'subdomain':
                assert isinstance(cf, connection.SubdomainCallingFormat)
            else:
                assert False
Example #4
0
def test_https():
    for proto in ['http', 'https']:
        for convention in ['virtualhost', 'path', 'subdomain']:
            opts = calling_format._s3connection_opts_from_uri(
                '{0}+{1}://'.format(proto, convention))

            assert (proto == 'https') == opts['is_secure']
            assert (proto == 'http') == (not opts['is_secure'])

            cf = opts['calling_format']

            if convention == 'virtualhost':
                assert isinstance(cf, connection.VHostCallingFormat)
            elif convention == 'path':
                assert isinstance(cf, connection.OrdinaryCallingFormat)
            elif convention == 'subdomain':
                assert isinstance(cf, connection.SubdomainCallingFormat)
            else:
                assert False
Example #5
0
def test_reject_fragment():
    with pytest.raises(exception.UserException):
        print(
            calling_format._s3connection_opts_from_uri(
                'https+path://localhost#hello'))
Example #6
0
def test_reject_query():
    with pytest.raises(exception.UserException):
        calling_format._s3connection_opts_from_uri(
            'https+path://localhost?q=world')
Example #7
0
def test_reject_path():
    with pytest.raises(exception.UserException):
        calling_format._s3connection_opts_from_uri(
            'https+path://localhost/hello')
Example #8
0
def test_port():
    opts = calling_format._s3connection_opts_from_uri(
        'https+path://localhost:443')
    assert opts['port'] == 443
Example #9
0
def test_bad_scheme():
    with pytest.raises(exception.UserException):
        calling_format._s3connection_opts_from_uri('https+nope://')
Example #10
0
def test_bad_proto():
    with pytest.raises(exception.UserException):
        calling_format._s3connection_opts_from_uri('nope+virtualhost://')
Example #11
0
def test_reject_fragment():
    with pytest.raises(exception.UserException):
        print calling_format._s3connection_opts_from_uri(
            'https+path://localhost#hello')
Example #12
0
def test_reject_query():
    with pytest.raises(exception.UserException):
        calling_format._s3connection_opts_from_uri(
            'https+path://localhost?q=world')
Example #13
0
def test_port():
    opts = calling_format._s3connection_opts_from_uri(
        'https+path://localhost:443')
    assert opts['port'] == 443
Example #14
0
def test_bad_scheme():
    with pytest.raises(exception.UserException):
        calling_format._s3connection_opts_from_uri('https+nope://')
Example #15
0
def test_bad_proto():
    with pytest.raises(exception.UserException):
        calling_format._s3connection_opts_from_uri('nope+virtualhost://')