# Path: hbmqtt/plugins/manager.py
# class BaseContext:
#     def __init__(self):
#         self.loop = None
#         self.logger = None


import unittest
import logging
import os
import asyncio
from hbmqtt.plugins.manager import BaseContext
from hbmqtt.plugins.authentication import AnonymousAuthPlugin, FileAuthPlugin
from hbmqtt.session import Session
            'auth': {
                'allow-anonymous': False
            }
        }
        s = Session()
        s.username = ""
        auth_plugin = AnonymousAuthPlugin(context)
        ret = self.loop.run_until_complete(auth_plugin.authenticate(session=s))
        self.assertFalse(ret)

    def test_allow_nonanonymous(self):
        context = BaseContext()
        context.logger = logging.getLogger(__name__)
        context.config = {
            'auth': {
                'allow-anonymous': False
            }
        }
        s = Session()
        s.username = "test"
        auth_plugin = AnonymousAuthPlugin(context)
        ret = self.loop.run_until_complete(auth_plugin.authenticate(session=s))
        self.assertTrue(ret)


class TestFileAuthPlugin(unittest.TestCase):
    def setUp(self):
        self.loop = asyncio.new_event_loop()

    def test_allow(self):

# Path: hbmqtt/plugins/manager.py
# class BaseContext:
#     def __init__(self):
#         self.loop = None
#         self.logger = None


# Path: tests/plugins/test_authentication.py
import unittest
import logging
import os
import asyncio
from hbmqtt.plugins.manager import BaseContext
from hbmqtt.plugins.authentication import AnonymousAuthPlugin, FileAuthPlugin
from hbmqtt.session import Session

            'auth': {
                'allow-anonymous': False
            }
        }
        s = Session()
        s.username = ""
        auth_plugin = AnonymousAuthPlugin(context)
        ret = self.loop.run_until_complete(auth_plugin.authenticate(session=s))
        self.assertFalse(ret)

    def test_allow_nonanonymous(self):
        context = BaseContext()
        context.logger = logging.getLogger(__name__)
        context.config = {
            'auth': {
                'allow-anonymous': False
            }
        }
        s = Session()
        s.username = "test"
        auth_plugin = AnonymousAuthPlugin(context)
        ret = self.loop.run_until_complete(auth_plugin.authenticate(session=s))
        self.assertTrue(ret)


class TestFileAuthPlugin(unittest.TestCase):
    def setUp(self):
        self.loop = asyncio.new_event_loop()

    def test_allow(self):

        context = BaseContext()