Example #1
0
    def test_mail_creation(self):
        users_without_mail = [
            u for u in self.users_to_sync if u.User.email is None
        ]
        if not users_without_mail:
            raise RuntimeError(
                "Fixtures do not provide a syncable user without a mail address"
            )
        mod_user = users_without_mail[0].User
        mod_dn = UserRecord.from_db_user(mod_user, self.user_base_dn).dn
        mod_user.email = '*****@*****.**'
        session.add(mod_user)
        session.commit()

        users_to_sync = fetch_users_to_sync(session,
                                            self.config.required_property)
        exporter = self.build_user_exporter(current_users=self.new_ldap_users,
                                            desired_users=users_to_sync)
        exporter.compile_actions()
        relevant_actions = [
            a for a in exporter.actions if not isinstance(a, IdleAction)
        ]
        print(relevant_actions)
        self.assertEqual(len(relevant_actions), 1)
        self.assertEqual(type(relevant_actions[0]), ModifyAction)
        exporter.execute_all(self.conn)

        newest_users = fetch_current_ldap_users(self.conn,
                                                base_dn=self.user_base_dn)
        modified_ldap_record = self.get_by_dn(newest_users, mod_dn)
        self.assertIn('mail', modified_ldap_record['attributes'])
        self.assertEqual(modified_ldap_record['attributes']['mail'],
                         [mod_user.email])
Example #2
0
    def test_mail_deletion(self):
        users_with_mail = [
            u for u in self.users_to_sync if u.User.email is not None
        ]
        if not users_with_mail:
            raise RuntimeError(
                "Fixtures do not provide a syncable user with a mail address")

        modified_user = users_with_mail[0].User
        mod_dn = Record.from_db_user(modified_user, self.base_dn).dn
        modified_user.email = '*****@*****.**'
        session.add(modified_user)
        session.commit()

        self.users_to_sync = fetch_users_to_sync(session,
                                                 self.config.required_property)
        self.sync_all()

        newest_users = fetch_current_ldap_users(self.conn,
                                                base_dn=self.base_dn)
        newest_users_correct_dn = [
            u for u in newest_users if u['dn'] == mod_dn
        ]
        self.assertEqual(len(newest_users_correct_dn), 1)
        modified_record = newest_users_correct_dn[0]
        self.assertNotIn('mail', modified_record)
Example #3
0
 def test_correct_users_fetched(self):
     users = fetch_users_to_sync(session, required_property='mail')
     expected_logins = {
         complex_fixtures.UserData.active_user1.login,
         complex_fixtures.UserData.active_user2.login,
     }
     self.assertEqual({u.User.login for u in users}, expected_logins)
Example #4
0
 def test_correct_users_fetched(self):
     users = fetch_users_to_sync(session, required_property='mail')
     expected_logins = {
         complex_fixtures.UserData.active_user1.login,
         complex_fixtures.UserData.active_user2.login,
     }
     self.assertEqual({u.User.login for u in users}, expected_logins)
Example #5
0
 def setUp(self):
     super(LdapSyncerTestBase, self).setUp()
     self.users_to_sync = fetch_users_to_sync(session,
                                              self.config.required_property)
     self.initial_ldap_users = fetch_current_ldap_users(
         self.conn, base_dn=self.user_base_dn)
     self.groups_to_sync = fetch_groups_to_sync(session)
     self.initial_ldap_groups = fetch_current_ldap_groups(
         self.conn, base_dn=self.group_base_dn)
     self.properties_to_sync = fetch_properties_to_sync(session)
     self.initial_ldap_properties = fetch_current_ldap_properties(
         self.conn, base_dn=self.property_base_dn)
Example #6
0
    def test_mail_deletion(self):
        users_with_mail = [u for u in self.users_to_sync if u.User.email is not None]
        if not users_with_mail:
            raise RuntimeError("Fixtures do not provide a syncable user with a mail address")

        modified_user = users_with_mail[0].User
        mod_dn = Record.from_db_user(modified_user, self.base_dn).dn
        modified_user.email = '*****@*****.**'
        session.add(modified_user)
        session.commit()

        self.users_to_sync = fetch_users_to_sync(session, self.config.required_property)
        self.sync_all()

        newest_users = fetch_current_ldap_users(self.conn, base_dn=self.base_dn)
        newest_users_correct_dn = [u for u in newest_users if u['dn'] == mod_dn]
        self.assertEqual(len(newest_users_correct_dn), 1)
        modified_record = newest_users_correct_dn[0]
        self.assertNotIn('mail', modified_record)
