示例#1
0
def run_test(url, allow_redirect, should_fail, text_message):
    global SYSTEM_ID

    message = "Running test: %s" % text_message

    print message,

    s = Server(url)
    s.allow_redirect(allow_redirect)

    try:
        s.up2date.login(SYSTEM_ID)
    except Exception, e:
        if should_fail and isinstance(e, should_fail):
            print "PASS"
            return 0

        print "FAIL (exception: %s)" % (e.__class__.__name__)
        return 1
示例#2
0
def run_test(url, allow_redirect, should_fail, text_message):
    global SYSTEM_ID

    message = "Running test: %s" % text_message

    print message,

    s = Server(url)
    s.allow_redirect(allow_redirect)

    try:
        s.up2date.login(SYSTEM_ID)
    except Exception, e:
        if should_fail and isinstance(e, should_fail):
            print "PASS"
            return 0

        print "FAIL (exception: %s)" % (e.__class__.__name__)
        return 1
def authenticate():
    global SERVER, PORT, HANDLER
    s = Server("http://" + SERVER + ":" + PORT + HANDLER)
    connected = False
    while not connected:
        try:
            connected = True
            print s.test.method()
        except socket.error, e:
            # nobody is listenning, try to authenticate again
            connected = False
            pass
        except httplib.BadStatusLine, e:
            # This is ok, netcat does not send apropriate response
            pass
示例#4
0
import sys
sys.path.append('..')
from rhn.rpclib import Server, GETServer

SERVER = "http://xmlrpc.rhn.redhat.com/XMLRPC"
system_id_file = "/etc/sysconfig/rhn/systemid"
try:
    SERVER = "http://%s/XMLRPC" % sys.argv[1]
    system_id_file = sys.argv[2]
except:
    pass
print "SERVER = %s" % SERVER
print "system_id_file = %s" % system_id_file

s = Server(SERVER)
sysid = open(system_id_file).read()

dict = s.up2date.login(sysid)
print dict

channels = dict['X-RHN-Auth-Channels']

channel_name, channel_version = channels[0][:2]

sg = GETServer(SERVER, headers=dict)
l = sg.listPackages(channel_name, channel_version)

print l

# Package download
示例#5
0
 def get_test_server_https(self):
     global SERVER, HANDLER, PROXY
     return Server("https://%s%s" % (SERVER, HANDLER), proxy=PROXY)
def get_test_server_https():
    global SERVER, HANDLER
    return Server("https://%s%s" % (SERVER, HANDLER))
示例#7
0
def get_test_server_proxy_http():
    global SERVER, HANDLER, PROXY
    return Server("http://%s%s" % (SERVER, HANDLER), proxy=PROXY)
示例#8
0
    system_id_file = sys.argv[2]
except:
    pass
print "SERVER = %s" % SERVER
print "system_id_file = %s" % system_id_file

def refreshCallback(*args, **kwargs):
    print "Called refreshCallback, args %s, kwargs %s" % (args, kwargs)

def progressCallback(*args, **kwargs):
    print "Called progressCallback, args %s, kwargs %s" % (args, kwargs)

if __name__ == '__main__':
    sysid = open(system_id_file).read()

    s = Server(SERVER)
    s.set_refresh_callback(refreshCallback)
    s.set_progress_callback(progressCallback)

    dict = s.up2date.login(sysid)

    gs = GETServer(SERVER, headers=dict)
    gs.set_refresh_callback(refreshCallback)
    gs.set_progress_callback(progressCallback, 16384)

    channels = dict['X-RHN-Auth-Channels']
    cn, cv = channels[0][:2]
    
    print "Calling listPackages"
    l = gs.listPackages(cn, cv)
    for p in l:
print "SERVER = %s" % SERVER
print "system_id_file = %s" % system_id_file


def refreshCallback(*args, **kwargs):
    print "Called refreshCallback, args %s, kwargs %s" % (args, kwargs)


def progressCallback(*args, **kwargs):
    print "Called progressCallback, args %s, kwargs %s" % (args, kwargs)


if __name__ == '__main__':
    sysid = open(system_id_file).read()

    s = Server(SERVER)
    s.set_refresh_callback(refreshCallback)
    s.set_progress_callback(progressCallback)

    dict = s.up2date.login(sysid)

    gs = GETServer(SERVER, headers=dict)
    gs.set_refresh_callback(refreshCallback)
    gs.set_progress_callback(progressCallback, 16384)

    channels = dict['X-RHN-Auth-Channels']
    cn, cv = channels[0][:2]

    print "Calling listPackages"
    l = gs.listPackages(cn, cv)
    for p in l:
def get_test_server_proxy_https():
    global SERVER, HANDLER, PROXY
    return Server("https://%s%s" % (SERVER, HANDLER),
                  proxy=PROXY,
                  username=PROXY_USERNAME,
                  password=PROXY_PASSWORD)
 def testGoodURIWithHTTPS(self):
     try:
         Server("https://localhost")
     except:
         assert False