Пример #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.read_as_dict()
    assert data == mock_response.by_resource_server
Пример #2
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.read_as_dict()
    assert data == {}
Пример #3
0
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
Пример #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.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
Пример #5
0
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