Skip to content

Commit 8ac37a3

Browse files
committed
Added some normalisation of the reg_type and ticket_type entries in the OIDC registration scope.
- Legacy-Id: 18301
1 parent 5d29677 commit 8ac37a3

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

ietf/ietfauth/tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,14 @@ def test_oidc_code_auth(self):
847847
self.assertIn('full_week', set(userinfo['ticket_type'].split()))
848848
self.assertIn('Some Company', userinfo['affiliation'])
849849

850+
# Create a third registration, with a composite reg type
851+
MeetingRegistration.objects.create(
852+
meeting=meeting, person=None, first_name=person.first_name(), last_name=person.last_name(),
853+
email=email_list[1], ticket_type='one_day', reg_type='hackathon remote', affiliation='Some Company, Inc',
854+
)
855+
userinfo = client.do_user_info_request(state=params["state"], scope=args['scope'])
856+
self.assertEqual(set(userinfo['reg_type'].split()), set(['remote', 'hackathon']))
857+
850858
# Check that ending a session works
851859
r = client.do_end_session_request(state=params["state"], scope=args['scope'])
852860
self.assertEqual(r.status_code, 302)

ietf/ietfauth/utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,19 @@ def scope_registration(self):
268268
reg.attended = True
269269
reg.save()
270270
# fill in info to return
271+
ticket_types = set([])
272+
reg_types = set([])
273+
for reg in regs:
274+
for t in reg.ticket_type.split():
275+
ticket_types.add(t)
276+
for r in reg.reg_type.split():
277+
reg_types.add(r)
271278
info = {
272279
'meeting': meeting.number,
273280
# full_week, one_day, student:
274-
'ticket_type': ' '.join(set( reg.ticket_type for reg in regs )),
281+
'ticket_type': ' '.join(ticket_types),
275282
# in_person, onliine, hackathon:
276-
'reg_type': ' '.join(set( reg.reg_type for reg in regs )),
283+
'reg_type': ' '.join(reg_types),
277284
'affiliation': ([ reg.affiliation for reg in regs if reg.affiliation ] or [''])[0],
278285
}
279286

0 commit comments

Comments
 (0)