Skip to content

Commit b92ed28

Browse files
author
Carolyn Ranti
committed
Add test for updating user with an empty attribute
1 parent c658b52 commit b92ed28

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/testprofiles/tests.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,25 @@ def test_update_user_callable_attributes(self):
8989
self.assertEquals(user.email, '[email protected]')
9090
self.assertEquals(user.first_name, 'John')
9191
self.assertEquals(user.last_name, 'Doe')
92+
93+
def test_update_user_empty_attribute(self):
94+
user = User.objects.create(username='john', last_name='Smith')
95+
96+
backend = Saml2Backend()
97+
attribute_mapping = {
98+
'uid': ('username', ),
99+
'mail': ('email', ),
100+
'cn': ('first_name', ),
101+
'sn': ('last_name', ),
102+
}
103+
attributes = {
104+
'uid': ('john', ),
105+
'mail': ('[email protected]', ),
106+
'cn': ('John', ),
107+
'sn': (),
108+
}
109+
backend.update_user(user, attributes, attribute_mapping)
110+
self.assertEquals(user.email, '[email protected]')
111+
self.assertEquals(user.first_name, 'John')
112+
# empty attribute list: no update
113+
self.assertEquals(user.last_name, 'Smith')

0 commit comments

Comments
 (0)