def test_reload(self): Credentials('root', 'passwd', {"key": "value"}).persist() c = Credentials('root') self.assertEqual( keyring.get_password(Credentials.KEYRING_PASSWORD, 'root'), 'passwd') self.assertEqual( json.loads(keyring.get_password(Credentials.KEYRING_COOKIE, 'root')), {"key": "value"})
def cli(ctx, base_url, username, password, debug, watch): """ YouTrack command line interface """ connection = ctx.obj.connection ctx.obj.debug = debug ctx.obj.watch = watch if debug: logging.basicConfig(level=logging.DEBUG) import httplib httplib.HTTPConnection.debuglevel = 1 if base_url: connection.api_url = base_url if username and username != connection.credentials.username: connection.credentials = Credentials(username, password) if not connection.api_url or not connection.credentials.username: ctx.invoke(new.config) ctx.obj.config.reload() connection.api_url = ctx.obj.config.base_url connection.credentials = ctx.obj.config.credentials if not (connection.credentials.cookies or connection.credentials.password): connection.credentials.password = click.prompt( "Enter password for %s" % connection.credentials.username, hide_input=True) if not connection.credentials.cookies: connection.login() if base_url: connection.api_url = base_url
def setUp(self): credentials = Credentials(username='******') credentials.reset_cookies() credentials.reset_password()
def test_empty(self): c = Credentials('root') self.assertIsNone(c.password) self.assertIsNone(c.cookies)
def credentials(self): return Credentials(self.__config.get('username'), self.__config.get('password'))
def test_successful_authentication(self): connection = Connection( credentials=Credentials(username='******', password='******'), base_url='http://localhost:9876' ) self.assertTrue(connection.login())
def test_invalid_password(self): connection = Connection( credentials=Credentials(username='******', password='******'), base_url='http://localhost:9876' ) self.assertRaises(LoginError, connection.login)