style(proxy): format docker protocol tests
This commit is contained in:
1 parent
cb44ddb66c
commit
213e04de76
2 files changed
+5
-8
No files matched your search
@@ -130,7 +130,9 @@ function normalizeRepoPath(platformKey, repoPath) {
|
||||
* @returns {string} Repository path without the `/v2/` prefix or operation suffix.
|
||||
*/
|
||||
function extractRepositoryPath(apiPath) {
|
||||
const normalizedPath = apiPath.startsWith('/v2/') ? apiPath.slice(4) : apiPath.replace(/^\/+/, '');
|
||||
const normalizedPath = apiPath.startsWith('/v2/')
|
||||
? apiPath.slice(4)
|
||||
: apiPath.replace(/^\/+/, '');
|
||||
const pathParts = normalizedPath.split('/').filter(Boolean);
|
||||
|
||||
if (pathParts.length === 0 || pathParts[0].startsWith('_')) {
|
||||
@@ -228,10 +230,7 @@ export function responseUnauthorized(url, platform) {
|
||||
const realmPath = platform ? `/cr/${platform.slice(3)}/v2/auth` : '/v2/auth';
|
||||
const headers = new Headers();
|
||||
headers.set('Content-Type', 'application/json');
|
||||
headers.set(
|
||||
'WWW-Authenticate',
|
||||
`Bearer realm="${url.origin}${realmPath}",service="Xget"`
|
||||
);
|
||||
headers.set('WWW-Authenticate', `Bearer realm="${url.origin}${realmPath}",service="Xget"`);
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
errors: [
|
||||
|
||||
@@ -198,9 +198,7 @@ describe('Docker Authentication', () => {
|
||||
const response = await worker.fetch(request, {}, executionContext);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(String(fetchSpy.mock.calls[1][0])).toContain(
|
||||
'scope=repository%3Aprivate%2Frepo%3Apull'
|
||||
);
|
||||
expect(String(fetchSpy.mock.calls[1][0])).toContain('scope=repository%3Aprivate%2Frepo%3Apull');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user