Skip to content

Commit

Permalink
Removed custom user agent string from outgoing requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyanziano committed Apr 15, 2019
1 parent 2c6a4cf commit dba9b8e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 67 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [ui-react] Added default disabled styling to checkbox control in PR [1424](https://github.com/Microsoft/BotFramework-Emulator/pull/1424)
- [client] Fixed issue where BOM wasn't being stripped from transcripts opened via the File menu in PR [1425](https://github.com/Microsoft/BotFramework-Emulator/pull/1425)

## Removed
- [main] Removed custom user agent string from outgoing requests in PR [1427](https://github.com/Microsoft/BotFramework-Emulator/pull/1427)

## v4.3.3 - 2019 - 03 - 14
## Fixed
- [client] Use correct casing for user id prop for web chat in PR [#1374](https://github.com/Microsoft/BotFramework-Emulator/pull/1374)
Expand Down
43 changes: 0 additions & 43 deletions packages/app/main/src/appendCustomUserAgent.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/app/main/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { app, BrowserWindow, dialog, ipcMain, Rectangle, screen, systemPreferenc
import { UpdateInfo } from 'electron-updater';
import { Store } from 'redux';

import { appendCustomUserAgent } from './appendCustomUserAgent';
import { AppMenuBuilder } from './appMenuBuilder';
import { AppUpdater } from './appUpdater';
import { getStore } from './botData/store';
Expand Down Expand Up @@ -298,9 +297,6 @@ const createMainWindow = async () => {
})
);

// attach custom user agent string
mainWindow.webContents.session.webRequest.onBeforeSendHeaders(appendCustomUserAgent);

// get reference to bots list in state for comparison against state changes
let botsRef = store.getState().bot.botFiles;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,31 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { appendCustomUserAgent } from './appendCustomUserAgent';
import { SharedConstants } from '@bfemulator/app-shared';
import { logEntry, LogLevel, textItem } from '@bfemulator/sdk-shared';

const mockVersion = 'v4.5.6';
jest.mock('electron', () => ({
app: {
getVersion: () => mockVersion,
},
}));
import { LogService } from './logService';

it('should append a custom user agent to outgoing requests', () => {
const mockDetails = {
requestHeaders: {
'User-Agent': 'some/user/agent',
},
};
const callBack = jest.fn((...args: any[]) => null);
appendCustomUserAgent(mockDetails, callBack);
describe('LogService', () => {
it('should log items to chat', () => {
// lock down the time so that the timestamp doesn't break the test
Date.now = () => 123;

expect(callBack).toHaveBeenCalledWith({
cancel: false,
requestHeaders: {
'User-Agent': `some/user/agent botbuilder/emulator/${mockVersion}`,
},
const mockRemoteCall = jest.fn(() => null);
const window: any = {
commandService: {
remoteCall: mockRemoteCall,
},
};
const logService = new LogService(window);
const item1 = textItem(LogLevel.Debug, 'someText');
const item2 = textItem(LogLevel.Info, 'someOtherText');
logService.logToChat('someConvoId', item1, item2);

expect(mockRemoteCall).toHaveBeenCalledWith(
SharedConstants.Commands.Emulator.AppendToLog,
'someConvoId',
logEntry(item1, item2)
);
});
});

0 comments on commit dba9b8e

Please sign in to comment.