diff --git a/app/lib/email_validator.rb b/app/lib/email_validator.rb index 4e08a97..59efcfb 100644 --- a/app/lib/email_validator.rb +++ b/app/lib/email_validator.rb @@ -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' @@ -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 @@ -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*)/, diff --git a/test/lib/email_validator_test.rb b/test/lib/email_validator_test.rb index 865bade..d493afa 100644 --- a/test/lib/email_validator_test.rb +++ b/test/lib/email_validator_test.rb @@ -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 = 'fname.lname@gpa.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) @@ -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 = 'fname.lname@gpa.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) @@ -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 = 'fname.lname@gpa.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