def test_isubscriptions_link_unicode(monkeypatch):
    monkeypatch.setenv('feature.emails', 'true')
    monkeypatch.setenv('feature.async_search', 'true')

    app = flask_webtest.TestApp(dnstwister.app)
    emailer = dnstwister.views.www.email.emailer
    repository = dnstwister.repository

    assert emailer.sent_emails == []

    domain = u'\u0454a.com'  # ea.com, but with a funny 'e'
    hexdomain = dnstwister.tools.encode_domain(domain)
    subscribe_path = '/email/subscribe/{}'.format(hexdomain)

    search_page = app.get('/search?ed={}'.format(hexdomain))

    assert subscribe_path in search_page.body

    subscribe_page = app.get(subscribe_path)

    assert '\xd1\x94a.com (xn--a-9ub.com)' in subscribe_page.body

    subscribe_page.form['email_address'] = '*****@*****.**'
    pending_page = subscribe_page.form.submit()

    assert pending_page.request.url.endswith('pending_verify/786e2d2d612d3975622e636f6d')
    assert '\xd1\x94a.com (xn--a-9ub.com)' in pending_page.body

    assert list(repository.isubscriptions()) == []

    verify_code = repository.db.data.items()[0][0].split(
        'email_sub_pending:'
    )[1]
    verify_path = '/email/verify/{}'.format(
        verify_code
    )
    verify_url = 'http://localhost{}'.format(verify_path)

    assert len(emailer.sent_emails) == 1

    sent_email = emailer.sent_emails[0][:2]

    assert sent_email == (
        '*****@*****.**', 'Please verify your subscription'
    )

    assert verify_url in emailer.sent_emails[0][2]

    subscribed_page = app.get(verify_path)

    assert 'You are now subscribed' in subscribed_page.body
    assert '\xd1\x94a.com (xn--a-9ub.com)' in subscribed_page.body

    assert len(list(repository.isubscriptions())) == 1
def test_isubscriptions_link(monkeypatch):
    monkeypatch.setenv('feature.emails', 'true')
    monkeypatch.setenv('feature.async_search', 'true')

    app = flask_webtest.TestApp(dnstwister.app)
    emailer = dnstwister.views.www.email.emailer
    repository = dnstwister.repository

    assert emailer.sent_emails == []

    domain = 'a.com'
    hexdomain = dnstwister.tools.encode_domain(domain)
    subscribe_path = '/email/subscribe/{}'.format(hexdomain)

    search_page = app.get('/search?ed={}'.format(hexdomain))

    assert subscribe_path in search_page.body

    subscribe_page = app.get(subscribe_path)

    subscribe_page.form['email_address'] = '*****@*****.**'
    subscribe_page.form.submit()

    assert list(repository.isubscriptions()) == []

    verify_code = repository.db.data.items()[0][0].split(
        'email_sub_pending:'
    )[1]
    verify_path = '/email/verify/{}'.format(
        verify_code
    )
    verify_url = 'http://localhost{}'.format(verify_path)

    assert len(emailer.sent_emails) == 1

    sent_email = emailer.sent_emails[0][:2]

    assert sent_email == (
        '*****@*****.**', 'Please verify your subscription'
    )

    assert verify_url in emailer.sent_emails[0][2]

    subscribed_page = app.get(verify_path)

    assert 'You are now subscribed' in subscribed_page.body

    assert len(list(repository.isubscriptions())) == 1
def vcscontroller(pylonsapp, config_stub):
    config_stub.testing_securitypolicy()
    config_stub.include('rhodecode.authentication')

    set_anonymous_access(True)
    controller = StubVCSController(pylonsapp, pylonsapp.config)
    app = HttpsFixup(controller, pylonsapp.config)
    app = webtest.app.TestApp(app)

    _remove_default_user_from_query_cache()

    # Sanity checks that things are set up correctly
    app.get('/' + HG_REPO, status=200)

    app.controller = controller
    return app
Exemple #4
0
def test_isubscriptions_link():
    app = flask.ext.webtest.TestApp(dnstwister.app)
    emailer = dnstwister.views.www.email.emailer
    repository = dnstwister.repository

    assert emailer.sent_emails == []

    domain = 'a.com'
    hexdomain = binascii.hexlify(domain)
    subscribe_path = '/email/subscribe/{}'.format(hexdomain)

    search_page = app.get('/search/{}'.format(hexdomain))

    assert subscribe_path in search_page.body

    subscribe_page = app.get(subscribe_path)

    subscribe_page.form['email_address'] = '*****@*****.**'
    subscribe_page.form.submit()

    assert list(repository.isubscriptions()) == []

    verify_code = repository.db.data.items()[0][0].split(
        'email_sub_pending:'
    )[1]
    verify_path = '/email/verify/{}'.format(
        verify_code
    )
    verify_url = 'http://*****:*****@b.com', 'Please verify your subscription'
    )

    assert verify_url in emailer.sent_emails[0][2]

    subscribed_page = app.get(verify_path)

    assert 'You are now subscribed' in subscribed_page.body

    assert len(list(repository.isubscriptions())) == 1
