From 6864ffb385b30e15eb82c940ebfc2098e77e4e76 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Mon, 6 Feb 2023 16:56:45 +0100 Subject: [PATCH] 97298: Added form validator tests for restricted domains --- .../register-email-form.component.spec.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/app/register-email-form/register-email-form.component.spec.ts b/src/app/register-email-form/register-email-form.component.spec.ts index 8a527135bc..4fea169e35 100644 --- a/src/app/register-email-form/register-email-form.component.spec.ts +++ b/src/app/register-email-form/register-email-form.component.spec.ts @@ -96,6 +96,30 @@ describe('RegisterEmailFormComponent', () => { comp.form.patchValue({email: 'valid@email.org'}); expect(comp.form.invalid).toBeFalse(); }); + it('should not accept email with other domain names', () => { + spyOn(configurationDataService, 'findByPropertyName').and.returnValue(createSuccessfulRemoteDataObject$(Object.assign(new ConfigurationProperty(), { + name: 'authentication-password.domain.valid', + values: ['marvel.com'], + }))); + comp.typeRequest = TYPE_REQUEST_REGISTER; + + comp.ngOnInit(); + + comp.form.patchValue({ email: 'valid@email.org' }); + expect(comp.form.invalid).toBeTrue(); + }); + it('should accept email with the given domain name', () => { + spyOn(configurationDataService, 'findByPropertyName').and.returnValue(createSuccessfulRemoteDataObject$(Object.assign(new ConfigurationProperty(), { + name: 'authentication-password.domain.valid', + values: ['marvel.com'], + }))); + comp.typeRequest = TYPE_REQUEST_REGISTER; + + comp.ngOnInit(); + + comp.form.patchValue({ email: 'thor.odinson@marvel.com' }); + expect(comp.form.invalid).toBeFalse(); + }); }); describe('register', () => { it('should send a registration to the service and on success display a message and return to home', () => {