Skip to content

Commit

Permalink
test: change template to BB server and added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dar Malovani committed May 22, 2017
1 parent e3afd01 commit f5d6a56
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
},
{
Expand Down
4 changes: 4 additions & 0 deletions lib/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion test/functional/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
19 changes: 18 additions & 1 deletion test/functional/server-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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(() => {
Expand Down

0 comments on commit f5d6a56

Please sign in to comment.