fix shadowExpire deserialization
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Max Erenberg 2022-09-10 15:53:14 -04:00
parent 3cc9b011c3
commit 779e35a08e
4 changed files with 7 additions and 8 deletions

View File

@ -221,7 +221,7 @@ kinit
# Make the request
curl --negotiate -u : --service-name ceod --delegation always \
-d '{"uid":"test_1","cn":"Test One","given_name":"Test","sn":"One","program":"Math","terms":["s2021"]}' \
-X POST https://phosphoric-acid:9987/api/members
-X POST https://phosphoric-acid.csclub.uwaterloo.ca:9987/api/members
```
## Packaging

View File

@ -86,7 +86,6 @@ class User:
'is_club': self.is_club(),
'is_club_rep': self.is_club_rep,
'program': self.program or 'Unknown',
'shadowExpire': self.shadowExpire,
}
if self.sn and self.given_name:
data['sn'] = self.sn
@ -103,6 +102,8 @@ class User:
data['mail_local_addresses'] = self.mail_local_addresses
if get_forwarding_addresses:
data['forwarding_addresses'] = self.get_forwarding_addresses()
if self.shadowExpire:
data['shadow_expire'] = self.shadowExpire
return data
def __repr__(self) -> str:
@ -169,7 +170,7 @@ class User:
is_club_rep=attrs.get('isClubRep', [False])[0],
is_club=('club' in attrs['objectClass']),
is_member_or_club_rep=('member' in attrs['objectClass']),
shadowExpire=attrs.get('shadowExpire'),
shadowExpire=attrs.get('shadowExpire', [None])[0],
ldap3_entry=entry,
)

View File

@ -72,7 +72,6 @@ def test_api_create_user(cfg, create_user_resp, mock_mail_server):
"mail_local_addresses": ["test1@csclub.internal"],
"forwarding_addresses": ['test1@uwaterloo.internal'],
"password": "krb5",
"shadowExpire": None,
}},
]
assert data == expected
@ -285,14 +284,14 @@ def test_expire(client, new_user, term_attr, ldap_conn):
assert (data == [uid]) == should_expire
_, user = client.get(f'/api/members/{uid}')
assert user['shadowExpire'] is None
assert 'shadow_expire' not in user
status, data = client.post('/api/members/expire')
assert status == 200
assert (data == [uid]) == should_expire
_, user = client.get(f'/api/members/{uid}')
assert (user['shadowExpire'] is not None) == should_expire
assert (user.get('shadow_expire') == 1) == should_expire
if not should_expire:
continue
@ -302,7 +301,7 @@ def test_expire(client, new_user, term_attr, ldap_conn):
assert status == 200
_, user = client.get(f'/api/members/{uid}')
assert user['shadowExpire'] is None
assert 'shadow_expire' not in user
reset_terms()

View File

@ -173,7 +173,6 @@ def test_user_to_dict(cfg):
'home_directory': user.home_directory,
'is_club': False,
'is_club_rep': False,
'shadowExpire': None,
}
assert user.to_dict() == expected