@@ -625,11 +625,47 @@ def test10Login(self):
625625 """
626626 Failed login test, gives us a bit more coverage
627627 """
628- ret = tests .clicomm ("bugzilla --bugzilla %s "
629- 630- "--password foobar login" % self .url , None ,
631- expectfail = True )
632- self .assertTrue ("Login failed: " in ret )
628+ # We overwrite getpass for testing
629+ import getpass
630+
631+ def fakegetpass (prompt ):
632+ sys .stdout .write (prompt )
633+ sys .stdout .flush ()
634+ return sys .stdin .readline ()
635+ oldgetpass = getpass .getpass
636+ getpass .getpass = fakegetpass
637+
638+ try :
639+ # Implied login with --username and --password
640+ ret = tests .clicomm ("bugzilla --bugzilla %s "
641+ 642+ "--password foobar query -b 123456" % self .url ,
643+ None , expectfail = True )
644+ self .assertTrue ("Login failed: " in ret )
645+
646+ # 'login' with explicit options
647+ ret = tests .clicomm ("bugzilla --bugzilla %s "
648+ 649+ "--password foobar login" % self .url ,
650+ None , expectfail = True )
651+ self .assertTrue ("Login failed: " in ret )
652+
653+ # 'login' with positional options
654+ ret = tests .clicomm ("bugzilla --bugzilla %s "
655+ "login [email protected] foobar" % self .
url ,
656+ None , expectfail = True )
657+ self .assertTrue ("Login failed: " in ret )
658+
659+
660+ # bare 'login'
661+ stdinstr = "[email protected] \n \r foobar\n \r " 662+ ret = tests .clicomm ("bugzilla --bugzilla %s login" % self .url ,
663+ None , expectfail = True , stdinstr = stdinstr )
664+ self .assertTrue ("Bugzilla Username:" in ret )
665+ self .assertTrue ("Bugzilla Password:" in ret )
666+ self .assertTrue ("Login failed: " in ret )
667+ finally :
668+ getpass .getpass = oldgetpass
633669
634670
635671 def test10LoginState (self ):
0 commit comments