def testFromArgsWithIapTunnelingEnabled(self, internal_ip_flag_available, iap_tunneling_flag_available): if internal_ip_flag_available: ssh_surface.AddInternalIPArg(self.parser) if iap_tunneling_flag_available: iap_tunnel.AddSshTunnelArgs(self.parser, self.parser) expected_tunnel_args = self._GenExpectedTunnelArgs() if iap_tunneling_flag_available: # Implicit enabled cases self.assertEqual(self._FromArgs([], include_external_nic=False), expected_tunnel_args) # Explicit enabled cases self.assertEqual(self._FromArgs(['--tunnel-through-iap']), expected_tunnel_args) self.assertEqual( self._FromArgs(['--tunnel-through-iap'], include_external_nic=False), expected_tunnel_args) if internal_ip_flag_available and iap_tunneling_flag_available: # Implicit enabled cases self.assertEqual( self._FromArgs(['--no-internal-ip'], include_external_nic=False), expected_tunnel_args) # Explicit enabled cases self.assertEqual( self._FromArgs(['--no-internal-ip', '--tunnel-through-iap']), expected_tunnel_args) self.assertEqual( self._FromArgs(['--no-internal-ip', '--tunnel-through-iap'], include_external_nic=False), expected_tunnel_args)
def testFromArgsWithIapTunnelingDisabled(self, internal_ip_flag_available, iap_tunneling_flag_available): if internal_ip_flag_available: ssh_surface.AddInternalIPArg(self.parser) if iap_tunneling_flag_available: iap_tunnel.AddSshTunnelArgs(self.parser, self.parser) # Implicit disabled cases self.assertIsNone(self._FromArgs([])) if not iap_tunneling_flag_available: self.assertIsNone(self._FromArgs([], include_external_nic=False)) if iap_tunneling_flag_available: # Explicit disabled cases self.assertIsNone(self._FromArgs(['--no-tunnel-through-iap'])) self.assertIsNone( self._FromArgs(['--no-tunnel-through-iap'], include_external_nic=False)) if internal_ip_flag_available: # Implicit disabled cases self.assertIsNone(self._FromArgs(['--internal-ip'])) self.assertIsNone( self._FromArgs(['--internal-ip'], include_external_nic=False)) self.assertIsNone(self._FromArgs(['--no-internal-ip'])) if internal_ip_flag_available and iap_tunneling_flag_available: # Not allowed to use both --internal-ip and --tunnel-through-iap flags, # but --internal-ip trumps --tunnel-through-iap and IAP tunneling is # disabled. self.assertIsNone( self._FromArgs(['--internal-ip', '--tunnel-through-iap'])) self.assertIsNone( self._FromArgs(['--internal-ip', '--tunnel-through-iap'], include_external_nic=False)) # For completeness, other combinations with IAP tunneling explicitly # disabled. self.assertIsNone( self._FromArgs(['--internal-ip', '--no-tunnel-through-iap'])) self.assertIsNone( self._FromArgs(['--internal-ip', '--no-tunnel-through-iap'], include_external_nic=False)) self.assertIsNone( self._FromArgs(['--no-internal-ip', '--no-tunnel-through-iap'])) self.assertIsNone( self._FromArgs(['--no-internal-ip', '--no-tunnel-through-iap'], include_external_nic=False))
def testFromArgsWithPassThroughArgs(self): ssh_surface.AddInternalIPArg(self.parser) iap_tunnel.AddSshTunnelArgs(self.parser, self.parser) expected_tunnel_args = self._GenExpectedTunnelArgs() expected_tunnel_args.pass_through_args = [ '--iap-tunnel-url-override=https://none' ] self.assertEqual( self._FromArgs([ '--tunnel-through-iap', '--iap-tunnel-url-override=https://none' ]), expected_tunnel_args) expected_tunnel_args.pass_through_args = [ '--iap-tunnel-insecure-disable-websocket-cert-check' ] self.assertEqual( self._FromArgs([ '--tunnel-through-iap', '--iap-tunnel-insecure-disable-websocket-cert-check' ]), expected_tunnel_args) expected_tunnel_args.pass_through_args = [ '--iap-tunnel-url-override=https://none', '--iap-tunnel-insecure-disable-websocket-cert-check' ] self.assertEqual( self._FromArgs([ '--tunnel-through-iap', '--iap-tunnel-url-override=https://none', '--iap-tunnel-insecure-disable-websocket-cert-check' ]), expected_tunnel_args) expected_tunnel_args.pass_through_args = [] self.assertEqual( self._FromArgs([ '--tunnel-through-iap', '--no-iap-tunnel-insecure-disable-websocket-cert-check' ]), expected_tunnel_args)