Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed custom user agent string from outgoing requests. #1427

Merged
merged 1 commit into from
Apr 15, 2019
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
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)
);
});
});