Ejemplo n.º 1
0
def t21():
    pretty = '%s t21' % __file__
    print(pretty)

    sock, port = find_free_port()
    accounts = {'admin':'key2', 'root':'key3', 'nobody':'key4'}
    c = MockControl(port, 'key1', sock, accounts)
    c.start()

    r = RemoteControl(('',port), 'key4', timeout=5)
    who = r.whoami()
    if who != 'key4':
        print('FAIL %s: wrong who: %s' % (pretty, who))
        c.terminate()
        c.join()
        return False

    r = RemoteControl(('',port), 'key4', timeout=5)
    try:
        r.whoami_preauth()
    except Exception, e:
        if str(e) != 'not authorized to make this call':
            print('FAIL %s: wrong error: %s' % (pretty, str(e)))
            c.terminate()
            c.join()
            return False
Ejemplo n.º 2
0
def t23():
    pretty = '%s t23' % __file__
    print(pretty)

    sock, port = find_free_port()
    c = MockControl(port, None, sock, {'admin':None, 'root':None})
    c.start()

    r = RemoteControl(('',port), 'foo bar', timeout=5)
    who = r.whoami_preauth()
    if who != None:
        print('FAIL %s: wrong who: %s' % (pretty, who))
        c.terminate()
        c.join()
        return False

    c.terminate()
    c.join()
    return True
Ejemplo n.º 3
0
def t20():
    pretty = '%s t20' % __file__
    print(pretty)

    sock, port = find_free_port()
    accounts = {'admin':'key2', 'root':'key3', 'nobody':'key4'}
    c = MockControl(port, 'key1', sock, accounts)
    c.start()

    r = RemoteControl(('',port), 'key2', timeout=5)
    who = r.whoami_preauth()
    if who != 'key2':
        print('FAIL %s: wrong who: %s' % (pretty, who))
        c.terminate()
        c.join()
        return False

    c.terminate()
    c.join()
    return True