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

    sock, port = find_free_port()
    c = MockControl(port, 'key1', sock, {'alt2':'key2', 'alt3':'key3'})
    c.start()

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

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

    c.terminate()
    c.join()
    return True
Ejemplo n.º 2
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.º 3
0
def t17():
    pretty = '%s t17' % __file__
    print(pretty)

    sock, port = find_free_port()
    c = MockControl(port, 'key1', sock, {'alt':'key'})
    c.start()

    r = RemoteControl(('',port), 'key', timeout=5)
    who = r.whoami()

    result = True
    if who != 'key':
        print('FAIL %s: wrong who: %s' % (pretty, who))
        result = False

    c.terminate()
    c.join()
    return result
Ejemplo n.º 4
0
def t18():
    pretty = '%s t18' % __file__
    print(pretty)

    sock, port = find_free_port()
    c = MockControl(port, 'key1', sock, {'alt2':'key2', 'alt3':'key3'})
    c.start()

    result = True
    for key in ['key1', 'key2', 'key3']:
        r = RemoteControl(('',port), key, timeout=5)
        who = r.whoami()
        if who != key:
            print('FAIL %s: wrong who: %s' % (pretty, who))
            result = False
            break

    c.terminate()
    c.join()
    return result