| 1 | import { execFileSync } from 'node:child_process'; |
| 2 | import { mkdtempSync, rmSync |
| 3 | import { tmpdir } |
| 4 | import path from 'node:path |
| 5 | import { text } |
| 6 | import { Test, TestingModule |
| 7 | import { RefAdvertisementService } |
| 8 | |
| 9 | describe('RefAdvertisementService', () |
| 10 | let service: |
| 11 | let repoDirectory: |
| 12 | |
| 13 | beforeEach(async () |
| 14 | const module: |
| 15 | providers: [RefAdvertisementService], |
| 16 | }).compile(); |
| 17 | |
| 18 | service = module. |
| 19 | repoDirectory = mkdtempSync( |
| 20 | execFileSync('git', |
| 21 | }); |
| 22 | |
| 23 | afterEach(() => |
| 24 | |
| 25 | it('answers a v2 client with capabilities instead of refs', |
| 26 | const body = |
| 27 | service.advertise({ |
| 28 | repoDirectory, |
| 29 | service: 'git-upload-pack', |
| 30 | protocol: 'version=2', |
| 31 | }), |
| 32 | ); |
| 33 | |
| 34 | expect(body).toContain |
| 35 | expect(body).toContain |
| 36 | expect(body).toContain |
| 37 | }); |
| 38 | |
| 39 | it('stays on v0 for anything but an exact version=2', |
| 40 | const body = |
| 41 | service.advertise({ |
| 42 | repoDirectory, |
| 43 | service: 'git-upload-pack', |
| 44 | protocol: 'version=2:evil=1', |
| 45 | }), |
| 46 | ); |
| 47 | |
| 48 | expect(body).not |
| 49 | }); |
| 50 | }); |