|
21 | 21 | expect { User.from_omniauth(auth) }.to raise_error(Error::InvalidAuthProviderError) |
22 | 22 | end |
23 | 23 |
|
24 | | - it 'rejects calnet when a required schema attribute is missing or renamed' do |
| 24 | + it 'logs a warning when a required schema attribute is missing or renamed' do |
25 | 25 | auth = { |
26 | 26 | 'provider' => 'calnet', |
27 | 27 | 'extra' => { |
|
43 | 43 | actual = %w[berkeleyEduAffiliations berkeleyEduAlternatid berkeleyEduCSID berkeleyEduIsMemberOf berkeleyEduUCPathID departmentNumber |
44 | 44 | displayName employeeNumber givenName surname uid] |
45 | 45 | # rubocop:disable Layout/LineLength |
46 | | - msg = "Expected CalNet attribute(s) not found (case-sensitive): #{missing.join(', ')}. The actual CalNet attributes: #{actual.join(', ')}. The user is expected display name" |
| 46 | + msg = "Expected CalNet attribute(s) not found (case-sensitive): #{missing.join(', ')}. The actual CalNet attributes: #{actual.join(', ')}. The user is expected UID" |
47 | 47 | # rubocop:enable Layout/LineLength |
48 | | - expect { User.from_omniauth(auth) }.to raise_error(Error::CalnetError, msg) |
| 48 | + expect(Rails.logger).to receive(:info).with(msg) |
| 49 | + User.from_omniauth(auth) |
49 | 50 | end |
50 | 51 |
|
51 | 52 | it 'populates a User object' do |
|
198 | 199 | expect { User.from_omniauth({ 'provider' => 'calnet', 'extra' => auth_extra }) }.not_to raise_error |
199 | 200 | end |
200 | 201 |
|
201 | | - it 'rejects student-affiliated users if berkeleyEduStuID is missing' do |
| 202 | + it 'logs missing berkeleyEduStuID for student-affiliated users' do |
202 | 203 | auth_extra = { |
203 | 204 | 'berkeleyEduAffiliations' => ['STUDENT-TYPE-REGISTERED'], |
204 | 205 | 'berkeleyEduCSID' => 'cs123', |
|
211 | 212 | 'uid' => 'student1' |
212 | 213 | } |
213 | 214 |
|
214 | | - expect { User.from_omniauth({ 'provider' => 'calnet', 'extra' => auth_extra }) }.to raise_error(Error::CalnetError) |
| 215 | + expect(Rails.logger).to receive(:info).with(/berkeleyEduStuID/) |
| 216 | + User.from_omniauth({ 'provider' => 'calnet', 'extra' => auth_extra }) |
215 | 217 | end |
216 | 218 |
|
217 | | - it 'rejects employee-affiliated users if employeeNumber is missing' do |
| 219 | + it 'logs missing employeeNumber for employee-affiliated users' do |
218 | 220 | auth_extra = { |
219 | 221 | 'berkeleyEduAffiliations' => ['EMPLOYEE-TYPE-STAFF'], |
220 | 222 | 'berkeleyEduCSID' => 'cs123', |
|
228 | 230 | 'uid' => 'staff1' |
229 | 231 | } |
230 | 232 |
|
231 | | - expect { User.from_omniauth({ 'provider' => 'calnet', 'extra' => auth_extra }) }.to raise_error(Error::CalnetError) |
| 233 | + expect(Rails.logger).to receive(:info).with(/employeeNumber/) |
| 234 | + User.from_omniauth({ 'provider' => 'calnet', 'extra' => auth_extra }) |
232 | 235 | end |
233 | 236 | end |
234 | 237 |
|
|
0 commit comments