Example #1
0
def test_redis_event_manager_publish():
    """Test that RedisEventManager publishing to clients works."""
    class RedisConfig(TestingConfig):
        REDIS_URL = "redis://localhost:6379/3"
        CACHE_REDIS_URL = "redis://localhost:6379/3"
        CACHE_TYPE = "redis"

    try:
        app = create_ctfd(config=RedisConfig)
    except ConnectionError:
        print("Failed to connect to redis. Skipping test.")
    else:
        with app.app_context():
            saved_data = {
                "user_id": None,
                "title": "asdf",
                "content": "asdf",
                "team_id": None,
                "user": None,
                "team": None,
                "date": "2019-01-28T01:20:46.017649+00:00",
                "id": 10,
            }

            event_manager = RedisEventManager()
            event_manager.publish(data=saved_data,
                                  type="notification",
                                  channel="ctf")
        destroy_ctfd(app)
Example #2
0
def test_redis_event_manager_publish():
    """Test that RedisEventManager publishing to clients works."""

    # TODO: This test is flaky.
    class RedisConfig(TestingConfig):
        REDIS_URL = 'redis://localhost:6379'
        CACHE_REDIS_URL = 'redis://localhost:6379'
        CACHE_TYPE = 'redis'

    try:
        app = create_ctfd(config=RedisConfig)
        with app.app_context():
            saved_data = {
                'user_id': None,
                'title': 'asdf',
                'content': 'asdf',
                'team_id': None,
                'user': None,
                'team': None,
                'date': '2019-01-28T01:20:46.017649+00:00',
                'id': 10
            }

            event_manager = RedisEventManager()
            event_manager.publish(data=saved_data,
                                  type='notification',
                                  channel='ctf')
        destroy_ctfd(app)
    except ConnectionError:
        print("Failed to connect to redis. Skipping test.")