def setUp(self): configurator = Configurator() configurator.add_route("example", "/example", request_method="GET") configurator.add_route("trace_context", "/trace_context", request_method="GET") configurator.add_view(example_application, route_name="example", renderer="json") configurator.add_view(local_tracing_within_context, route_name="trace_context", renderer="json") configurator.add_view(render_exception_view, context=ControlFlowException, renderer="json") configurator.add_view(render_bad_exception_view, context=ControlFlowException2, renderer="json") mock_filewatcher = mock.Mock(spec=FileWatcher) mock_filewatcher.get_data.return_value = { "secrets": { "secret/authentication/public-key": { "type": "versioned", "current": AUTH_TOKEN_PUBLIC_KEY, } }, "vault": { "token": "test", "url": "http://vault.example.com:8200/" }, } secrets = SecretsStore("/secrets") secrets._filewatcher = mock_filewatcher self.observer = mock.Mock(spec=BaseplateObserver) self.server_observer = mock.Mock(spec=ServerSpanObserver) def _register_mock(context, server_span): server_span.register(self.server_observer) self.observer.on_server_span_created.side_effect = _register_mock self.baseplate = Baseplate() self.baseplate.register(self.observer) self.baseplate_configurator = BaseplateConfigurator( self.baseplate, trust_trace_headers=True, edge_context_factory=EdgeRequestContextFactory(secrets), ) configurator.include(self.baseplate_configurator.includeme) self.context_init_event_subscriber = mock.Mock() configurator.add_subscriber(self.context_init_event_subscriber, ServerSpanInitialized) app = configurator.make_wsgi_app() self.test_app = webtest.TestApp(app)
def make_edge_context_factory(): mock_filewatcher = mock.Mock(spec=FileWatcher) mock_filewatcher.get_data.return_value = { "secrets": { "secret/authentication/public-key": { "type": "versioned", "current": AUTH_TOKEN_PUBLIC_KEY, } }, "vault": {"token": "test", "url": "http://vault.example.com:8200/"}, } secrets = SecretsStore("/secrets") secrets._filewatcher = mock_filewatcher return EdgeRequestContextFactory(secrets)
def setUp(self): mock_filewatcher = mock.Mock(spec=FileWatcher) mock_filewatcher.get_data.return_value = { "secrets": { "secret/csrf/signing-key": { "type": "versioned", "current": base64.b64encode(b"test"), "encoding": "base64", } }, "vault": {"token": "test", "url": "http://vault.example.com:8200/"}, } secrets = SecretsStore("/secrets") secrets._filewatcher = mock_filewatcher self.policy = TokenCSRFStoragePolicy(secrets=secrets, secret_path="secret/csrf/signing-key")
def secrets(): mock_filewatcher = mock.Mock(spec=FileWatcher) mock_filewatcher.get_data.return_value = { "secrets": { "secret/rabbitmq/account": { "type": "credential", "username": "******", "password": "******", } }, "vault": {"token": "test", "url": "http://vault.example.com:8200/"}, } secrets = SecretsStore("/secrets") secrets._filewatcher = mock_filewatcher return secrets
def setUp(self): mock_filewatcher = mock.Mock(spec=FileWatcher) mock_filewatcher.get_data.return_value = { "secrets": { "secret/sql/account": { "type": "credential", "username": "******", "password": "******", } }, "vault": { "token": "test", "url": "http://vault.example.com:8200/" }, } secrets = SecretsStore("/secrets") secrets._filewatcher = mock_filewatcher self.secrets = secrets