Esempio n. 1
0
    def test_update_user(self):
        u = User(
            username="******",
            email="*****@*****.**",
            password="******",
        )
        u.save()
        mock_ldap.reset()
        mock_ldap.set_return_value(
            'search_s',
            ('uid=bill,ou=users,dc=test', 0, '(objectClass=*)', None, 0),
            [('uid=bill,ou=users,dc=test', [
                ('objectClass', ['organizationalPerson', 'inetOrgPerson']),
                ('mail', ['*****@*****.**']),
                ('userPassword', ['{SSHA}QkJTQUxU']),
            ])])

        u.email = '*****@*****.**'
        u.save()
        self.assertEqual(mock_ldap.ldap_methods_called(), [
            'initialize', 'simple_bind_s', 'search_s', 'search_s', 'modify_s'
        ])
        self.assertEqual(
            mock_ldap.ldap_methods_called_with_arguments()[4][1], {
                'who': 'uid=bill,ou=users,dc=test',
                'attrs': [(1, 'mail', None), (0, 'mail', ['*****@*****.**'])]
            })
Esempio n. 2
0
    def test_update_user(self):
        u = User(username="******", email="*****@*****.**", password="******")
        u.save()
        mock_ldap.reset()
        mock_ldap.set_return_value(
            "search_s",
            ("uid=bill,ou=users,dc=test", 0, "(objectClass=*)", None, 0),
            [
                (
                    "uid=bill,ou=users,dc=test",
                    [
                        ("objectClass", ["organizationalPerson", "inetOrgPerson"]),
                        ("mail", ["*****@*****.**"]),
                        ("userPassword", ["{SSHA}QkJTQUxU"]),
                    ],
                )
            ],
        )

        u.email = "*****@*****.**"
        u.save()
        self.assertEqual(
            mock_ldap.ldap_methods_called(), ["initialize", "simple_bind_s", "search_s", "search_s", "modify_s"]
        )
        self.assertEqual(
            mock_ldap.ldap_methods_called_with_arguments()[4][1],
            {"who": "uid=bill,ou=users,dc=test", "attrs": [(1, "mail", None), (0, "mail", ["*****@*****.**"])]},
        )
Esempio n. 3
0
 def test_create_existing_user(self):
     mock_ldap.reset()
     u = User(username="******", email="*****@*****.**", password="******")
     u.save()
     self.assertEqual(
         mock_ldap.ldap_methods_called(), ["initialize", "simple_bind_s", "search_s", "search_s", "modify_s"]
     )
Esempio n. 4
0
 def test_create_existing_user(self):
     mock_ldap.reset()
     u = User(
         username="******",
         email="*****@*****.**",
         password="******",
     )
     u.save()
     self.assertEqual(mock_ldap.ldap_methods_called(), [
         'initialize',
         'simple_bind_s',
         'search_s',
         'search_s',
         'modify_s',
     ])
Esempio n. 5
0
 def test_create_new_user(self):
     mock_ldap.reset()
     u = User(username="******", email="*****@*****.**", password="******")
     u.save()
     self.assertEqual(mock_ldap.ldap_methods_called(), ["initialize", "simple_bind_s", "search_s", "add_s"])
     self.assertEqual(
         mock_ldap.ldap_methods_called_with_arguments()[3][1],
         {
             "who": "uid=fred,ou=users,dc=test",
             "attrs": [
                 ("objectClass", ["organizationalPerson", "inetOrgPerson"]),
                 ("mail", ["*****@*****.**"]),
                 ("userPassword", ["{SSHA}QkJTQUxU"]),
             ],
         },
     )
Esempio n. 6
0
 def test_create_new_user(self):
     mock_ldap.reset()
     u = User(
         username="******",
         email="*****@*****.**",
         password="******",
     )
     u.save()
     self.assertEqual(mock_ldap.ldap_methods_called(), [
         'initialize',
         'simple_bind_s',
         'search_s',
         'add_s',
     ])
     self.assertEqual(
         mock_ldap.ldap_methods_called_with_arguments()[3][1], {
             'who':
             'uid=fred,ou=users,dc=test',
             'attrs': [
                 ('objectClass', ['organizationalPerson', 'inetOrgPerson']),
                 ('mail', ['*****@*****.**']),
                 ('userPassword', ['{SSHA}QkJTQUxU']),
             ]
         })