Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
18 changes: 13 additions & 5 deletions .github/workflows/__start-proxy.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 59 additions & 11 deletions lib/entry-points.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"long": "^5.3.2",
"node-forge": "^1.4.0",
"semver": "^7.8.5",
"uuid": "^14.0.1"
"uuid": "^14.0.1",
"undici": "^6.24.0"
},
"devDependencies": {
"@ava/typescript": "6.0.0",
Expand Down
19 changes: 14 additions & 5 deletions pr-checks/checks/start-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ operatingSystems:
- windows
versions:
- linked
env:
CODEQL_ACTION_PROXY_API_REQUESTS: "true"
steps:
- uses: ./../action/init
with:
languages: csharp
tools: ${{ steps.prepare-test.outputs.tools-url }}

- name: Setup proxy for registries
id: proxy
uses: ./../action/start-proxy
with:
language: java
registry_secrets: |
[
{
Expand Down Expand Up @@ -44,3 +42,14 @@ steps:
|| !contains(steps.proxy.outputs.proxy_urls, 'https://repo.maven.apache.org/maven2/')
|| !contains(steps.proxy.outputs.proxy_urls, 'https://repo1.maven.org/maven2')
run: exit 1

- uses: ./../action/init
env:
CODEQL_PROXY_HOST: ${{ steps.proxy.outputs.proxy_host }}
CODEQL_PROXY_PORT: ${{ steps.proxy.outputs.proxy_port }}
CODEQL_PROXY_CA_CERTIFICATE: ${{ steps.proxy.outputs.proxy_ca_certificate }}
CODEQL_ACTION_NEW_REMOTE_FILE_ADDRESSES: "true"
with:
languages: java
tools: ${{ steps.prepare-test.outputs.tools-url }}
config-file: codeql-action@main:tests/multi-language-repo/.github/codeql/custom-queries.yml
Comment thread
mario-campos marked this conversation as resolved.
53 changes: 50 additions & 3 deletions src/api-client.test.ts
Comment thread
mario-campos marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import * as sinon from "sinon";
import * as actionsUtil from "./actions-util";
import * as api from "./api-client";
import { DO_NOT_RETRY_STATUSES } from "./api-client";
import { ActionsEnvVars } from "./environment";
import { getTestEnv, setupTests } from "./testing-utils";
import { ActionsEnvVars, RegistryProxyVars } from "./environment";
import { callee, getTestEnv, setupTests } from "./testing-utils";
import * as util from "./util";

setupTests(test);
Expand All @@ -27,14 +27,17 @@ test.serial("getApiClient", async (t) => {

sinon.stub(actionsUtil, "getRequiredInput").withArgs("token").returns("xyz");

api.getApiClient(env);
const apiClient = api.getApiClient(env);
t.truthy(apiClient);

t.true(githubStub.calledOnce);
t.assert(
githubStub.calledOnceWithExactly({
auth: "token xyz",
baseUrl: "http://api.github.localhost",
log: sinon.match.any,
userAgent: `CodeQL-Action/${actionsUtil.getActionVersion()}`,
request: sinon.match.any,
retry: {
doNotRetry: DO_NOT_RETRY_STATUSES,
},
Expand Down Expand Up @@ -204,3 +207,47 @@ test.serial(
}
},
);

test("getRegistryProxy - returns undefined if the proxy is not configured", async (t) => {
const target = callee(api.getRegistryProxy).withArgs();

// Empty environment.
await target.passes(t.is, undefined);
// Only the host.
await target
.withEnv(getTestEnv({ [RegistryProxyVars.PROXY_HOST]: "localhost" }))
.passes(t.is, undefined);
// Only the port.
await target
.withEnv(getTestEnv({ [RegistryProxyVars.PROXY_PORT]: "1234" }))
.passes(t.is, undefined);
});

test("getRegistryProxy - returns value when both vars are set", async (t) => {
await callee(api.getRegistryProxy)
.withArgs()
.withEnv(
getTestEnv({
[RegistryProxyVars.PROXY_HOST]: "localhost",
[RegistryProxyVars.PROXY_PORT]: "1234",
}),
)
.passes(t.truthy);
});

test("getRegistryProxyConfig - gets the configuration from the env vars", async (t) => {
const host = "localhost";
const port = "1234";
const ca = "cert";

await callee(api.getRegistryProxyConfig)
.withArgs()
.withEnv(
getTestEnv({
[RegistryProxyVars.PROXY_HOST]: host,
[RegistryProxyVars.PROXY_PORT]: port,
[RegistryProxyVars.PROXY_CA_CERTIFICATE]: ca,
}),
)
.passes(t.like, { host, port, ca });
});
Loading
Loading