Skip to content
Merged
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
2 changes: 1 addition & 1 deletion internal/infra/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func proxyEnv(apiURL string) []string {
"HTTP_PROXY=" + os.Getenv("HTTP_PROXY"),
"HTTPS_PROXY=" + os.Getenv("HTTPS_PROXY"),
"NO_PROXY=" + os.Getenv("NO_PROXY"),
"JOB_ID=" + jobID,
"JOB_ID=" + firstNonEmpty(os.Getenv("DEPENDABOT_JOB_ID"), jobID),
"PROXY_CACHE=" + firstNonEmpty(os.Getenv("PROXY_CACHE"), "true"),
"LOG_RESPONSE_BODY_ON_AUTH_FAILURE=true",
"ACTIONS_ID_TOKEN_REQUEST_TOKEN=" + os.Getenv("ACTIONS_ID_TOKEN_REQUEST_TOKEN"),
Expand Down
32 changes: 32 additions & 0 deletions internal/infra/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,38 @@ func Test_proxyEnv_OpenSSLForceFIPSMode(t *testing.T) {
})
}

func Test_proxyEnv_JobID(t *testing.T) {
for _, tt := range []struct {
name string
jobID string
unset bool
want string
}{
{name: "uses host job ID", jobID: "1588055836", want: "1588055836"},
{name: "defaults when empty", want: "cli"},
{name: "defaults when unset", unset: true, want: "cli"},
} {
t.Run(tt.name, func(t *testing.T) {
t.Setenv("DEPENDABOT_JOB_ID", tt.jobID)
if tt.unset {
if err := os.Unsetenv("DEPENDABOT_JOB_ID"); err != nil {
t.Fatal(err)
}
}

env := proxyEnv("")

value, ok := envValue(env, "JOB_ID")
if !ok {
t.Fatal("expected JOB_ID to be present in proxy env")
}
if value != tt.want {
t.Errorf("expected JOB_ID to be %q, got %q", tt.want, value)
}
})
}
}

func Test_proxyEnv_JobToken(t *testing.T) {
t.Run("passes JOB_TOKEN from environment", func(t *testing.T) {
t.Setenv("JOB_TOKEN", "super-secret-token")
Expand Down
Loading