Example #7
0
    def test_mail_deletion(self):
        users_with_mail = [
            u for u in self.users_to_sync if u.User.email is not None
        ]
        if not users_with_mail:
            raise RuntimeError(
                "Fixtures do not provide a syncable user with a mail address")

        modified_user = users_with_mail[0].User
        mod_dn = UserRecord.from_db_user(modified_user, self.user_base_dn).dn
        modified_user.email = '*****@*****.**'
        session.add(modified_user)
        session.commit()

        self.users_to_sync = fetch_users_to_sync(session,
                                                 self.config.required_property)
        self.sync_all()

        newest_users = fetch_current_ldap_users(self.conn,
                                                base_dn=self.user_base_dn)
        modified_record = self.get_by_dn(newest_users, mod_dn)
        assert 'mail' not in modified_record
Example #8
0
    def test_mail_creation(self):
        users_without_mail = [u for u in self.users_to_sync if u.User.email is None]
        if not users_without_mail:
            raise RuntimeError("Fixtures do not provide a syncable user without a mail address")
        mod_user = users_without_mail[0].User
        mod_dn = Record.from_db_user(mod_user, self.base_dn).dn
        mod_user.email = '*****@*****.**'
        session.add(mod_user)
        session.commit()

        users_to_sync = fetch_users_to_sync(session, self.config.required_property)
        exporter = self.build_exporter(current=self.new_ldap_users,
                                       desired=users_to_sync)
        exporter.compile_actions()
        relevant_actions = [a for a in exporter.actions if not isinstance(a, IdleAction)]
        print(relevant_actions)
        self.assertEqual(len(relevant_actions), 1)
        self.assertEqual(type(relevant_actions[0]), ModifyAction)
        exporter.execute_all(self.conn)

        newest_users = fetch_current_ldap_users(self.conn, base_dn=self.base_dn)
        modified_ldap_record = [u for u in newest_users if u['dn'] == mod_dn][0]
        self.assertIn('mail', modified_ldap_record['attributes'])
        self.assertEqual(modified_ldap_record['attributes']['mail'], [mod_user.email])
Example #9
0
 def setUp(self):
     super(EmptyDatabaseTestCase, self).setUp()
     self.users = fetch_users_to_sync(session)
Example #10
0
 def test_one_user_fetched(self):
     users = fetch_users_to_sync(session, required_property=self.PROPNAME)
     self.assertEqual(len(users), 1, f"Not a list of length one: {users}")
Example #11
0
 def test_no_users_fetched(self):
     self.assertEqual(fetch_users_to_sync(self.session), [])
Example #12
0
 def test_no_users_fetched(self):
     assert fetch_users_to_sync(self.session) == []
Example #13
0
 def test_one_user_fetched(self):
     users = fetch_users_to_sync(session, required_property='mail')
     self.assertEqual(len(users), 1)
Example #14
0
 def setUp(self):
     super(EmptyDatabaseTestCase, self).setUp()
     self.users = fetch_users_to_sync(session)
Example #15
0
 def test_one_user_fetched(self):
     users = fetch_users_to_sync(session, required_property='mail')
     self.assertEqual(len(users), 1)
Example #16
0
 def test_correct_users_fetched(self):
     users = fetch_users_to_sync(session, required_property='mail')
     expected_logins = {self.user1.login, self.user2.login}
     self.assertEqual({u.User.login for u in users}, expected_logins)
Example #17
0
 def setUp(self):
     super(LdapSyncerTestBase, self).setUp()
     self.users_to_sync = fetch_users_to_sync(session, self.config.required_property)
     self.initial_ldap_users = fetch_current_ldap_users(self.conn, base_dn=self.base_dn)