UNPKG

2.29 kBJavaScriptView Raw
1/*
2 Here we simulate the response of the server when asked
3 to get the strider.json file from the privproject1 repo
4
5 nock will simulate a gitlab server running at
6 localhost:80, where Strider Tester, a user is
7 registered with the name "stridertester", and
8 has been registered with api token - zRtVsmeznn7ySatTrnrp
9 stridertester is an "owner" of a group named "testunion"
10 and has admin access to three projects -
11 testunion / unionproject1
12 Strider Tester / pubproject1
13 Strider Tester / privproject1
14 */
15
16var nock = require('nock');
17
18module.exports = function () {
19
20 nock('http://localhost:80')
21 .get('/api/v3/projects/5/repository/blobs/master')
22 .query({"private_token": "zRtVsmeznn7ySatTrnrp", "per_page": "100", "filepath": "strider.json"})
23 .reply(200, ["1f8b0800000000000003abe6525050ca4bcc4d55b25250cacd2c294a54d2010915a726e7e7a580048b12cb3221622519994560a1e2d2a24aa8bab4fcd2a2920c90605246625ea912572d170048d47f8653000000"], {
24 server: 'nginx',
25 date: 'Wed, 19 Aug 2015 14:12:21 GMT',
26 'content-type': 'text/plain',
27 'transfer-encoding': 'chunked',
28 connection: 'close',
29 status: '200 OK',
30 etag: 'W/"079e2a69978805f09ba55d6f6b3705f2"',
31 'cache-control': 'max-age=0, private, must-revalidate',
32 'x-request-id': 'daffad5d-cdff-4f23-bd2d-aec209109619',
33 'x-runtime': '0.013665',
34 'content-encoding': 'gzip'
35 });
36
37 //--------------------------------------------------------------------------------------
38 //Simulate a scenario where the project does not contain a strider.json
39 //For this purpose we have added another project named priproject2 with id 8
40 nock('http://localhost:80')
41 .get('/api/v3/projects/8/repository/blobs/master')
42 .query({"private_token":"zRtVsmeznn7ySatTrnrp","per_page":"100","filepath":"strider.json"})
43 .reply(404, ["1f8b0800000000000003ab56ca4d2d2e4e4c4f55b2523231305170cbcc4955f0cb2f5170cb2fcd4b51aa0500db72e71020000000"], { server: 'nginx',
44 date: 'Mon, 24 Aug 2015 06:28:17 GMT',
45 'content-type': 'application/json',
46 'transfer-encoding': 'chunked',
47 connection: 'close',
48 status: '404 Not Found',
49 'cache-control': 'no-cache',
50 'x-request-id': '9e221d4c-9109-4291-929b-2e7cb1e4f057',
51 'x-runtime': '0.022119',
52 'content-encoding': 'gzip' });
53};