Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
dd462359
Unverified
Commit
dd462359
authored
4 years ago
by
jose-ws
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(proxy): lowercase proxy env (#10025)
parent
e7506fef
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/proxy.spec.ts
+26
-0
26 additions, 0 deletions
lib/proxy.spec.ts
lib/proxy.ts
+4
-0
4 additions, 0 deletions
lib/proxy.ts
lib/util/exec/env.spec.ts
+21
-25
21 additions, 25 deletions
lib/util/exec/env.spec.ts
lib/util/exec/env.ts
+3
-0
3 additions, 0 deletions
lib/util/exec/env.ts
with
54 additions
and
25 deletions
lib/proxy.spec.ts
+
26
−
0
View file @
dd462359
...
@@ -7,7 +7,9 @@ describe('proxy', () => {
...
@@ -7,7 +7,9 @@ describe('proxy', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
delete
process
.
env
.
HTTP_PROXY
;
delete
process
.
env
.
HTTP_PROXY
;
delete
process
.
env
.
http_proxy
;
delete
process
.
env
.
HTTPS_PROXY
;
delete
process
.
env
.
HTTPS_PROXY
;
delete
process
.
env
.
https_proxy
;
delete
process
.
env
.
NO_PROXY
;
delete
process
.
env
.
NO_PROXY
;
delete
process
.
env
.
no_proxy
;
delete
process
.
env
.
no_proxy
;
});
});
...
@@ -17,11 +19,35 @@ describe('proxy', () => {
...
@@ -17,11 +19,35 @@ describe('proxy', () => {
bootstrap
();
bootstrap
();
expect
(
hasProxy
()).
toBeTrue
();
expect
(
hasProxy
()).
toBeTrue
();
});
});
it
(
'
copies upper case HTTP_PROXY to http_proxy
'
,
()
=>
{
process
.
env
.
HTTP_PROXY
=
httpProxy
;
bootstrap
();
expect
(
hasProxy
()).
toBeTrue
();
expect
(
process
.
env
.
HTTP_PROXY
).
toBeDefined
();
expect
(
process
.
env
.
http_proxy
).
toBeDefined
();
expect
(
process
.
env
.
HTTPS_PROXY
).
toBeUndefined
();
expect
(
process
.
env
.
https_proxy
).
toBeUndefined
();
expect
(
process
.
env
.
NO_PROXY
).
toBeUndefined
();
expect
(
process
.
env
.
no_proxy
).
toBeUndefined
();
});
it
(
'
respects HTTPS_PROXY
'
,
()
=>
{
it
(
'
respects HTTPS_PROXY
'
,
()
=>
{
process
.
env
.
HTTPS_PROXY
=
httpsProxy
;
process
.
env
.
HTTPS_PROXY
=
httpsProxy
;
bootstrap
();
bootstrap
();
expect
(
hasProxy
()).
toBeTrue
();
expect
(
hasProxy
()).
toBeTrue
();
});
});
it
(
'
copies upper case HTTPS_PROXY to https_proxy
'
,
()
=>
{
process
.
env
.
HTTPS_PROXY
=
httpsProxy
;
bootstrap
();
expect
(
hasProxy
()).
toBeTrue
();
expect
(
process
.
env
.
HTTPS_PROXY
).
toBeDefined
();
expect
(
process
.
env
.
https_proxy
).
toBeDefined
();
expect
(
process
.
env
.
HTTP_PROXY
).
toBeUndefined
();
expect
(
process
.
env
.
http_proxy
).
toBeUndefined
();
expect
(
process
.
env
.
NO_PROXY
).
toBeUndefined
();
expect
(
process
.
env
.
no_proxy
).
toBeUndefined
();
});
it
(
'
does nothing
'
,
()
=>
{
it
(
'
does nothing
'
,
()
=>
{
process
.
env
.
no_proxy
=
noProxy
;
process
.
env
.
no_proxy
=
noProxy
;
bootstrap
();
bootstrap
();
...
...
This diff is collapsed.
Click to expand it.
lib/proxy.ts
+
4
−
0
View file @
dd462359
...
@@ -14,6 +14,10 @@ export function bootstrap(): void {
...
@@ -14,6 +14,10 @@ export function bootstrap(): void {
)
{
)
{
process
.
env
[
envVar
]
=
process
.
env
[
envVar
.
toLowerCase
()];
process
.
env
[
envVar
]
=
process
.
env
[
envVar
.
toLowerCase
()];
}
}
if
(
process
.
env
[
envVar
])
{
process
.
env
[
envVar
.
toLowerCase
()]
=
process
.
env
[
envVar
];
}
});
});
if
(
if
(
...
...
This diff is collapsed.
Click to expand it.
lib/util/exec/env.spec.ts
+
21
−
25
View file @
dd462359
...
@@ -21,18 +21,16 @@ describe('getChildProcess environment when trustlevel set to low', () => {
...
@@ -21,18 +21,16 @@ describe('getChildProcess environment when trustlevel set to low', () => {
envVars
.
forEach
((
env
)
=>
delete
process
.
env
[
env
]);
envVars
.
forEach
((
env
)
=>
delete
process
.
env
[
env
]);
});
});
it
(
'
returns default environment variables
'
,
()
=>
{
it
(
'
returns default environment variables
'
,
()
=>
{
expect
(
getChildProcessEnv
()).
toMatchInlineSnapshot
(
`
expect
(
getChildProcessEnv
()).
toMatchObject
({
Object {
DOCKER_HOST
:
'
DOCKER_HOST
'
,
"DOCKER_HOST": "DOCKER_HOST",
HOME
:
'
HOME
'
,
"HOME": "HOME",
HTTPS_PROXY
:
'
HTTPS_PROXY
'
,
"HTTPS_PROXY": "HTTPS_PROXY",
HTTP_PROXY
:
'
HTTP_PROXY
'
,
"HTTP_PROXY": "HTTP_PROXY",
LANG
:
'
LANG
'
,
"LANG": "LANG",
LC_ALL
:
'
LC_ALL
'
,
"LC_ALL": "LC_ALL",
NO_PROXY
:
'
NO_PROXY
'
,
"NO_PROXY": "NO_PROXY",
PATH
:
'
PATH
'
,
"PATH": "PATH",
});
}
`
);
});
});
it
(
'
returns environment variable only if defined
'
,
()
=>
{
it
(
'
returns environment variable only if defined
'
,
()
=>
{
delete
process
.
env
.
PATH
;
delete
process
.
env
.
PATH
;
...
@@ -40,19 +38,17 @@ describe('getChildProcess environment when trustlevel set to low', () => {
...
@@ -40,19 +38,17 @@ describe('getChildProcess environment when trustlevel set to low', () => {
});
});
it
(
'
returns custom environment variables if passed and defined
'
,
()
=>
{
it
(
'
returns custom environment variables if passed and defined
'
,
()
=>
{
process
.
env
.
FOOBAR
=
'
FOOBAR
'
;
process
.
env
.
FOOBAR
=
'
FOOBAR
'
;
expect
(
getChildProcessEnv
([
'
FOOBAR
'
])).
toMatchInlineSnapshot
(
`
expect
(
getChildProcessEnv
([
'
FOOBAR
'
])).
toMatchObject
({
Object {
DOCKER_HOST
:
'
DOCKER_HOST
'
,
"DOCKER_HOST": "DOCKER_HOST",
FOOBAR
:
'
FOOBAR
'
,
"FOOBAR": "FOOBAR",
HOME
:
'
HOME
'
,
"HOME": "HOME",
HTTPS_PROXY
:
'
HTTPS_PROXY
'
,
"HTTPS_PROXY": "HTTPS_PROXY",
HTTP_PROXY
:
'
HTTP_PROXY
'
,
"HTTP_PROXY": "HTTP_PROXY",
LANG
:
'
LANG
'
,
"LANG": "LANG",
LC_ALL
:
'
LC_ALL
'
,
"LC_ALL": "LC_ALL",
NO_PROXY
:
'
NO_PROXY
'
,
"NO_PROXY": "NO_PROXY",
PATH
:
'
PATH
'
,
"PATH": "PATH",
});
}
`
);
delete
process
.
env
.
LANG
;
delete
process
.
env
.
LANG
;
});
});
...
...
This diff is collapsed.
Click to expand it.
lib/util/exec/env.ts
+
3
−
0
View file @
dd462359
...
@@ -4,6 +4,9 @@ const basicEnvVars = [
...
@@ -4,6 +4,9 @@ const basicEnvVars = [
'
HTTP_PROXY
'
,
'
HTTP_PROXY
'
,
'
HTTPS_PROXY
'
,
'
HTTPS_PROXY
'
,
'
NO_PROXY
'
,
'
NO_PROXY
'
,
'
http_proxy
'
,
'
https_proxy
'
,
'
no_proxy
'
,
'
HOME
'
,
'
HOME
'
,
'
PATH
'
,
'
PATH
'
,
'
LC_ALL
'
,
'
LC_ALL
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment