def serverapp(environ, config, http_port, tmp_path, home_dir, data_dir, config_dir, runtime_dir, root_dir): config.NotebookNotary.db_file = ':memory:' token = hexlify(os.urandom(4)).decode('ascii') url_prefix = '/' app = ServerApp( port=http_port, port_retries=0, open_browser=False, config_dir=str(config_dir), data_dir=str(data_dir), runtime_dir=str(runtime_dir), root_dir=str(root_dir), base_url=url_prefix, config=config, allow_root=True, token=token, ) app.init_signal = lambda: None app.log.propagate = True app.log.handlers = [] # Initialize app without httpserver app.initialize(argv=[], new_httpserver=False) app.log.propagate = True app.log.handlers = [] # Start app without ioloop app.start_app() return app
def initialize_server(argv=[], **kwargs): """Get an instance of the Jupyter Server.""" # Get a jupyter server instance serverapp = ServerApp(**kwargs) # Initialize ServerApp config. # Parses the command line looking for # ServerApp configuration. serverapp.initialize(argv=argv) return serverapp
def test_deprecated_config(): cfg = Config() cfg.ServerApp.token = token = "asdf" cfg.ServerApp.password = password = passwd("secrets") app = ServerApp(config=cfg) app.initialize([]) app.init_configurables() assert app.identity_provider.token == token assert app.token == token assert app.identity_provider.hashed_password == password assert app.password == password
def test_deprecated_config_priority(): cfg = Config() cfg.ServerApp.token = "ignored" cfg.IdentityProvider.token = token = "idp_token" cfg.ServerApp.password = passwd("ignored") cfg.PasswordIdentityProvider.hashed_password = password = passwd("used") app = ServerApp(config=cfg) app.initialize([]) app.init_configurables() assert app.identity_provider.token == token assert app.identity_provider.hashed_password == password