Skip to content
Open
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
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.

65 changes: 54 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 @@ -41,7 +41,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
36 changes: 33 additions & 3 deletions src/api-client.test.ts
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,30 @@ 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);
});
Loading
Loading