Skip to content
Snippets Groups Projects
Select Git revision
  • 53ca91301f6a36c0c87e7d6b06b1bd8c9ec1b283
  • main default protected
  • fix/36615b-branch-reuse-no-cache
  • renovate/main-redis-5.x
  • next
  • revert-31645-feat/rename-gradle-wrapper-validation-action
  • chore/punycode
  • refactor/pin-new-value
  • feat/36219--git-x509-signing
  • feat/structured-logger
  • hotfix/39.264.1
  • feat/skip-dangling
  • gh-readonly-queue/next/pr-36034-7a061c4ca1024a19e2c295d773d9642625d1c2be
  • hotfix/39.238.3
  • refactor/gitlab-auto-approve
  • feat/template-strings
  • gh-readonly-queue/next/pr-35654-137d934242c784e0c45d4b957362214f0eade1d7
  • fix/32307-global-extends-merging
  • fix/32307-global-extends-repositories
  • gh-readonly-queue/next/pr-35009-046ebf7cb84ab859f7fefceb5fa53a54ce9736f8
  • gh-readonly-queue/next/pr-35009-9d5e583b7d7251148ab0d11ee8dd38149618d162
  • 41.38.1
  • 41.38.0
  • 41.37.12
  • 41.37.11
  • 41.37.10
  • 41.37.9
  • 41.37.8
  • 41.37.7
  • 41.37.6
  • 41.37.5
  • 41.37.4
  • 41.37.3
  • 41.37.2
  • 41.37.1
  • 41.37.0
  • 41.36.2
  • 41.36.1
  • 41.36.0
  • 41.35.2
  • 41.35.1
41 results

generate.spec.ts

Blame
  • got.spec.ts 2.60 KiB
    import nock from 'nock';
    import { getConfigResponse } from '../../datasource/docker';
    
    describe('getConfigResponse', () => {
      beforeEach(() => {
        nock.disableNetConnect();
      });
    
      afterEach(() => {
        nock.cleanAll();
        nock.enableNetConnect();
      });
    
      it('redirects correctly when the original and redirect url both have a port', async () => {
        const url =
          'http://docker.registry.com:5000/v2/image:latest/blobs/some-digest';
        const redirectURL =
          'https://s3.aws.amazon.com:3000/docker/registry/v2/blobs/sha256/d4/some-digest/data?X-Amz-Algorithm=AWS4-HMAC-SHA256';
        nock('http://docker.registry.com:5000')
          .get('/v2/image:latest/blobs/some-digest')
          .reply(307, undefined, {
            location: redirectURL,
          });
        nock('https://s3.aws.amazon.com:3000')
          .get(
            '/docker/registry/v2/blobs/sha256/d4/some-digest/data?X-Amz-Algorithm=AWS4-HMAC-SHA256'
          )
          .reply(200, 'test body');
        const response = await getConfigResponse(url, {});
        expect(response.body).toEqual('test body');
      });
    
      it('redirects correctly when original url has a port, but the redirect url does not', async () => {
        const url =
          'http://docker.registry.com:5001/v2/image:latest/blobs/some-digest';
        const redirectURL =
          'https://s3.aws.amazon.com/docker/registry/v2/blobs/sha256/d4/some-digest/data?X-Amz-Algorithm=AWS4-HMAC-SHA256';
        nock('http://docker.registry.com:5001')
          .get('/v2/image:latest/blobs/some-digest')
          .reply(307, undefined, {
            location: redirectURL,
          });
        nock('https://s3.aws.amazon.com')
          .get(
            '/docker/registry/v2/blobs/sha256/d4/some-digest/data?X-Amz-Algorithm=AWS4-HMAC-SHA256'
          )
          .reply(200, 'test body');
        const response = await getConfigResponse(url, {});
        expect(response.body).toEqual('test body');
      });
    
      it('redirects correctly when the original url does not have a port, but the redirect to url does', async () => {
        const url = 'http://docker.registry.com/v2/image:latest/blobs/some-digest';
        const redirectURL =
          'https://s3.aws.amazon.com:3001/docker/registry/v2/blobs/sha256/d4/some-digest/data?X-Amz-Algorithm=AWS4-HMAC-SHA256';
        nock('http://docker.registry.com')
          .get('/v2/image:latest/blobs/some-digest')
          .reply(307, undefined, {
            location: redirectURL,
          });
        nock('https://s3.aws.amazon.com:3001')
          .get(
            '/docker/registry/v2/blobs/sha256/d4/some-digest/data?X-Amz-Algorithm=AWS4-HMAC-SHA256'
          )
          .reply(200, 'test body');
        const response = await getConfigResponse(url, {});
        expect(response.body).toEqual('test body');
      });
    });