diff --git a/app/lib/email_validator.rb b/app/lib/email_validator.rb index 59efcfb..fdfe1a0 100644 --- a/app/lib/email_validator.rb +++ b/app/lib/email_validator.rb @@ -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' @@ -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 @@ -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*)/, diff --git a/test/lib/email_validator_test.rb b/test/lib/email_validator_test.rb index d493afa..94af78b 100644 --- a/test/lib/email_validator_test.rb +++ b/test/lib/email_validator_test.rb @@ -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) @@ -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) @@ -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