Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/__tests__/connection/enterprise/matchConnection.test.js
Original file line number Diff line number Diff line change
@@ -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();
});
});
2 changes: 1 addition & 1 deletion src/connection/enterprise.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down
Loading