def test_saprouter_route_string(self): """Test construction of SAPRouterRouteHop items""" # Two hops with full details self.check_route( "/H/host1/S/service1/W/pass1/H/host2/S/service2/W/pass2", [ SAPRouterRouteHop( hostname="host1", port="service1", password="******"), SAPRouterRouteHop( hostname="host2", port="service2", password="******") ]) # One intermediate hop with service/password self.check_route("/H/host1/H/host2/S/service2/W/pass2/H/host3", [ SAPRouterRouteHop(hostname="host1"), SAPRouterRouteHop( hostname="host2", port="service2", password="******"), SAPRouterRouteHop(hostname="host3") ]) # Example in SAP Help self.check_route( "/H/sap_rout/H/your_rout/W/pass_to_app/H/yourapp/S/sapsrv", [ SAPRouterRouteHop(hostname="sap_rout"), SAPRouterRouteHop(hostname="your_rout", password="******"), SAPRouterRouteHop(hostname="yourapp", port="sapsrv") ]) # Hostname with FQDN self.check_route( "/H/some.valid.domain.com/S/3299", [SAPRouterRouteHop(hostname="some.valid.domain.com", port="3299")]) # Hostname with IP addresses self.check_route( "/H/127.0.0.1/S/3299", [SAPRouterRouteHop(hostname="127.0.0.1", port="3299")]) # Lowercase hostname and service self.check_route("/h/127.0.0.1/s/3299/w/Password", [ SAPRouterRouteHop( hostname="127.0.0.1", port="3299", password="******") ]) # Invalid route strings self.assertListEqual(SAPRouterRouteHop.from_string("/S/service"), []) self.assertListEqual(SAPRouterRouteHop.from_string("/P/password"), [])
def check_route(self, route_string, route_hops): """Check from string to hops and back again""" hops = SAPRouterRouteHop.from_string(route_string) self.assertListEqual(hops, route_hops) string = SAPRouterRouteHop.from_hops(hops) self.assertEqual(string, route_string)
def test_saprouter_route_string(self): """Test construction of SAPRouterRouteHop items""" # Two hops with full details self.check_route("/H/host1/S/service1/W/pass1/H/host2/S/service2/W/pass2", [SAPRouterRouteHop(hostname="host1", port="service1", password="******"), SAPRouterRouteHop(hostname="host2", port="service2", password="******")]) # One intermediate hop with service/password self.check_route("/H/host1/H/host2/S/service2/W/pass2/H/host3", [SAPRouterRouteHop(hostname="host1"), SAPRouterRouteHop(hostname="host2", port="service2", password="******"), SAPRouterRouteHop(hostname="host3")]) # Example in SAP Help self.check_route("/H/sap_rout/H/your_rout/W/pass_to_app/H/yourapp/S/sapsrv", [SAPRouterRouteHop(hostname="sap_rout"), SAPRouterRouteHop(hostname="your_rout", password="******"), SAPRouterRouteHop(hostname="yourapp", port="sapsrv")]) # Hostname with FQDN self.check_route("/H/some.valid.domain.com/S/3299", [SAPRouterRouteHop(hostname="some.valid.domain.com", port="3299")]) # Hostname with IP addresses self.check_route("/H/127.0.0.1/S/3299", [SAPRouterRouteHop(hostname="127.0.0.1", port="3299")]) # Lowercase hostname and service self.check_route("/h/127.0.0.1/s/3299/w/Password", [SAPRouterRouteHop(hostname="127.0.0.1", port="3299", password="******")]) # Invalid route strings self.assertListEqual(SAPRouterRouteHop.from_string("/S/service"), []) self.assertListEqual(SAPRouterRouteHop.from_string("/P/password"), [])
def check_route(self, route_string, route_hops): """Check from string to hops and back again""" hops = SAPRouterRouteHop.from_string(route_string) self.assertListEqual(hops, route_hops) string = SAPRouterRouteHop.from_hops(hops) route_string = route_string.replace("/h/", "/H/").replace("/s/", "/S/").replace("/p/", "/P/").replace("/w/", "/W/") self.assertEqual(string, route_string)