Conversation
awilfox
left a comment
There was a problem hiding this comment.
This looks great and should help with debugging AP-583 as well. r+ after tiny question.
awilfox
left a comment
There was a problem hiding this comment.
Ah, sorry, I didn't see the test failures. Looks like Rubocop has some suggestions, and we need to fix up the mock user objects in the other tests to have the required attributes. Still, I approve of the overall work - just need to fix those issues before merging.
anarchivist
left a comment
There was a problem hiding this comment.
agreed with @awilfox - this is looking good, but let's address the test failures before moving forward.
|
I added For the student ID value, since there is no However, after further review, I think we should not introduce a fallback for the If this is the case, a student might also not have an It seems we need a sample CalNet response for an actual student account to clarify the expected attributes. Based on that, we can decide how to properly update the current validation logic for studentID and employeeID, or we just eliminate to validate related attributes: I will rebase locally to fix the conflict tomorrow. |
|
@yzhoubk I agree that we should gather a real CalNet student response, anonymise it, and then use it as part of our testing. It would be beneficial to have both a student employee and a student non-employee to see how The overall direction of this MR looks good. I will review it in-depth when you are ready. |
|
The PR isn’t ready for review yet — I’m planning to refactor and restructure some of the code . |
|
@awilfox It's ready for review. I've added implementation notes in slack, please take a look. |
awilfox
left a comment
There was a problem hiding this comment.
A few minor typos, but otherwise looks great. Going to test against Rails 7.2 in a bit.
| # NOTE: berkeleyEduCSID should be same as berkeleyEduStuID for students | ||
| { | ||
| affiliations: get_attribute_from_auth(auth_extra, :affiliations), | ||
| cs_id: auth_extra['berkeleyEduCSID'], # Not included in CALNET_ATTRS because it's not used by any applications; Just keept it here. |
There was a problem hiding this comment.
| cs_id: auth_extra['berkeleyEduCSID'], # Not included in CALNET_ATTRS because it's not used by any applications; Just keept it here. | |
| cs_id: auth_extra['berkeleyEduCSID'], # Not included in CALNET_ATTRS because it's not used by any applications; Just keep it here. |
minor typo.
| end | ||
|
|
||
| def raise_missing_calnet_attribute_error(auth_extra, missing) | ||
| missing_attrs = "Expected Calnet attribute(s) not found (case-sensitive): #{missing.join(', ')}." |
There was a problem hiding this comment.
| missing_attrs = "Expected Calnet attribute(s) not found (case-sensitive): #{missing.join(', ')}." | |
| missing_attrs = "Expected CalNet attribute(s) not found (case-sensitive): #{missing.join(', ')}." |
spec/models/user_spec.rb
Outdated
| actual = %w[berkeleyEduAffiliations berkeleyEduAlternatid berkeleyEduCSID berkeleyEduIsMemberOf berkeleyEduUCPathID departmentNumber | ||
| displayName employeeNumber givenName surname uid] | ||
| # rubocop:disable Layout/LineLength | ||
| msg = "Expected Calnet attribute(s) not found (case-sensitive): #{missing.join(', ')}. The actual CalNet attributes: #{actual.join(', ')}. The user is expected display name" |
There was a problem hiding this comment.
| msg = "Expected Calnet attribute(s) not found (case-sensitive): #{missing.join(', ')}. The actual CalNet attributes: #{actual.join(', ')}. The user is expected display name" | |
| msg = "Expected CalNet attribute(s) not found (case-sensitive): #{missing.join(', ')}. The actual CalNet attributes: #{actual.join(', ')}. The user is expected display name" |
when the other fix is applied, this will need to be as well.
There was a problem hiding this comment.
Thanks for catching the typos!
|
Confirmed that this works on Rails 7.2 as well (applied atop #28). |
During Rails upgrade code review testing, we discovered users were missing email addresses. Investigation showed that a CalNet schema attribute had been renamed, though we were not notified when the change occurred. This ticket aims to address unexpected attribute changes from CalNet and improve our handling of schema updates.