Ejemplo n.º 1
0
    def testMessage(self):
        """
        This simulates the 'test' application that keeps its own data in the 'user' collection in the 'test' DB
        and sends a message notifying the attribute manager instance (am) about a new entry in its dataset thereby
        calling the plugin (above) which is registered with the am in the test setup below.
        """
        settings = {
            'BROKER_TRANSPORT': 'memory',
            'BROKER_URL': 'memory://',
            'CELERY_EAGER_PROPAGATES_EXCEPTIONS': True,
            'CELERY_ALWAYS_EAGER': True,
            'CELERY_RESULT_BACKEND': "cache",
            'CELERY_CACHE_BACKEND': 'memory',
            'MONGO_URI': 'mongodb://*****:*****@eduid.se')
        user = am.get_user_by_field('eppn', '*****@*****.**')
        assert (user['_id'] == attrs['_id'])
Ejemplo n.º 2
0
    def testMessage(self):
        """
        This simulates the 'test' application that keeps its own data in the 'user' collection in the 'test' DB
        and sends a message notifying the attribute manager instance (am) about a new entry in its dataset thereby
        calling the plugin (above) which is registered with the am in the test setup below.
        """
        settings = {
            'BROKER_TRANSPORT': 'memory',
            'BROKER_URL': 'memory://',
            'CELERY_EAGER_PROPAGATES_EXCEPTIONS': True,
            'CELERY_ALWAYS_EAGER': True,
            'CELERY_RESULT_BACKEND': "cache",
            'CELERY_CACHE_BACKEND': 'memory',
            'MONGO_URI': 'mongodb://*****:*****@eduid.se')
        user = am.get_user_by_field('eppn', '*****@*****.**')
        assert(user['_id'] == attrs['_id'])
Ejemplo n.º 3
0
    def __init__(self, settings):

        am_settings = {'MONGO_URI': settings['mongo_uri_am']}

        mongo_replicaset = settings.get('mongo_replicaset', None)

        if mongo_replicaset is not None:
            am_settings['replicaSet'] = mongo_replicaset

        celery.conf.update(am_settings)
        self._db = get_attribute_manager(celery)
        self.settings = settings
        self.user_main_attribute = settings.get('saml2.user_main_attribute',
                                                'mail')
        # provide access to our backends exceptions to users of this class
        self.exceptions = eduid_am.exceptions
Ejemplo n.º 4
0
    def setUp(self):
        super(MongoTestCase, self).setUp()
        self.tmp_db = MongoTemporaryInstance.get_instance()
        self.conn = self.tmp_db.conn
        self.port = self.tmp_db.port
        self.am_settings = {
            'BROKER_TRANSPORT': 'memory',
            'BROKER_URL': 'memory://',
            'CELERY_EAGER_PROPAGATES_EXCEPTIONS': True,
            'CELERY_ALWAYS_EAGER': True,
            'CELERY_RESULT_BACKEND': "cache",
            'CELERY_CACHE_BACKEND': 'memory',
            'MONGO_URI': 'mongodb://localhost:%d/' % self.port,
            'MONGO_DBNAME': 'am',
        }

        celery.conf.update(self.am_settings)
        self.am = get_attribute_manager(celery)

        for db_name in self.conn.database_names():
            self.conn.drop_database(db_name)

        mongo_settings = {
                'mongo_replicaset': None,
                'mongo_uri_am': self.am_settings['MONGO_URI'] + 'am',
            }


        if getattr(self, 'settings', None) is None:
            self.settings = mongo_settings
        else:
            self.settings.update(mongo_settings)

        mongo_replicaset = self.settings.get('mongo_replicaset', None)

        self.amdb = self.am.conn.get_database('am')
        self.userdb = self.MockedUserDB(self.users)

        self.initial_verifications = (getattr(self, 'initial_verifications', None)
                                      or INITIAL_VERIFICATIONS)
        self.amdb.attributes.drop()

        userdocs = []
        for userdoc in self.userdb.all_userdocs():
            userdocs.append(deepcopy(userdoc))

        self.amdb.attributes.insert(userdocs)
Ejemplo n.º 5
0
    def setUp(self):
        super(MongoTestCase, self).setUp()
        self.tmp_db = MongoTemporaryInstance.get_instance()
        self.conn = self.tmp_db.conn
        self.port = self.tmp_db.port
        self.am_settings = {
            'BROKER_TRANSPORT': 'memory',
            'BROKER_URL': 'memory://',
            'CELERY_EAGER_PROPAGATES_EXCEPTIONS': True,
            'CELERY_ALWAYS_EAGER': True,
            'CELERY_RESULT_BACKEND': "cache",
            'CELERY_CACHE_BACKEND': 'memory',
            'MONGO_URI': 'mongodb://localhost:%d/' % self.port,
            'MONGO_DBNAME': 'am',
        }

        celery.conf.update(self.am_settings)
        self.am = get_attribute_manager(celery)

        for db_name in self.conn.database_names():
            self.conn.drop_database(db_name)

        mongo_settings = {
            'mongo_replicaset': None,
            'mongo_uri_am': self.am_settings['MONGO_URI'] + 'am',
        }

        if getattr(self, 'settings', None) is None:
            self.settings = mongo_settings
        else:
            self.settings.update(mongo_settings)

        mongo_replicaset = self.settings.get('mongo_replicaset', None)

        self.amdb = self.am.conn.get_database('am')
        self.userdb = self.MockedUserDB(self.users)

        self.initial_verifications = (getattr(self, 'initial_verifications',
                                              None) or INITIAL_VERIFICATIONS)
        self.amdb.attributes.drop()

        userdocs = []
        for userdoc in self.userdb.all_userdocs():
            userdocs.append(deepcopy(userdoc))

        self.amdb.attributes.insert(userdocs)