Exemplo n.º 1
0
def test_args_secure_connection(check_swarm):
    args = ('--secure-connection', 'non-default', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.secure_connection == 'non-default'

    args = ('--secure-connection', 'foo.com/bar', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.secure_connection == 'foo.com/bar'
    assert check_swarm.daemon == 'https://foo.com/bar'
Exemplo n.º 2
0
def test_args_secure_connection(check_swarm):
    args = ('--secure-connection', 'non-default', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.secure_connection == 'non-default'

    args = ('--secure-connection', 'foo.com/bar', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.secure_connection == 'foo.com/bar'
    assert check_swarm.daemon == 'https://foo.com/bar'
Exemplo n.º 3
0
def test_args_connection(check_swarm):
    args = ('--connection', '/foo', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.connection == '/foo'
    assert check_swarm.daemon == 'socket:///foo:'

    args = ('--connection', 'foo.com/bar', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.connection == 'foo.com/bar'
    assert check_swarm.daemon == 'http://foo.com/bar'
Exemplo n.º 4
0
def test_args_connection(check_swarm):
    args = ('--connection', '/foo', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.connection == '/foo'
    assert check_swarm.daemon == 'socket:///foo:'

    args = ('--connection', 'foo.com/bar', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.connection == 'foo.com/bar'
    assert check_swarm.daemon == 'http://foo.com/bar'
Exemplo n.º 5
0
def test_socketfile_failure_unreadable(check_swarm, fs):
    fs.create_file('/tmp/unreadable',
                   contents='',
                   st_mode=(stat.S_IFSOCK | 0o000))
    args = ('--swarm', '--connection', '/tmp/unreadable')
    result = check_swarm.process_args(args=args)
    assert check_swarm.socketfile_permissions_failure(parsed_args=result)
Exemplo n.º 6
0
def test_args_mixed_checks(check_swarm):
    try:
        with pytest.raises(argparse.ArgumentError):
            check_swarm.process_args(['--swarm', "--service", "FOO"])
    except SystemExit:  # Argument failures exit as well
        pass
Exemplo n.º 7
0
def test_missing_check(check_swarm):
    try:
        with pytest.raises(argparse.ArgumentError):
            check_swarm.process_args(tuple())
    except SystemExit:  # Argument failures exit as well
        pass
Exemplo n.º 8
0
def test_args_mixed_connection(check_swarm):
    args = ('--connection', 'non-default', '--secure-connection', 'non-default', '--swarm')
    with pytest.raises(SystemExit):
        check_swarm.process_args(args)
Exemplo n.º 9
0
def test_args_timeout(check_swarm):
    args = ('--timeout', '9999', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.timeout == 9999.0
Exemplo n.º 10
0
def test_socketfile_failure_unwriteable(check_swarm, fs):
    fs.create_file('/tmp/unwritable', contents='', st_mode=(stat.S_IFSOCK | 0o000))
    args = ('--swarm', '--connection', '/tmp/unwritable')
    result = check_swarm.process_args(args=args)
    assert check_swarm.socketfile_permissions_failure(parsed_args=result)
Exemplo n.º 11
0
def test_socketfile_failure_missing(check_swarm, fs):
    args = ('--swarm', '--connection', '/tmp/missing')
    result = check_swarm.process_args(args=args)
    check_swarm.socketfile_permissions_failure(parsed_args=result)
Exemplo n.º 12
0
def test_socketfile_failure_filetype(check_swarm, fs):
    fs.create_file('/tmp/not_socket', contents='testing')
    args = ('--swarm', '--connection', '/tmp/not_socket')
    result = check_swarm.process_args(args=args)
    assert check_swarm.socketfile_permissions_failure(parsed_args=result)
Exemplo n.º 13
0
def test_args_mixed_checks(check_swarm):
    try:
        with pytest.raises(argparse.ArgumentError):
            check_swarm.process_args(['--swarm', "--service", "FOO"])
    except SystemExit:  # Argument failures exit as well
        pass
Exemplo n.º 14
0
def test_missing_check(check_swarm):
    try:
        with pytest.raises(argparse.ArgumentError):
            check_swarm.process_args(tuple())
    except SystemExit:  # Argument failures exit as well
        pass
Exemplo n.º 15
0
def test_args_mixed_connection(check_swarm):
    args = ('--connection', 'non-default', '--secure-connection',
            'non-default', '--swarm')
    with pytest.raises(SystemExit):
        check_swarm.process_args(args)
Exemplo n.º 16
0
def test_socketfile_failure_filetype(check_swarm, fs):
    fs.create_file('/tmp/not_socket', contents='testing')
    args = ('--swarm', '--connection', '/tmp/not_socket')
    result = check_swarm.process_args(args=args)
    assert check_swarm.socketfile_permissions_failure(parsed_args=result)
Exemplo n.º 17
0
def test_socketfile_failure_missing(check_swarm, fs):
    args = ('--swarm', '--connection', '/tmp/missing')
    result = check_swarm.process_args(args=args)
    check_swarm.socketfile_permissions_failure(parsed_args=result)
Exemplo n.º 18
0
def test_args_timeout(check_swarm):
    args = ('--timeout', '9999', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.timeout == 9999.0
Exemplo n.º 19
0
def test_socketfile_failure_http(check_swarm, fs):
    fs.create_file('/tmp/http', contents='', st_mode=(stat.S_IFSOCK | 0o000))
    args = ('--swarm', '--connection', 'http://127.0.0.1')
    result = check_swarm.process_args(args=args)
    assert not check_swarm.socketfile_permissions_failure(parsed_args=result)
Exemplo n.º 20
0
def test_socketfile_failure_http(check_swarm, fs):
    fs.CreateFile('/tmp/http', contents='', st_mode=(stat.S_IFSOCK | 0o000))
    args = ('--swarm', '--connection', 'http://127.0.0.1')
    result = check_swarm.process_args(args=args)
    assert not check_swarm.socketfile_permissions_failure(parsed_args=result)