Example #1
0
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.get_by_resource_server()
    assert data == mock_response.by_resource_server
Example #2
0
def test_on_refresh_and_retrieve(mock_response):
    """just confirm that the aliasing of these functions does not change anything"""
    adapter = SQLiteAdapter(MEMORY_DBNAME)
    adapter.on_refresh(mock_response)

    data = adapter.get_by_resource_server()
    assert data == mock_response.by_resource_server
Example #3
0
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.get_by_resource_server()
    assert data == {}
Example #4
0
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.get_by_resource_server()
    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
Example #5
0
def test_store_and_retrieve(mock_response):
    adapter = SQLiteAdapter(MEMORY_DBNAME)
    adapter.store(mock_response)

    data = adapter.get_by_resource_server()
    assert data == mock_response.by_resource_server
Example #6
0
def test_load_missing_token_data():
    adapter = SQLiteAdapter(MEMORY_DBNAME)
    assert adapter.get_by_resource_server() == {}
    assert adapter.get_token_data("resource_server_1") is None