Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scripts/jenkins-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ module.exports = function (app) {
return res.status(400).end('Invalid payload')
}

if (!isRelatedToPullRequest(req.body.ref)) {
return res.status(400).end('Will only push builds related to pull requests')
}

if (!enabledRepos.includes(repo)) {
return res.status(400).end('Invalid repository')
}
Expand Down
19 changes: 18 additions & 1 deletion test/integration/push-jenkins-update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ tap.test('Responds with 400 / "Bad request" when incoming request has invalid pa
})
})

tap.test('Responds with 400 / "Bad request" when incoming request is not related to a pull request', (t) => {
tap.test('Responds with 400 / "Bad request" when build started status update is not related to a pull request', (t) => {
const fixture = readFixture('jenkins-staging-failure-payload.json')

// don't care about the results, just want to prevent any HTTP request ever being made
Expand All @@ -132,6 +132,23 @@ tap.test('Responds with 400 / "Bad request" when incoming request is not related
})
})

tap.test('Responds with 400 / "Bad request" when build ended status update is not related to a pull request', (t) => {
const fixture = readFixture('jenkins-staging-failure-payload.json')

// don't care about the results, just want to prevent any HTTP request ever being made
nock('https://api.github.com')

t.plan(1)

supertest(app)
.post('/node/jenkins/end')
.send(fixture)
.expect(400, 'Will only push builds related to pull requests')
.end((err, res) => {
t.equal(err, null)
})
})

tap.test('Responds with 400 / "Bad request" when incoming providing invalid repository name', (t) => {
const fixture = readFixture('pending-payload.json')

Expand Down