Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove authorization header from core.windows.net requests for A…
…zure docker registries (#6641) Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
- Loading branch information
1 parent
c450621
commit 45d7d40
Showing
3 changed files
with
146 additions
and
19 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { getName } from '../../../test/util'; | ||
import { removeAuthorization } from './auth'; | ||
|
||
describe(getName(__filename), () => { | ||
it('removeAuthorization no authorization', () => { | ||
const opts = { | ||
hostname: 'amazon.com', | ||
href: 'https://amazon.com', | ||
search: 'something X-Amz-Algorithm something', | ||
}; | ||
|
||
removeAuthorization(opts); | ||
|
||
expect(opts).toEqual({ | ||
hostname: 'amazon.com', | ||
href: 'https://amazon.com', | ||
search: 'something X-Amz-Algorithm something', | ||
}); | ||
}); | ||
|
||
it('removeAuthorization Amazon', () => { | ||
const opts = { | ||
auth: 'auth', | ||
headers: { | ||
authorization: 'auth', | ||
}, | ||
hostname: 'amazon.com', | ||
href: 'https://amazon.com', | ||
search: 'something X-Amz-Algorithm something', | ||
}; | ||
|
||
removeAuthorization(opts); | ||
|
||
expect(opts).toEqual({ | ||
headers: {}, | ||
hostname: 'amazon.com', | ||
href: 'https://amazon.com', | ||
search: 'something X-Amz-Algorithm something', | ||
}); | ||
}); | ||
|
||
it('removeAuthorization Amazon ports', () => { | ||
const opts = { | ||
auth: 'auth', | ||
headers: { | ||
authorization: 'auth', | ||
}, | ||
hostname: 'amazon.com', | ||
href: 'https://amazon.com', | ||
port: 3000, | ||
search: 'something X-Amz-Algorithm something', | ||
}; | ||
|
||
removeAuthorization(opts); | ||
|
||
expect(opts).toEqual({ | ||
headers: {}, | ||
hostname: 'amazon.com', | ||
href: 'https://amazon.com', | ||
search: 'something X-Amz-Algorithm something', | ||
}); | ||
}); | ||
|
||
it('removeAuthorization Azure blob', () => { | ||
const opts = { | ||
auth: 'auth', | ||
headers: { | ||
authorization: 'auth', | ||
}, | ||
hostname: 'store123.blob.core.windows.net', | ||
href: | ||
'https://<store>.blob.core.windows.net/<some id>//docker/registry/v2/blobs', | ||
}; | ||
|
||
removeAuthorization(opts); | ||
|
||
expect(opts).toEqual({ | ||
headers: {}, | ||
hostname: 'store123.blob.core.windows.net', | ||
href: | ||
'https://<store>.blob.core.windows.net/<some id>//docker/registry/v2/blobs', | ||
}); | ||
}); | ||
|
||
it('removeAuthorization keep auth', () => { | ||
const opts = { | ||
auth: 'auth', | ||
headers: { | ||
authorization: 'auth', | ||
}, | ||
hostname: 'renovate.com', | ||
href: 'https://renovate.com', | ||
search: 'something', | ||
}; | ||
|
||
removeAuthorization(opts); | ||
|
||
expect(opts).toEqual({ | ||
auth: 'auth', | ||
headers: { | ||
authorization: 'auth', | ||
}, | ||
hostname: 'renovate.com', | ||
href: 'https://renovate.com', | ||
search: 'something', | ||
}); | ||
}); | ||
}); |
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