def testGetServerRedirectServer(self): "Verify that getServer works when talking to a server that redirects" self.cfg['serverURL'] = "%s-REDIRECT" % self.cfg['serverURL'] try: s = rpcServer.getServer() except: self.fail("Got an expection calling rpcServer.getServer")
def testDefaultWelcomeMessageHttpsToHttpsCheckReturnCode(self): "Test redirecting https to https and verify its return code" self.cfg['serverURL'] = "%s/XMLRPC-REDIRECT" % self.defaultServer s = rpcServer.getServer() s.registration.welcome_message() status = s.get_response_status() self.assertEqual(status, 200)
def testDefaulWelcomeMessageNoRedirectCheckRedirect(self): "Test a non redirecting connection and see if redirected() is set" self.cfg['serverURL'] = "http://SECRET_URL/XMLRPC" s = rpcServer.getServer() s.registration.welcome_message() ret = s.redirected() self.assertEqual(ret, None)
def testGetServerRedirectServer(self): "Verify that getServer works when talking to a server that redirects" self.cfg['serverURL'] = "https://rhn.redhat.com/XMLRPC-REDIRECT" try: s = rpcServer.getServer() except: self.fail("Got an expection calling rpcServer.getServer")
def updateHardware(): s = rpcServer.getServer() hardwareList = hardware.Hardware() s.registration.refresh_hw_profile(up2dateAuth.getSystemId(), hardwareList)
def __init__(self, serverOverride=None, timeout=None, rpcServerOverride=None): if rpcServerOverride is None: self._server = rpcServer.getServer(serverOverride=serverOverride, timeout=timeout) else: self._server = rpcServerOverride self._capabilities = None
def testDefaultWelcomeMessageHttpToHttpsCheckRedirect(self): "Test redirecting http to https and verify redirect()" self.cfg['serverURL'] = "%s/XMLRPC-REDIRECT" % self.defaultServer s = rpcServer.getServer() s.registration.welcome_message() ret = s.redirected() self.assertEqual(ret, "%s/XMLRPC") % self.defaultServer
def testDefaultWelcomeMessageHttpToHttpCheckRedirect(self): "Test redirecting http to http and verify redirect()" self.cfg['serverURL'] = "http://SECRET_URL/XMLRPC-REDIRECT-NOSSL" s = rpcServer.getServer() s.registration.welcome_message() ret = s.redirected() self.assertEqual(ret, "http://SECRET_URL/XMLRPC")
def testDefaultWelcomeMessageFailoverNonExistentServer(self): "Test welcome_message call faling over from a non existent server" self.cfg['serverURL'] = [ self.neServer, '%s/XMLRPC' % self.defaultServer ] s = rpcServer.getServer() s.registration.welcome_message()
def testDefaultWelcomeMessageHttpToHttpCheckReturnCode(self): "Test redirecting http to http and verify its return code" self.cfg['serverURL'] = "http://SECRET_URL/XMLRPC-REDIRECT-NOSSL" s = rpcServer.getServer() s.registration.welcome_message() status = s.get_response_status() self.assertEqual(status, 200)
def testDefaultWelcomeMessageFailover404ServerRedirect(self): "Test welcome_message call faling over from a non existent server to a redirect" self.cfg['serverURL'] = [ self.FourOhFourServer, '%s/XMLRPC-REDIRECT' % self.defaultServer ] s = rpcServer.getServer() s.registration.welcome_message()
def testDefaultWelcomeMessageFailover404Server(self): "Test welcome_message call faling over from a server that 404's" self.cfg['serverURL'] = [ self.FourOhFourServer, '%s/XMLRPC' % self.defaultServer ] s = rpcServer.getServer() s.registration.welcome_message()
def testGetServerMultipleCaCert(self): "getServer with a multiple CA certs" rpcServer.rhns_ca_certs = ["/usr/share/rhn/RHNS-CA-CERT", "/usr/share/rhn/RHNS-CA-CERT"] try: s = rpcServer.getServer() except: self.fail("Got an %s expection" % sys.exc_type)
def testGetServerAuthProxyNoEnableAuthProxy(self): "getServer with httpProxy set, but no enableAuthProxy" sys.path.append("/etc/sysconfig/rhn/") proxyUrl = testConfig.authProxyUrl self.cfg['httpProxy'] = testConfig.authProxyUrl try: s = rpcServer.getServer() except: self.fail("Got an expection calling rpcServer.getServer")
def testGetServerProxy(self): "Verify that getServer Works when specifying a proxy" sys.path.append("/etc/sysconfig/rhn/") proxyUrl = testConfig.anonProxyUrl self.cfg['httpProxy'] = proxyUrl try: s = rpcServer.getServer() except: self.fail("Got an expection calling rpcServer.getServer")
def testGetServerAuthProxyNoUsername(self): "Verify that getSerer works when specifying an an auth proxy and no username" sys.path.append("/etc/sysconfig/rhn/") proxyUrl = testConfig.authProxyUrl self.cfg['httpProxy'] = testConfig.authProxyUrl self.cfg['enableAuthProxy'] = 1 try: s = rpcServer.getServer() except: self.fail("Got an expection calling rpcServer.getServer")
def testGetServerNoCaCert(self): "getServer with a missing CA cert" self.cfg['sslCACert'] = ["/var/not/likely/to/exist/I/hope/SSL-CA-Cert"] try: s = rpcServer.getServer() write(s) except SystemExit: pass else: self.fail("Expected to get an SSLCertificateFileNotFound error")
def testDefaultWelcomeMessageHttpsToHttp(self): "Test redirecting https to http" self.cfg['serverURL'] = "https://SECRET_URL/XMLRPC-REDIRECT-NOSSL" s = rpcServer.getServer() try: s.registration.welcome_message() except rpclib.InvalidRedirectionError: pass else: self.fail("IOError expected here but didnt get it")
def testDefaultWelcomeMessageHttpsToHttpsRedirectsOff(self): "Test redirecting https to https and verify it fails with allow_redirect off" self.cfg['serverURL'] = "%s/XMLRPC-REDIRECT" % self.defaultServer s = rpcServer.getServer() s.allow_redirect(0) try: s.registration.welcome_message() except rpclib.InvalidRedirectionError: pass else: self.fail("InvalidRedirectionError expected here but didnt get it")
def testGetServerNoCaCert(self): "getServer with a missing CA cert" self.cfg['sslCACert'] = ["/var/not/likely/to/exist/I/hope/SSL-CA-Cert"] # rpcServer.rhns_ca_certs = ["/var/not/likely/to/exist/I/hope/SSL-CA-Cert"] try: s = rpcServer.getServer() write(s) except SystemExit: pass else: self.fail("Expected to get a sys.exit(1)")
def testGetServerMultipleCaCert(self): "getServer with a multiple CA certs" rpcServer.rhns_ca_certs = [ "/etc/ssl/certs/ISRG_Root_X1.pem", "/etc/ssl/certs/ISRG_Root_X1.pem" ] try: s = rpcServer.getServer() except: self.fail("Got an %s exception" % sys.exc_type)
def testDefaultWelcomeMessageHttpToHttpRedirectsOff(self): "Test redirecting http to http and verify if tails with allow_redirect off" self.cfg['serverURL'] = "http://SECRET_URL/XMLRPC-REDIRECT-NOSSL" s = rpcServer.getServer() s.allow_redirect(0) try: s.registration.welcome_message() except rpclib.InvalidRedirectionError: pass else: self.fail("InvalidRedirectionError expected here but didnt get it")
def getSolutions(self, unknowns, progressCallback=None, msgCallback=None): s = rpcServer.getServer(refreshCallback=self.refreshCallback) try: tmpRetList = rpcServer.doCall(s.up2date.solveDependencies, up2dateAuth.getSystemId(), unknowns) except rpclib.Fault, f: if f.faultCode == -26: #raise RpmError(f.faultString + _(", depended on by %s") % unknowns) raise up2dateErrors.RpmError(f.faultString) else: raise up2dateErrors.CommunicationError(f.faultString)
def __get_server(): """ Initialize a server connection and set up capability info. """ server = rpcServer.getServer() # load the new client caps if they exist clientCaps.loadLocalCaps() headerlist = clientCaps.caps.headerFormat() for (headerName, value) in headerlist: server.add_header(headerName, value) return server
def getSolutions(self, unknowns, progressCallback = None, msgCallback = None): s = rpcServer.getServer(refreshCallback=self.refreshCallback) try: tmpRetList = rpcServer.doCall(s.up2date.solveDependencies, up2dateAuth.getSystemId(), unknowns) except rpclib.Fault, f: if f.faultCode == -26: #raise RpmError(f.faultString + _(", depended on by %s") % unknowns) raise up2dateErrors.RpmError(f.faultString) else: raise up2dateErrors.CommunicationError(f.faultString)
def testDefaultWelcomeMessageHttpsToHttpCheckRedirect(self): "Test redirecting https to http and verify redirect()" self.cfg['serverURL'] = "https://SECRET_URL/XMLRPC-REDIRECT-NOSSL" s = rpcServer.getServer() try: s.registration.welcome_message() except rpclib.InvalidRedirectionError: pass else: self.fail("InvalidRedirectError expected here but didnt get it") ret = s.redirected() self.assertEqual(ret, "http://SECRET_URL/XMLRPC")
def testDefaultWelcomeMessageHttpsToHttpFailoversSSL(self): "Test redirecting https to http after failing over from bad ssl servers" self.cfg['serverURL'] = [self.neServerSSL, self.FourOhFourServerSSL, "https://SECRET_URL/XMLRPC-REDIRECT-NOSSL"] s = rpcServer.getServer() try: s.registration.welcome_message() except rpclib.InvalidRedirectionError: pass else: self.fail("InvalidRedirectionError expected here but didnt get it")
def refresh_list(cache_only=None): if cache_only: return (0, "no-ops for caching", {}) # read all hardware in hardwareList = hardware.Hardware() s = rpcServer.getServer() if argVerbose > 1: print "Called refresh_hardware" try: s.registration.refresh_hw_profile(up2dateAuth.getSystemId(), hardwareList) except: print "ERROR: sending hardware database for System Profile" return (12, "Error refreshing system hardware", {}) return (0, "hardware list refreshed", {})
def testDefaultWelcomeMessage(self): "Test welcome_message call with no redirects or proxies" s = rpcServer.getServer() s.registration.welcome_message()
def testGetServerDefaultWithRefreshCallback(self): "Verify that getServer works with default config and a refreshCallback" try: s = rpcServer.getServer(refreshCallback=self.__callback) except: self.fail("Got an expection calling rpcServer.getServer")
def testDefaultWelcomeMessageFailoverNonExistentServer(self): "Test welcome_message call faling over from a non existent server" self.cfg['serverURL'] = [ self.neServer, 'https://SECRET_URL/XMLRPC'] s = rpcServer.getServer() s.registration.welcome_message()
def testDefaultWelcomeMessageHttpsToHttps(self): "Test redirecting https to https" self.cfg['serverURL'] = "https://SECRET_URL/XMLRPC-REDIRECT" s = rpcServer.getServer() s.registration.welcome_message()
def testDefaultWelcomeMessageFailover404Server(self): "Test welcome_message call faling over from a server that 404's" self.cfg['serverURL'] = [ self.FourOhFourServer, 'https://SECRET_URL/XMLRPC'] s = rpcServer.getServer() s.registration.welcome_message()
def testGetServerDefault(self): "Verify that rpcServer.getServer works with default config and arguments" try: s = rpcServer.getServer() except: self.fail("Got an expection calling rpcServer.getServer")
def testDefaultWelcomeMessageFailover404ServerRedirect(self): "Test welcome_message call faling over from a non existent server to a redirect" self.cfg['serverURL'] = [ self.FourOhFourServer, 'https://SECRET_URL/XMLRPC-REDIRECT'] s = rpcServer.getServer() s.registration.welcome_message()