-
Notifications
You must be signed in to change notification settings - Fork 753
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
WIP: Ngrok Debugger Implementation #2032
Merged
Merged
Changes from 21 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
4507aaf
Basic ngrok debugger setup
902b061
Ui updates completed for ngrok debug console
0213324
Ngrok redux setup completed. Actions hooked up to ngrokDebugContainer
1d7c28b
Wrapped up all inputs going into the debuggr ngrok component
8c969f3
Broadcasting error response
3d7f8b9
Write stream tests passed
4b1aadb
Get path initializer
abe0bf2
Refactoring fn names
105138e
Reconnect to ngrok functionality completed
8f4af7b
UI test updated for ngrok container
95fe0fd
All lock files and fresh installs done
23b4d99
removed unneeded scss
ef83075
Renaming classes
2d9492c
Linter errors and fixes for it across all packages
ad8a57a
Removed prefixed slash
7d9f8a9
added rebuild keytar script inside main
e778e50
Added lock file to ignore
a9daa47
Revert keytar to old version
92ed4d1
Updatting postman collection to leverage global variables
aa20468
Debug container UI tests
9a34510
Mock Jest Date implementation
b11dd49
PR review feedback addressed
3b8f04f
Pre feedback addressed
88f6642
Made sure all pacjage locks are removed and spacing between cases
7ce584a
PR review feedback addressed
49cb853
One more package lock deleted
f57b6e4
Qna maker package lock removed
e65aa20
Tests updated after refactor
c6ff96f
Pr feedback addressed
6c08711
More copy fixes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
# dependencies | ||
/node_modules | ||
package-lock.json | ||
|
||
# testing | ||
/coverage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/app/client/src/state/actions/ngrokTunnelActions.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. | ||
// | ||
// Microsoft Bot Framework: http://botframework.com | ||
// | ||
// Bot Framework Emulator Github: | ||
// https://github.com/Microsoft/BotFramwork-Emulator | ||
// | ||
// Copyright (c) Microsoft Corporation | ||
// All rights reserved. | ||
// | ||
// MIT License: | ||
// Permission is hereby granted, free of charge, to any person obtaining | ||
// a copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so, subject to | ||
// the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
|
||
import { | ||
updateNewTunnelInfo, | ||
updateTunnelError, | ||
updateTunnelStatus, | ||
NgrokTunnelActions, | ||
TunnelInfo, | ||
TunnelError, | ||
TunnelStatus, | ||
} from './ngrokTunnelActions'; | ||
|
||
describe('Ngrok Tunnel Actions', () => { | ||
it('should create an update tunnel info action', () => { | ||
const payload: TunnelInfo = { | ||
publicUrl: 'https://d1a2bf16.ngrok.io', | ||
inspectUrl: 'http://127.0.0.1:4041', | ||
logPath: 'ngrok.log', | ||
postmanCollectionPath: 'postman.json', | ||
}; | ||
const action = updateNewTunnelInfo(payload); | ||
expect(action.type).toBe(NgrokTunnelActions.setDetails); | ||
expect(action.payload).toEqual(payload); | ||
}); | ||
|
||
it('should create a update tunnel error action', () => { | ||
const payload: TunnelError = { | ||
statusCode: 402, | ||
errorMessage: 'Tunnel has expired', | ||
}; | ||
const action = updateTunnelError(payload); | ||
expect(action.type).toBe(NgrokTunnelActions.updateOnError); | ||
expect(action.payload).toEqual(payload); | ||
}); | ||
|
||
it('should create a tunnel status update action', () => { | ||
const expectedStatus: TunnelStatus = TunnelStatus.Active; | ||
const action = updateTunnelStatus(expectedStatus); | ||
expect(action.type).toBe(NgrokTunnelActions.setStatus); | ||
expect(action.payload.ts).toBe(new Date().toLocaleString()); | ||
expect(action.payload.status).toBe(expectedStatus); | ||
}); | ||
}); |
94 changes: 94 additions & 0 deletions
94
packages/app/client/src/state/actions/ngrokTunnelActions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. | ||
// | ||
// Microsoft Bot Framework: http://botframework.com | ||
// | ||
// Bot Framework Emulator Github: | ||
// https://github.com/Microsoft/BotFramwork-Emulator | ||
// | ||
// Copyright (c) Microsoft Corporation | ||
// All rights reserved. | ||
// | ||
// MIT License: | ||
// Permission is hereby granted, free of charge, to any person obtaining | ||
// a copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so, subject to | ||
// the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
// eslint-disable-next-line typescript/no-unused-vars | ||
import { Action } from 'redux'; | ||
|
||
export enum NgrokTunnelActions { | ||
setDetails = 'NgrokTunnel/SET_DETAILS', | ||
updateOnError = 'NgrokTunnel/TUNNEL_ERROR', | ||
setStatus = 'NgrokTunnel/STATUS_CHECK', | ||
} | ||
|
||
export enum TunnelStatus { | ||
Active, | ||
Inactive, | ||
Error, | ||
} | ||
|
||
export interface TunnelInfo { | ||
publicUrl: string; | ||
inspectUrl: string; | ||
logPath: string; | ||
postmanCollectionPath: string; | ||
} | ||
|
||
export interface TunnelError { | ||
statusCode: number; | ||
errorMessage: string; | ||
} | ||
|
||
export interface TunnelStatusAndTs { | ||
status: TunnelStatus; | ||
ts: string; | ||
srinaath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
export interface NgrokTunnelAction<T> extends Action { | ||
type: NgrokTunnelActions; | ||
payload: T; | ||
} | ||
|
||
export type NgrokTunnelPayloadTypes = TunnelError | TunnelInfo | TunnelStatusAndTs; | ||
|
||
export function updateNewTunnelInfo(payload: TunnelInfo): NgrokTunnelAction<TunnelInfo> { | ||
return { | ||
type: NgrokTunnelActions.setDetails, | ||
payload, | ||
}; | ||
} | ||
|
||
export function updateTunnelStatus(tunnelStatus: TunnelStatus): NgrokTunnelAction<TunnelStatusAndTs> { | ||
return { | ||
type: NgrokTunnelActions.setStatus, | ||
payload: { | ||
status: tunnelStatus, | ||
ts: new Date().toLocaleString(), | ||
}, | ||
}; | ||
} | ||
|
||
export function updateTunnelError(payload: TunnelError): NgrokTunnelAction<TunnelError> { | ||
return { | ||
type: NgrokTunnelActions.updateOnError, | ||
payload, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
packages/app/client/src/state/reducers/ngrokTunnel.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. | ||
// | ||
// Microsoft Bot Framework: http://botframework.com | ||
// | ||
// Bot Framework Emulator Github: | ||
// https://github.com/Microsoft/BotFramwork-Emulator | ||
// | ||
// Copyright (c) Microsoft Corporation | ||
// All rights reserved. | ||
// | ||
// MIT License: | ||
// Permission is hereby granted, free of charge, to any person obtaining | ||
// a copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so, subject to | ||
// the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
|
||
import { | ||
TunnelStatus, | ||
NgrokTunnelAction, | ||
TunnelInfo, | ||
NgrokTunnelPayloadTypes, | ||
NgrokTunnelActions, | ||
TunnelError, | ||
TunnelStatusAndTs, | ||
} from '../actions/ngrokTunnelActions'; | ||
|
||
import { ngrokTunnel, NgrokTunnelState } from './ngrokTunnel'; | ||
|
||
describe('Ngrok Tunnel reducer', () => { | ||
const DEFAULT_STATE: NgrokTunnelState = { | ||
inspectUrl: 'http://127.0.0.1:4040', | ||
publicUrl: '', | ||
logPath: '', | ||
postmanCollectionPath: '', | ||
errors: {} as TunnelError, | ||
tunnelStatus: TunnelStatus.Inactive, | ||
lastTunnelStatusCheckTS: '', | ||
}; | ||
|
||
afterEach(() => { | ||
const emptyAction: NgrokTunnelAction<NgrokTunnelPayloadTypes> = { | ||
type: null, | ||
payload: null, | ||
}; | ||
ngrokTunnel({ ...DEFAULT_STATE }, emptyAction); | ||
}); | ||
|
||
it('Tunnel info should be set from payload', () => { | ||
const payload: TunnelInfo = { | ||
publicUrl: 'https://abc.io/', | ||
inspectUrl: 'http://127.0.0.1:4003', | ||
logPath: 'logger.txt', | ||
postmanCollectionPath: 'postman.json', | ||
}; | ||
const setDetailsAction: NgrokTunnelAction<NgrokTunnelPayloadTypes> = { | ||
type: NgrokTunnelActions.setDetails, | ||
payload, | ||
}; | ||
const startingState = { ...DEFAULT_STATE }; | ||
const endingState = ngrokTunnel(startingState, setDetailsAction); | ||
|
||
expect(endingState.publicUrl).toBe(payload.publicUrl); | ||
expect(endingState.logPath).toBe(payload.logPath); | ||
expect(endingState.postmanCollectionPath).toBe(payload.postmanCollectionPath); | ||
expect(endingState.inspectUrl).toBe(payload.inspectUrl); | ||
}); | ||
|
||
it('Tunnel errors should be set from payload', () => { | ||
const payload: TunnelError = { | ||
statusCode: 422, | ||
errorMessage: '<h1>Too many connections<h1>', | ||
}; | ||
const updateErrorAction: NgrokTunnelAction<NgrokTunnelPayloadTypes> = { | ||
type: NgrokTunnelActions.updateOnError, | ||
payload, | ||
}; | ||
const startingState = { ...DEFAULT_STATE }; | ||
const endingState = ngrokTunnel(startingState, updateErrorAction); | ||
|
||
expect(endingState.publicUrl).toBe(DEFAULT_STATE.publicUrl); | ||
expect(endingState.errors.statusCode).toBe(payload.statusCode); | ||
expect(endingState.errors.errorMessage).toBe(payload.errorMessage); | ||
}); | ||
|
||
it('Tunnel status should be set from payload', () => { | ||
const payload: TunnelStatusAndTs = { | ||
status: TunnelStatus.Active, | ||
ts: '12/27/2019, 1:30:00 PM', | ||
}; | ||
const nextPayload: TunnelStatusAndTs = { | ||
status: TunnelStatus.Error, | ||
ts: '12/27/2019, 1:33:00 PM', | ||
}; | ||
const actions: NgrokTunnelAction<NgrokTunnelPayloadTypes>[] = [ | ||
{ | ||
type: NgrokTunnelActions.setStatus, | ||
payload, | ||
}, | ||
{ | ||
type: NgrokTunnelActions.setStatus, | ||
payload: nextPayload, | ||
}, | ||
]; | ||
const startingState = { ...DEFAULT_STATE }; | ||
const transientState = ngrokTunnel(startingState, actions[0]); | ||
expect(transientState.tunnelStatus).toBe(payload.status); | ||
|
||
const finalState = ngrokTunnel(startingState, actions[1]); | ||
expect(finalState.tunnelStatus).toBe(nextPayload.status); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could instead add an entry to the root level
.gitignore
that ignores every lock file except for the root one?/packages/**/package-lock.json
and then delete the sub-root-level lock files?