Esempio n. 1
0
def test_hcaptcha_disabled():
    hcaptcha = hCaptcha(site_key="SITE_KEY",
                        secret_key="SECRET_KEY",
                        is_enabled=False)
    assert hcaptcha.is_enabled == False
    assert hcaptcha.get_code() == ""
    assert hcaptcha.verify(response="None", remote_ip="0.0.0.0") == True
def test_hcaptcha_disabled_flask():
    app.config.update({
        "RECAPTCHA_ENABLED": False
    })
    hcaptcha = hCaptcha(app=app)
    assert hcaptcha.is_enabled == False
    assert hcaptcha.get_code() == ""
    assert hcaptcha.verify(response="None", remote_ip="0.0.0.0") == True
Esempio n. 3
0
from flask import Flask
from config import Config
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager
import logging
from logging.handlers import SMTPHandler, RotatingFileHandler
from flask_hcaptcha import hCaptcha

app = Flask(__name__)
app.config.from_object(Config)
db = SQLAlchemy(app)
migrate = Migrate(app, db, render_as_batch=True, compare_type=True)
login = LoginManager(app)
login.login_view = 'login'
hcaptcha = hCaptcha(app)

from app import routes, models, errors
app.config['TEMPLATES_AUTO_RELOAD'] = True

if not app.debug:
    if app.config['MAIL_SERVER']:
        auth = None
        if app.config['MAIL_USERNAME'] or app.config['MAIL_PASSWORD']:
            auth = (app.config['MAIL_USERNAME'], app.config['MAIL_PASSWORD'])
        secure = None
        if app.config['MAIL_USE_TLS']:
            secure = ()
        mail_handler = SMTPHandler(
            mailhost=(app.config['MAIL_SERVER'], app.config['MAIL_PORT']),
            fromaddr='no-reply@' + app.config['MAIL_SERVER'],
def test_hcaptcha_enabled_flask():
    hcaptcha = hCaptcha(app=app)
    assert isinstance(hcaptcha, hCaptcha)
    assert hcaptcha.is_enabled == True
    assert "script" in hcaptcha.get_code()
    assert hcaptcha.verify(response="None", remote_ip="0.0.0.0") == False
def test_hcaptcha_enabled():
    hcaptcha = hCaptcha(site_key="SITE_KEY", secret_key="SECRET_KEY")
    assert isinstance(hcaptcha, hCaptcha)
    assert hcaptcha.is_enabled == True
    assert "script" in hcaptcha.get_code()
    assert hcaptcha.verify(response="None", remote_ip="0.0.0.0") == False
Esempio n. 6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#
# Module for hcaptcha verifications
#

from flask_hcaptcha import hCaptcha

hcaptcha = hCaptcha()