Exemple #1
0
def test_login_as_demo_user_is_not_available_if_debug_mode_if_off(
        client, settings):
    settings.DEBUG = False
    settings.ALLOW_DEMO_LOGIN = True
    settings.DEMO_INSPECTOR_USERNAME = '******'
    utils.reload_urlconf()
    with pytest.raises(NoReverseMatch):
        reverse('demo-inspector')
Exemple #2
0
def test_demo_user_is_not_logged_in_if_username_not_in_setting(
        client, settings):
    settings.DEBUG = True
    settings.ALLOW_DEMO_LOGIN = True
    settings.DEMO_INSPECTOR_USERNAME = None
    utils.reload_urlconf()
    response = client.get(reverse('demo-inspector'), follow=True)
    assert response.status_code != 200
def reload_urls(mocker):
    mocker.patch.object(TelegramWebhookReceiver,
                        "webhook_connection_set",
                        return_value=True)
    reload_urlconf()
    resolved = resolve("/wagtail_live/telegram/events/telegram-token/")

    assert resolved.url_name == "telegram_events_handler"
Exemple #4
0
    def test_ok_with_saml2_views(self):
        with override_settings(RELATE_SIGN_IN_BY_SAML2_ENABLED=True):
            reload_urlconf()

            with self.temporarily_switch_to_user(None):
                # 'Settings' object has no attribute 'SAML_CONFIG'
                # with that error raised, we can confirm it is actually
                # requesting the view
                with self.assertRaises(AttributeError):
                    self.c.get(reverse("saml2_login"))
Exemple #5
0
    def test_ok_with_saml2_views(self):
        with override_settings(RELATE_SIGN_IN_BY_SAML2_ENABLED=True):
            reload_urlconf()

            with self.temporarily_switch_to_user(None):
                # 'Settings' object has no attribute 'SAML_CONFIG'
                # with that error raised, we can confirm it is actually
                # requesting the view
                with self.assertRaises(AttributeError):
                    self.c.get(reverse("saml2_login"))
Exemple #6
0
def test_urls_webhook_setup_error(caplog, mocker):
    mocker.patch.object(
        TelegramWebhookReceiver, "webhook_connection_set", return_value=False
    )
    mocker.patch.object(
        TelegramWebhookReceiver, "set_webhook", side_effect=WebhookSetupError
    )
    reload_urlconf()

    assert caplog.messages[0] == "Webhook setup failed"
Exemple #7
0
def test_demo_user_is_not_logged_in_if_staff(client, settings):
    settings.DEBUG = True
    settings.ALLOW_DEMO_LOGIN = True
    settings.DEMO_INSPECTOR_USERNAME = '******'
    utils.reload_urlconf()
    user = factories.UserFactory(username='******')
    user.is_superuser = False
    user.is_staff = True
    user.save()
    response = client.get(reverse('demo-inspector'), follow=True)
    assert response.status_code != 200
Exemple #8
0
def test_login_as_demo_user_is_not_available_if_setting_prevents(
        client, settings):
    settings.DEBUG = True
    settings.ALLOW_DEMO_LOGIN = False
    settings.DEMO_INSPECTOR_USERNAME = '******'
    utils.reload_urlconf()
    with pytest.raises(NoReverseMatch):
        reverse('demo-inspector')
    response = client.get('/demo-controleur/')
    assert response.status_code == 404
    response = client.get('/demo/')
    assert response.status_code == 404
Exemple #9
0
def test_demo_user_is_logged_in_when_requesting_demo_page(client, settings):
    settings.DEBUG = True
    settings.ALLOW_DEMO_LOGIN = True
    settings.DEMO_INSPECTOR_USERNAME = '******'
    utils.reload_urlconf()
    user = factories.UserFactory(username='******')
    user.is_superuser = False
    user.is_staff = False
    user.save()
    response = client.get(reverse('demo-inspector'), follow=True)
    assert response.status_code == 200
    session_user = response.context['user']
    assert session_user.is_authenticated
def reload_urls():
    reload_urlconf()
    resolved = resolve("/wagtail_live/slack/events")

    assert resolved.url_name == "slack_events_handler"
def reload_urls():
    reload_urlconf()
    resolved = resolve("/wagtail_live/get-updates/test_channel/")

    assert resolved.url_name == "long-polling"
Exemple #12
0
def test_urls_no_publisher(caplog):
    reload_urlconf()

    assert (
        caplog.messages[0] == "You haven't specified a live publisher in your settings."
    )