def test_multiple_adapters_store_and_retrieve(mock_response, db_filename): adapter1 = SQLiteAdapter(db_filename) adapter2 = SQLiteAdapter(db_filename) adapter1.store(mock_response) data = adapter2.read_as_dict() assert data == mock_response.by_resource_server
def test_multiple_adapters_store_and_retrieve_different_namespaces( mock_response, db_filename): adapter1 = SQLiteAdapter(db_filename, namespace="foo") adapter2 = SQLiteAdapter(db_filename, namespace="bar") adapter1.store(mock_response) data = adapter2.read_as_dict() assert data == {}
def test_token_storage(mock_login_token_response): """Put memory-backed sqlite token storage in place for the testsuite to use.""" mockstore = SQLiteAdapter(":memory:") mockstore.store_config( "auth_client_data", {"client_id": "fakeClientIDString", "client_secret": "fakeClientSecret"}, ) mockstore.store(mock_login_token_response) return mockstore
def test_remove_tokens(mock_response): adapter = SQLiteAdapter(MEMORY_DBNAME) adapter.store(mock_response) removed = adapter.remove_tokens_for_resource_server("resource_server_1") assert removed data = adapter.read_as_dict() assert data == { "resource_server_2": mock_response.by_resource_server["resource_server_2"] } removed = adapter.remove_tokens_for_resource_server("resource_server_1") assert not removed
def test_store_and_retrieve(mock_response): adapter = SQLiteAdapter(MEMORY_DBNAME) adapter.store(mock_response) data = adapter.read_as_dict() assert data == mock_response.by_resource_server