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
fix: kind installer/Resource not present #3994
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/********************************************************************** | ||
* Copyright (C) 2023 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
***********************************************************************/ | ||
|
||
import { expect, test, vi } from 'vitest'; | ||
import { Proxy } from '/@/plugin/proxy.js'; | ||
import type { ConfigurationRegistry } from '/@/plugin/configuration-registry.js'; | ||
import * as http from 'http'; | ||
import { createProxy, type ProxyServer } from 'proxy'; | ||
import type { AddressInfo } from 'net'; | ||
|
||
const URL = 'https://podman-desktop.io'; | ||
|
||
function getConfigurationRegistry( | ||
enabled: boolean, | ||
http: string | undefined, | ||
https: string | undefined, | ||
no: string | undefined, | ||
): ConfigurationRegistry { | ||
const get = vi.fn().mockImplementation(name => { | ||
if (name === 'enabled') { | ||
return enabled; | ||
} else if (name === 'http') { | ||
return http; | ||
} else if (name === 'https') { | ||
return https; | ||
} else if (name === 'no') { | ||
return no; | ||
} | ||
}); | ||
return { | ||
registerConfigurations: vi.fn(), | ||
onDidChangeConfiguration: vi.fn(), | ||
getConfiguration: vi.fn().mockReturnValue({ | ||
get: get, | ||
}), | ||
} as unknown as ConfigurationRegistry; | ||
} | ||
|
||
async function buildProxy(): Promise<ProxyServer> { | ||
return new Promise(resolve => { | ||
const server = createProxy(http.createServer()); | ||
server.listen(0, () => resolve(server)); | ||
}); | ||
} | ||
|
||
test('fetch without proxy', async () => { | ||
const configurationRegistry = getConfigurationRegistry(false, undefined, undefined, undefined); | ||
const proxy = new Proxy(configurationRegistry); | ||
await proxy.init(); | ||
await fetch(URL); | ||
}); | ||
|
||
test('fetch with http proxy', async () => { | ||
const proxyServer = await buildProxy(); | ||
const address = proxyServer.address() as AddressInfo; | ||
const configurationRegistry = getConfigurationRegistry(true, `127.0.0.1:${address.port}`, undefined, undefined); | ||
const proxy = new Proxy(configurationRegistry); | ||
await proxy.init(); | ||
let connectDone = false; | ||
proxyServer.on('connect', () => (connectDone = true)); | ||
await fetch(URL); | ||
expect(connectDone).toBeTruthy(); | ||
}); |
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
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.
I'm wondering if it should not go the https://github.com/containers/podman-desktop/blob/main/packages/main/src/plugin/extension-loader.ts#L217-L218
Also I'm wondering about the need of
undici
libraryit looks like that for
createHttpPatchedModules
https://www.npmjs.com/package/hpagent is used so it looks like to be a duplicated dependencyProbably some code could be shared with createHttpPatchedModules from proxy-resolver.ts class