[MM-45031] Don't use infinite background retry logic when the certificate is invalid (#2153)

This commit is contained in:
Devin Binnie
2022-06-15 09:22:21 -04:00
committed by GitHub
parent 537ed1dd0c
commit 0c5b612489
4 changed files with 41 additions and 1 deletions

View File

@@ -36,6 +36,10 @@ jest.mock('main/certificateStore', () => ({
jest.mock('main/tray/tray', () => ({}));
jest.mock('main/windows/windowManager', () => ({
getMainWindow: jest.fn(),
getViewNameByWebContentsId: jest.fn(),
viewManager: {
views: new Map(),
},
}));
describe('main/app/app', () => {
@@ -53,6 +57,7 @@ describe('main/app/app', () => {
});
afterEach(() => {
WindowManager.viewManager.views.clear();
jest.resetAllMocks();
});
@@ -139,6 +144,16 @@ describe('main/app/app', () => {
expect(CertificateStore.save).toHaveBeenCalled();
});
it('should load URL using MattermostView when trusting certificate', async () => {
dialog.showMessageBox.mockResolvedValue({response: 0});
const load = jest.fn();
WindowManager.viewManager.views.set('view-name', {load});
WindowManager.getViewNameByWebContentsId.mockReturnValue('view-name');
await handleAppCertificateError(event, webContents, testURL, 'error-1', certificate, callback);
expect(callback).toHaveBeenCalledWith(true);
expect(load).toHaveBeenCalledWith(testURL);
});
it('should explicitly untrust if user selects More Details and then cancel with the checkbox checked', async () => {
dialog.showMessageBox.mockResolvedValueOnce({response: 0}).mockResolvedValueOnce({response: 1, checkboxChecked: true});
await handleAppCertificateError(event, webContents, testURL, 'error-1', certificate, callback);