def test_unauthenticated_user_cannot_join_collection(config,
                                                     user_owned_collection):
    """An unauthenticated user should not be able to join or view
    collections."""
    unauth_client = R2RClient(config.base_url)
    # we must CREATE + LOGIN as superuser is default user for unauth in basic config
    user_name = f"unauth_user_{uuid.uuid4()}@email.com"
    unauth_client.users.create(user_name, "unauth_password")
    unauth_client.users.login(user_name, "unauth_password")

    # No login performed here, client is unauthenticated
    with pytest.raises(R2RException) as exc_info:
        unauth_client.collections.retrieve(user_owned_collection)
    assert exc_info.value.status_code in [
        401,
        403,
    ], "Unauthenticated user should not access collections."
An unauthenticated user should not be able to join or view
    collections.
py/tests/integration/test_collections_users_interaction.py