From 3722cef9377b06eed62b69955abfc270a9599964 Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Mon, 16 Mar 2020 16:15:19 -0700 Subject: [PATCH] Ensure local host only if connection not available (#10600) * Ensure local host only if connection not available * Add news item --- news/2 Fixes/10597.md | 1 + .../configuration/resolvers/attach.ts | 5 ++-- src/client/debugger/types.ts | 7 +++++ .../resolvers/attach.unit.test.ts | 26 +++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 news/2 Fixes/10597.md diff --git a/news/2 Fixes/10597.md b/news/2 Fixes/10597.md new file mode 100644 index 000000000000..c666d8d8d5b4 --- /dev/null +++ b/news/2 Fixes/10597.md @@ -0,0 +1 @@ +Ensure default `host` is not set, if `connect` or `listen` settings are available. diff --git a/src/client/debugger/extension/configuration/resolvers/attach.ts b/src/client/debugger/extension/configuration/resolvers/attach.ts index 0845781dff74..bcfdd4734e79 100644 --- a/src/client/debugger/extension/configuration/resolvers/attach.ts +++ b/src/client/debugger/extension/configuration/resolvers/attach.ts @@ -55,7 +55,8 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver { .deep.equal(debugOptionsAvailable); expect(debugConfig).to.have.property('host', 'localhost'); }); + test('Default host should not be added if connect is available.', async () => { + const pythonFile = 'xyz.py'; + + setupActiveEditor(pythonFile, PYTHON_LANGUAGE); + setupWorkspaces([]); + + const debugConfig = await debugProvider.resolveDebugConfiguration!(undefined, { + request: 'attach', + connect: { host: 'localhost', port: 5678 } + } as AttachRequestArguments); + + expect(debugConfig).to.not.have.property('host', 'localhost'); + }); + test('Default host should not be added if listen is available.', async () => { + const pythonFile = 'xyz.py'; + + setupActiveEditor(pythonFile, PYTHON_LANGUAGE); + setupWorkspaces([]); + + const debugConfig = await debugProvider.resolveDebugConfiguration!(undefined, { + request: 'attach', + listen: { host: 'localhost', port: 5678 } + } as AttachRequestArguments); + + expect(debugConfig).to.not.have.property('host', 'localhost'); + }); test("Ensure 'localRoot' is left unaltered", async () => { const activeFile = 'xyz.py'; const workspaceFolder = createMoqWorkspaceFolder(__dirname);