def test_findCheckerFactories(self): """ Test that findCheckerFactories returns all available plugins. """ availablePlugins = list(strcred.findCheckerFactories()) for plg in plugin.getPlugins(strcred.ICheckerFactory): self.assertIn(plg, availablePlugins)
def test_findCheckerFactories(self): """ L{strcred.findCheckerFactories} returns all available plugins. """ availablePlugins = list(strcred.findCheckerFactories()) for plg in plugin.getPlugins(strcred.ICheckerFactory): self.assertIn(plg, availablePlugins)
def getInvalidAuthType(): """ Helper method to produce an auth type that doesn't exist. """ invalidAuthType = "ThisPluginDoesNotExist" while invalidAuthType in [factory.authType for factory in strcred.findCheckerFactories()]: invalidAuthType += "_" return invalidAuthType
def getInvalidAuthType(): """ Helper method to produce an auth type that doesn't exist. """ invalidAuthType = 'ThisPluginDoesNotExist' while (invalidAuthType in [factory.authType for factory in strcred.findCheckerFactories()]): invalidAuthType += '_' return invalidAuthType
def test_displaysListCorrectly(self): """ The C{--help-auth} argument correctly displays all available authentication plugins, then exits. """ newStdout = NativeStringIO() options = DummyOptions() options.authOutput = newStdout self.assertRaises(SystemExit, options.parseOptions, ['--help-auth']) for checkerFactory in strcred.findCheckerFactories(): self.assertIn(checkerFactory.authType, newStdout.getvalue())
def test_displaysListCorrectly(self): """ Test that the --help-auth argument correctly displays all available authentication plugins, then exits. """ newStdout = StringIO.StringIO() options = DummyOptions() options.authOutput = newStdout self.assertRaises(SystemExit, options.parseOptions, ['--help-auth']) for checkerFactory in strcred.findCheckerFactories(): self.assertIn(checkerFactory.authType, newStdout.getvalue())
def test_helpAuthTypeLimitsOutput(self): """ Test that --help-auth-type will display a warning if you get help for an authType that does not supply at least one of the credential interfaces our application can use. """ options = OptionsForUsernamePassword() # Find an interface that we can use for our test invalidFactory = None for factory in strcred.findCheckerFactories(): if not options.supportsCheckerFactory(factory): invalidFactory = factory break self.assertNotIdentical(invalidFactory, None) # Capture output and make sure the warning is there newStdout = StringIO.StringIO() options.authOutput = newStdout self.assertRaises(SystemExit, options.parseOptions, ["--help-auth-type", "anonymous"]) self.assertIn(strcred.notSupportedWarning, newStdout.getvalue())
def test_helpAuthTypeLimitsOutput(self): """ C{--help-auth-type} will display a warning if you get help for an authType that does not supply at least one of the credential interfaces our application can use. """ options = OptionsForUsernamePassword() # Find an interface that we can use for our test invalidFactory = None for factory in strcred.findCheckerFactories(): if not options.supportsCheckerFactory(factory): invalidFactory = factory break self.assertNotIdentical(invalidFactory, None) # Capture output and make sure the warning is there newStdout = NativeStringIO() options.authOutput = newStdout self.assertRaises(SystemExit, options.parseOptions, ['--help-auth-type', 'anonymous']) self.assertIn(strcred.notSupportedWarning, newStdout.getvalue())