diff --git a/README.md b/README.md index a91f16151..090bf778a 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ $ broker init github --verbose for Bitbucket Server use: ```bash -$ broker init bitbucket --verbose +$ broker init bitbucket-server --verbose ``` This will generate two new files: `accept.json` and `.env`. If the files already exist in the current working directory, the `init` command will fail and not overwrite your local copies. diff --git a/client-templates/bitbucket/.env.sample b/client-templates/bitbucket-server/.env.sample similarity index 100% rename from client-templates/bitbucket/.env.sample rename to client-templates/bitbucket-server/.env.sample diff --git a/client-templates/bitbucket/accept.json.sample b/client-templates/bitbucket-server/accept.json.sample similarity index 83% rename from client-templates/bitbucket/accept.json.sample rename to client-templates/bitbucket-server/accept.json.sample index d30506fb9..f9f59e499 100644 --- a/client-templates/bitbucket/accept.json.sample +++ b/client-templates/bitbucket-server/accept.json.sample @@ -16,25 +16,25 @@ { "//": "used to determine the full dependency tree", "method": "GET", - "path": "/projects/:project/repos/:repo/browse/package.json", + "path": "/projects/:project/repos/:repo/browse*/package.json", "origin": "https://${BITBUCKET_USERNAME}:${BITBUCKET_PASSWORD}@${BITBUCKET_API}" }, { "//": "used to determine the full dependency tree", "method": "GET", - "path": "/projects/:project/repos/:repo/browse/Gemfile.lock", + "path": "/projects/:project/repos/:repo/browse*/Gemfile.lock", "origin": "https://${BITBUCKET_USERNAME}:${BITBUCKET_PASSWORD}@${BITBUCKET_API}" }, { "//": "used to determine the full dependency tree", "method": "GET", - "path": "/projects/:project/repos/:repo/browse/Gemfile", + "path": "/projects/:project/repos/:repo/browse*/Gemfile", "origin": "https://${BITBUCKET_USERNAME}:${BITBUCKET_PASSWORD}@${BITBUCKET_API}" }, { "//": "used to determine the full dependency tree", "method": "GET", - "path": "/projects/:project/repos/:repo/browse/pom.xml ", + "path": "/projects/:project/repos/:repo/browse*/pom.xml", "origin": "https://${BITBUCKET_USERNAME}:${BITBUCKET_PASSWORD}@${BITBUCKET_API}" }, { diff --git a/lib/log.js b/lib/log.js index 9537bda12..cd3bf0b7a 100644 --- a/lib/log.js +++ b/lib/log.js @@ -18,6 +18,10 @@ function sanitise(raw) { raw = raw.replace(new RegExp(config.GITHUB_TOKEN, 'igm'), 'GITHUB_TOKEN'); } + if (config.BITBUCKET_USERNAME) { + raw = raw.replace(new RegExp(config.BITBUCKET_USERNAME, 'igm'), 'BITBUCKET_USERNAME'); + } + if (config.BITBUCKET_PASSWORD) { raw = raw.replace(new RegExp(config.BITBUCKET_PASSWORD, 'igm'), 'BITBUCKET_PASSWORD'); } diff --git a/test/functional/init.test.js b/test/functional/init.test.js index f0337316d..a57ee4342 100644 --- a/test/functional/init.test.js +++ b/test/functional/init.test.js @@ -34,7 +34,7 @@ test('init creates files from specified bitbucket', t => { if (err) { throw err; } process.chdir(path); - init({_: ['bitbucket']}) + init({_: ['bitbucket-server']}) .then(() => Promise.all([ fs.stat('.env'), fs.stat('accept.json'), diff --git a/test/functional/server-client.test.js b/test/functional/server-client.test.js index 01ae1bd38..9bdff9fc0 100644 --- a/test/functional/server-client.test.js +++ b/test/functional/server-client.test.js @@ -87,7 +87,7 @@ test('proxy requests originating from behind the broker server', t => { t.same(res.body, swappedBody, 'body brokered'); t.end(); }); - }) + }); // the filtering happens in the broker client t.test('block request for non-whitelisted url', t => { @@ -165,6 +165,23 @@ test('proxy requests originating from behind the broker server', t => { }); }); + t.test('content-length is not set when using chunked http', t => { + const url = `http://localhost:${serverPort}/broker/${token}/echo-headers`; + request({ url, method: 'get', + headers: [{'Transfer-Encoding': 'chunked'}] }, (err, res) => { + t.notOk(res.headers['Content-Length'], 'no content-length header'); + t.end(); + }); + }); + + t.test('content-length is set without chunked http', t => { + const url = `http://localhost:${serverPort}/broker/${token}/echo-headers`; + request({ url, method: 'get' }, (err, res) => { + t.ok(res.headers['Content-Length'], 'found content-length header'); + t.end(); + }); + }); + t.test('clean up', t => { client.close(); setTimeout(() => {