Exemple #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'
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'
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'
Exemple #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'
Exemple #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)
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
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
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)
Exemple #9
0
def test_args_timeout(check_swarm):
    args = ('--timeout', '9999', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.timeout == 9999.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)
Exemple #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)
Exemple #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)
Exemple #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
Exemple #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
Exemple #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)
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)
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)
def test_args_timeout(check_swarm):
    args = ('--timeout', '9999', '--swarm')
    result = check_swarm.process_args(args=args)
    assert result.timeout == 9999.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)
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)