diff --git a/src/__tests__/connection/enterprise/matchConnection.test.js b/src/__tests__/connection/enterprise/matchConnection.test.js new file mode 100644 index 000000000..2c350b8db --- /dev/null +++ b/src/__tests__/connection/enterprise/matchConnection.test.js @@ -0,0 +1,27 @@ +import I from 'immutable'; +import { matchConnection } from '../../../connection/enterprise'; + +jest.mock('core/index', () => ({ + connections: jest.fn() +})); + +describe('matchConnection', () => { + afterEach(() => jest.resetAllMocks()); + + it('does not throw when enterprise connection has no domains configured', () => { + const { connections } = require('core/index'); + + // Simulate tenant endpoint returning a connection with no domains field + connections.mockReturnValue( + I.fromJS([{ name: 'samlp-connection', strategy: 'samlp', type: 'enterprise' }]) + ); + + const m = I.fromJS({ id: '__lock__' }); + + let result; + expect(() => { + result = matchConnection(m, 'test@example.com'); + }).not.toThrow(); + expect(result).toBeFalsy(); + }); +}); diff --git a/src/connection/enterprise.js b/src/connection/enterprise.js index be15a3b76..9feaa36e1 100644 --- a/src/connection/enterprise.js +++ b/src/connection/enterprise.js @@ -79,7 +79,7 @@ export function matchConnection(m, email, strategies = []) { const target = emailDomain(email); if (!target) return false; return l.connections(m, 'enterprise', ...strategies).find(x => { - return x.get('domains').contains(target); + return x.get('domains', List()).contains(target); }); }