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

ENG-462: Allow GPA email addresses to log in and request new users and accounts #358

Merged
merged 1 commit into from
Sep 9, 2024
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
3 changes: 3 additions & 0 deletions app/lib/email_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def self.email_is_allowed_basic?(email)
end
return true if email.end_with? '@digital.cabinet-office.gov.uk'
return true if email.end_with? '@cabinetoffice.gov.uk'
return true if email.end_with? '@gpa.gov.uk'
return true if email.end_with? '@softwire.com'
return true if email.end_with? '@fidusinfosec.com'
return true if email.end_with? '@cyberis.com'
Expand All @@ -21,6 +22,7 @@ def self.email_is_allowed_advanced?(email)
end
return true if email.end_with? '@digital.cabinet-office.gov.uk'
return true if email.end_with? '@cabinetoffice.gov.uk'
return true if email.end_with? '@gpa.gov.uk'
false
end

Expand All @@ -29,6 +31,7 @@ def self.allowed_emails_regexp
/\A(#{Regexp.union(
/([a-z0-9.\-\']+@digital\.cabinet-office\.gov\.uk,?\s*)/,
/([a-z0-9.\-\']+@cabinetoffice\.gov\.uk,?\s*)/,
/([a-z0-9.\-\']+@gpa\.gov\.uk,?\s*)/,
/([a-z0-9.\-\']+@softwire\.com,?\s*)/,
/([a-z0-9.\-\']+@fidusinfosec\.com,?\s*)/,
/([a-z0-9.\-\']+@cyberis\.com,?\s*)/,
Expand Down
15 changes: 15 additions & 0 deletions test/lib/email_validator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ class EmailValidatorTest < ActiveSupport::TestCase
assert EmailValidator.email_is_allowed_basic?(email)
end

test 'Government Property Agency email addresses are allowed to sign in' do
email = '[email protected]'
assert EmailValidator.email_is_allowed_basic?(email)
end

test 'Softwire email addresses are allowed to sign in' do
email = '[email protected]'
assert EmailValidator.email_is_allowed_basic?(email)
Expand Down Expand Up @@ -46,6 +51,11 @@ class EmailValidatorTest < ActiveSupport::TestCase
assert EmailValidator.email_is_allowed_advanced?(email)
end

test 'Government Property Agency email addresses are allowed to manage users' do
email = '[email protected]'
assert EmailValidator.email_is_allowed_advanced?(email)
end

test 'Softwire email addresses are not allowed to manage users' do
email = '[email protected]'
assert ! EmailValidator.email_is_allowed_advanced?(email)
Expand Down Expand Up @@ -76,6 +86,11 @@ class EmailValidatorTest < ActiveSupport::TestCase
assert_match EmailValidator.allowed_emails_regexp, email
end

test 'Government Property Agency emails can be used as usernames for new users' do
email = '[email protected]'
assert_match EmailValidator.allowed_emails_regexp, email
end

test 'Softwire emails are matched by the allowed emails regexp' do
email = '[email protected]'
assert_match EmailValidator.allowed_emails_regexp, email
Expand Down
Loading