Skip to content

Commit

Permalink
Merge pull request #385 from alphagov/ENG-516-add-ipa.gov.uk-email-do…
Browse files Browse the repository at this point in the history
…main-to-raat

Add ipa.gov.uk email domain to allowed list for RAAT
  • Loading branch information
HauwaHakimi authored Nov 1, 2024
2 parents b79d1d2 + 663a646 commit 9dd36cf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/lib/email_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def self.email_is_allowed_basic?(email)
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? '@ipa.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 @@ -23,6 +24,7 @@ def self.email_is_allowed_advanced?(email)
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? '@ipa.gov.uk'
false
end

Expand All @@ -32,6 +34,7 @@ def self.allowed_emails_regexp
/([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.\-\']+@ipa\.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 @@ -16,6 +16,11 @@ class EmailValidatorTest < ActiveSupport::TestCase
assert EmailValidator.email_is_allowed_basic?(email)
end

test 'Infrastructure and Projects Authority email addresses are allowed to sign in' do
email = 'fname.lname@ipa.gov.uk'
assert EmailValidator.email_is_allowed_basic?(email)
end

test 'Softwire email addresses are allowed to sign in' do
email = 'fname.lname@softwire.com'
assert EmailValidator.email_is_allowed_basic?(email)
Expand Down Expand Up @@ -56,6 +61,11 @@ class EmailValidatorTest < ActiveSupport::TestCase
assert EmailValidator.email_is_allowed_advanced?(email)
end

test 'Infrastructure and Projects Authority email addresses are allowed to manage users' do
email = 'fname.lname@ipa.gov.uk'
assert EmailValidator.email_is_allowed_advanced?(email)
end

test 'Softwire email addresses are not allowed to manage users' do
email = 'fname.lname@softwire.com'
assert ! EmailValidator.email_is_allowed_advanced?(email)
Expand Down Expand Up @@ -91,6 +101,11 @@ class EmailValidatorTest < ActiveSupport::TestCase
assert_match EmailValidator.allowed_emails_regexp, email
end

test 'Infrastructure and Projects Authority emails can be used as usernames for new users' do
email = 'fname.lname@ipa.gov.uk'
assert_match EmailValidator.allowed_emails_regexp, email
end

test 'Softwire emails are matched by the allowed emails regexp' do
email = 'fname.lname@softwire.com'
assert_match EmailValidator.allowed_emails_regexp, email
Expand Down

0 comments on commit 9dd36cf

Please sign in to comment.