def test_isubscriptions_link():
    app = flask.ext.webtest.TestApp(dnstwister.app)
    emailer = dnstwister.views.www.email.emailer
    repository = dnstwister.repository

    assert emailer.sent_emails == []

    domain = 'a.com'
    hexdomain = binascii.hexlify(domain)
    subscribe_path = '/email/subscribe/{}'.format(hexdomain)

    search_page = app.get('/search/{}'.format(hexdomain))

    assert subscribe_path in search_page.body

    subscribe_page = app.get(subscribe_path)

    subscribe_page.form['email_address'] = '*****@*****.**'
    subscribe_page.form.submit()

    assert list(repository.isubscriptions()) == []

    verify_code = repository.db.data.items()[0][0].split(
        'email_sub_pending:'
    )[1]
    verify_path = '/email/verify/{}'.format(
        verify_code
    )
    verify_url = 'http://*****:*****@b.com', 'Please verify your subscription'
    )

    assert verify_url in emailer.sent_emails[0][2]

    subscribed_page = app.get(verify_path)

    assert 'You are now subscribed' in subscribed_page.body

    assert len(list(repository.isubscriptions())) == 1
Exemple #6
0
def test_unsubscribe_unicode():
    """Test can unsubscribe."""
    app = flask_webtest.TestApp(dnstwister.app)
    repository = dnstwister.repository

    domain = u'www.\u0454xample.com'
    email = '*****@*****.**'
    sub_id = '1234'

    assert len(list(repository.isubscriptions())) == 0

    repository.subscribe_email(sub_id, email, domain, False)

    assert len(list(repository.isubscriptions())) == 1

    app.get('/email/unsubscribe/{}'.format(sub_id))

    assert len(list(repository.isubscriptions())) == 0
def test_unsubscribe():
    """Test can unsubscribe."""
    app = flask.ext.webtest.TestApp(dnstwister.app)
    repository = dnstwister.repository

    domain = 'www.example.com'
    email = '*****@*****.**'
    sub_id = '1234'

    assert len(list(repository.isubscriptions())) == 0

    repository.subscribe_email(sub_id, email, domain)

    assert len(list(repository.isubscriptions())) == 1

    app.get('/email/unsubscribe/{}'.format(sub_id))

    assert len(list(repository.isubscriptions())) == 0
def test_no_subscribe_links_without_emails_enabled(monkeypatch):
    monkeypatch.setenv('feature.async_search', 'true')
    app = flask_webtest.TestApp(dnstwister.app)

    domain = 'a.com'
    hexdomain = dnstwister.tools.encode_domain(domain)

    search_page = app.get('/search?ed={}'.format(hexdomain))

    assert '/email/subscribe/' not in search_page.body
Exemple #9
0
def test_email_address_required():
    app = flask.ext.webtest.TestApp(dnstwister.app)

    domain = 'a.com'
    hexdomain = binascii.hexlify(domain)
    subscribe_path = '/email/subscribe/{}'.format(hexdomain)

    subscribe_page = app.get(subscribe_path)

    assert 'Email address is required' not in subscribe_page.body

    subscribe_page.form['email_address'] = ' '
    response = subscribe_page.form.submit()

    assert response.status_code == 302
    assert response.headers['location'] == 'http://localhost:80/email/subscribe/{}/0'.format(hexdomain)

    assert 'Email address is required' in response.follow().body
def test_email_address_required():
    app = flask.ext.webtest.TestApp(dnstwister.app)

    domain = 'a.com'
    hexdomain = binascii.hexlify(domain)
    subscribe_path = '/email/subscribe/{}'.format(hexdomain)

    subscribe_page = app.get(subscribe_path)

    assert 'Email address is required' not in subscribe_page.body

    subscribe_page.form['email_address'] = ' '
    response = subscribe_page.form.submit()

    assert response.status_code == 302
    assert response.headers['location'] == 'http://localhost:80/email/subscribe/{}/0'.format(hexdomain)

    assert 'Email address is required' in response.follow().body
Exemple #11
0
def test_email_address_validation_remembers_hide_noisy_flag():
    app = flask_webtest.TestApp(dnstwister.app)

    domain = 'a.com'
    hexdomain = binascii.hexlify(domain)
    subscribe_path = '/email/subscribe/{}'.format(hexdomain)

    subscribe_page = app.get(subscribe_path)

    subscribe_page.form['email_address'] = ' '
    subscribe_page.form['hide_noisy'] = 'true'
    response = subscribe_page.form.submit()

    assert response.status_code == 302
    assert response.headers[
        'location'] == 'http://localhost/email/subscribe/{}/0?hide_noisy=True'.format(
            hexdomain)

    assert 'Email address is required' in response.follow().body
def test_email_address_required(monkeypatch):
    monkeypatch.setenv('feature.emails', 'true')

    app = flask_webtest.TestApp(dnstwister.app)

    domain = 'a.com'
    hexdomain = binascii.hexlify(domain)
    subscribe_path = '/email/subscribe/{}'.format(hexdomain)

    subscribe_page = app.get(subscribe_path)

    assert 'Email address is required' not in subscribe_page.body

    subscribe_page.form['email_address'] = ' '
    response = subscribe_page.form.submit()

    assert response.status_code == 302
    assert response.headers['location'] == 'http://localhost/email/subscribe/{}/0?hide_noisy=False'.format(hexdomain)

    assert 'Email address is required' in response.follow().body