Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for partial birthdates #4369

Merged
merged 3 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/saml/user_attributes/ssoe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def ssn

def birth_date
bd = safe_attr('va_eauth_birthDate_v1')
Date.parse(bd).strftime('%Y-%m-%d') if bd.present?
begin
Date.parse(bd).strftime('%Y-%m-%d')
rescue TypeError, ArgumentError
nil
end
end

def email
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/saml/ssoe_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@
end
end

context 'user with partial birth date' do
let(:saml_attributes) do
build(:ssoe_idme_loa3,
va_eauth_birthDate_v1: ['1980'])
end

it 'returns nil' do
expect(subject.to_hash[:birth_date]).to be_nil
end
end

context 'unproofed IDme LOA1 user' do
let(:saml_attributes) { build(:ssoe_idme_loa1_unproofed) }

Expand Down