Esempio n. 1
0
def test_change_ssh_port():
    change_ssh_port()
    print "test logging in on the new port"
    
    with settings(host_string='[email protected]:10022',user='******',password=env.ROOT_PASSWORD):
        try:
            run('echo')
        except:
            print "\nTEST: change_ssh_port FAILED"
            return
        print 'CHANGE PASSED'
    print "ROLLBACK"
    assert change_ssh_port(rollback=True)
    print "TESTING ROLLBACK AGAIN"
    assert change_ssh_port(rollback=True)==False
    print "\nTEST: change_ssh_port PASSED"
    return
Esempio n. 2
0
def test_disable_root():
    #These two functions would normally be run as a pair
    #until we can find a way of testing that the function has already been run
    #since disabling root can only be run once
    print 'TEST DISABLE ROOT',env.host_string,env.port,env.user,env.host
    port_changed = change_ssh_port()
    assert port_changed
    if port_changed:
        disable_root()
    assert exists('/home/woven')
Esempio n. 3
0
def test_setup_ufw():
    #setup
    port_changed = change_ssh_port()
    if port_changed:
        disable_root()
    upload_ssh_key()
    restrict_ssh()
    uncomment_sources()
    
    #test
    setup_ufw()
Esempio n. 4
0
def setupnode(rollback=False, overwrite=False):
    """
    Install a baseline host. Can be run multiple times
    
    rollback=True to teardown the installation
    This is just used to prevent having to rollback a virtual machine
    """
    
    #either fabric or manage.py will setup the roles & hosts env
    #setup_environ handles passing all the project settings into env
    #and any woven.global_settings not already defined.
    if not rollback:
        port_changed = change_ssh_port()
        #We need to assume that if the port does not get changed that
        #it has already been done and thus we do not need to disable root
        if port_changed:
            disable_root()
        upload_ssh_key()
        restrict_ssh()
        uncomment_sources()
        upgrade_ubuntu()
        setup_ufw()
        install_packages(overwrite=overwrite)
        upload_etc()
        set_timezone()
        stop_webservers()
        start_webservers()

        
    else:
        #rollback in reverse order of installation
        #The only things we don't rollback are the updates
        set_timezone(rollback)
        install_packages(rollback)
        setup_ufw(rollback)
        uncomment_sources(rollback)
        restrict_ssh(rollback)
        upload_ssh_key(rollback)
        disable_root(rollback)
        change_ssh_port(rollback)
Esempio n. 5
0
def test_restrict_ssh():
    """
    Test ssh functions together
    """
    #setup
    port_changed = change_ssh_port()
    if port_changed:
        disable_root()
    upload_ssh_key()
    
    #test
    restrict_ssh()
    assert exists('/home/woven/.ssh/authorized_keys')