示例#1
0
def test_empty_file_has_correct_permissions():

    from burlap.files import owner, group, mode
    from burlap.require.files import file as require_file

    try:
        run_as_root('touch foo')
        require_file('bar', use_sudo=True)

        assert owner('foo') == owner('bar')
        assert group('foo') == group('bar')
        assert mode('foo') == mode('bar')

    finally:
        run_as_root('rm -f foo bar')
示例#2
0
def test_file_with_contents_has_correct_permissions():

    from burlap.files import owner, group, mode
    from burlap.require.files import file as require_file

    try:
        run_as_root('echo "something" > foo')
        require_file('bar', contents='something', use_sudo=True)

        assert owner('foo') == owner('bar')
        assert group('foo') == group('bar')
        assert mode('foo') == mode('bar')

    finally:
        run_as_root('rm -f foo bar')
示例#3
0
def test_permissions():

    from burlap.files import owner, group, mode
    from burlap.require.files import directory as require_directory

    try:
        run_as_root('mkdir foo')
        require_directory('bar', use_sudo=True)

        assert owner('foo') == owner('bar')
        assert group('foo') == group('bar')
        assert mode('foo') == mode('bar')

    finally:
        run_as_root('rmdir foo bar')
示例#4
0
def test_empty_file_has_correct_permissions():

    from burlap.files import owner, group, mode
    from burlap.require.files import file as require_file

    try:
        run_as_root('touch foo')
        require_file('bar', use_sudo=True)

        assert owner('foo') == owner('bar')
        assert group('foo') == group('bar')
        assert mode('foo') == mode('bar')

    finally:
        run_as_root('rm -f foo bar')
示例#5
0
def test_permissions():

    from burlap.files import owner, group, mode
    from burlap.require.files import directory as require_directory

    try:
        run_as_root('mkdir foo')
        require_directory('bar', use_sudo=True)

        assert owner('foo') == owner('bar')
        assert group('foo') == group('bar')
        assert mode('foo') == mode('bar')

    finally:
        run_as_root('rmdir foo bar')
示例#6
0
def test_file_with_contents_has_correct_permissions():

    from burlap.files import owner, group, mode
    from burlap.require.files import file as require_file

    try:
        run_as_root('echo "something" > foo')
        require_file('bar', contents='something', use_sudo=True)

        assert owner('foo') == owner('bar')
        assert group('foo') == group('bar')
        assert mode('foo') == mode('bar')

    finally:
        run_as_root('rm -f foo bar')
示例#7
0
def test_git_require_sudo_user(gituser):
    """
    Test working_copy() with sudo as a user
    """

    from burlap.require.git import working_copy

    username, groupname = gituser

    with cd('/tmp'):
        try:
            working_copy(REMOTE_URL, path='wc_nobody', use_sudo=True, user=username)

            assert is_dir('wc_nobody')
            assert is_dir('wc_nobody/.git')

            with cd('wc_nobody'):
                remotes = sudo('git remote -v', user=username)
                assert remotes == \
                    'origin\thttps://github.com/chrisspen/burlap.git (fetch)\r\n' \
                    'origin\thttps://github.com/chrisspen/burlap.git (push)'

                assert _current_branch() == 'master'

            assert owner('wc_nobody') == username
            assert group('wc_nobody') == groupname

        finally:
            run_as_root('rm -rf wc_nobody')
示例#8
0
def test_git_require_sudo():
    """
    Test working_copy() with sudo
    """

    from burlap.require.git import working_copy

    try:
        working_copy(REMOTE_URL, path='wc_root', use_sudo=True)

        assert is_dir('wc_root')
        assert is_dir('wc_root/.git')

        with cd('wc_root'):
            remotes = run('git remote -v')
            assert remotes == \
                'origin\thttps://github.com/chrisspen/burlap.git (fetch)\r\n' \
                'origin\thttps://github.com/chrisspen/burlap.git (push)'

            assert _current_branch() == 'master'

        assert owner('wc_root') == 'root'
        assert group('wc_root') == 'root'

    finally:
        run_as_root('rm -rf wc_root')
示例#9
0
def test_git_require_sudo_user(gituser):
    """
    Test working_copy() with sudo as a user
    """

    from burlap.require.git import working_copy

    username, groupname = gituser

    with cd('/tmp'):
        try:
            working_copy(REMOTE_URL,
                         path='wc_nobody',
                         use_sudo=True,
                         user=username)

            assert is_dir('wc_nobody')
            assert is_dir('wc_nobody/.git')

            with cd('wc_nobody'):
                remotes = sudo('git remote -v', user=username)
                assert remotes == \
                    'origin\thttps://github.com/chrisspen/burlap.git (fetch)\r\n' \
                    'origin\thttps://github.com/chrisspen/burlap.git (push)'

                assert _current_branch() == 'master'

            assert owner('wc_nobody') == username
            assert group('wc_nobody') == groupname

        finally:
            run_as_root('rm -rf wc_nobody')
示例#10
0
def test_git_require_sudo():
    """
    Test working_copy() with sudo
    """

    from burlap.require.git import working_copy

    try:
        working_copy(REMOTE_URL, path='wc_root', use_sudo=True)

        assert is_dir('wc_root')
        assert is_dir('wc_root/.git')

        with cd('wc_root'):
            remotes = run('git remote -v')
            assert remotes == \
                'origin\thttps://github.com/chrisspen/burlap.git (fetch)\r\n' \
                'origin\thttps://github.com/chrisspen/burlap.git (push)'

            assert _current_branch() == 'master'

        assert owner('wc_root') == 'root'
        assert group('wc_root') == 'root'

    finally:
        run_as_root('rm -rf wc_root')