Skip to content

Commit

Permalink
fix(tests): update tests for gitlab parser
Browse files Browse the repository at this point in the history
  • Loading branch information
geraintwhite committed Sep 20, 2017
1 parent 83ea9e3 commit e6f5b9a
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions test/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('BEGIN GITHUB PAYLOAD TESTS', function (t) { t.end(); });
test('pass string as payload', function (t) {

var payload = 'asdf';
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
t.equal(data.err, 'Error: Invalid payload', 'correct server response');
Expand All @@ -28,7 +28,7 @@ test('pass string as payload', function (t) {
test('pass invalid JSON object', function (t) {

var payload = JSON.stringify({ property: 'false' });
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
t.equal(data.err, 'Error: Invalid data', 'correct server response');
Expand All @@ -42,7 +42,7 @@ test('pass valid JSON object but invalid signature', function (t) {

t.test('valid secret but invalid payload', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs' });
options.headers = {'x-hub-signature': gen_sig(config.github_secret, 'asdf')};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, 'asdf'), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.err, 'Error: Cannot verify payload signature', 'correct server response');
Expand All @@ -53,7 +53,7 @@ test('pass valid JSON object but invalid signature', function (t) {

t.test('valid payload but invalid secret', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs' });
options.headers = {'x-hub-signature': gen_sig('asdf', payload)};
options.headers = {'x-hub-signature': gen_sig('asdf', payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.err, 'Error: Cannot verify payload signature', 'correct server response');
Expand All @@ -68,7 +68,7 @@ test('pass valid JSON object and valid signature', function (t) {

t.test('valid data but invalid branch ref', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs' });
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.err, 'Branches do not match', 'correct server response');
Expand All @@ -79,7 +79,7 @@ test('pass valid JSON object and valid signature', function (t) {

t.test('valid data and valid branch ref', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs/heads/master' });
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.msg, 'Build queued', 'correct server response');
Expand All @@ -95,7 +95,7 @@ test('pass custom branch name', function (t) {
t.test('valid branch in path but invalid branch ref', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs' });
options.query = {branch: 'dev'};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.err, 'Branches do not match', 'correct server response');
Expand All @@ -107,7 +107,7 @@ test('pass custom branch name', function (t) {
t.test('valid branch in path and valid branch ref', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs/heads/dev' });
options.query = {branch: 'dev'};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.msg, 'Build queued', 'correct server response');
Expand All @@ -123,7 +123,7 @@ test('pass semver flag', function (t) {
t.test('semver flag passed but invalid branch ref', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs/heads/master' });
options.query = {semver: true};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.err, 'Branches do not match', 'correct server response');
Expand All @@ -135,7 +135,7 @@ test('pass semver flag', function (t) {
t.test('semver flag passed and valid branch ref', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs/heads/v1.2.3' });
options.query = {semver: true};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.msg, 'Build queued', 'correct server response');
Expand All @@ -147,7 +147,7 @@ test('pass semver flag', function (t) {
t.test('semver flag and branch name passed and valid branch ref', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs/heads/v1.2.3' });
options.query = {semver: true, branch: 'master'};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.msg, 'Build queued', 'correct server response');
Expand All @@ -159,7 +159,7 @@ test('pass semver flag', function (t) {
t.test('semver flag and branch name passed and valid branch ref but not semver', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs/heads/master' });
options.query = {semver: true, branch: 'master'};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.msg, 'Build queued', 'correct server response');
Expand All @@ -171,7 +171,7 @@ test('pass semver flag', function (t) {
t.test('semver flag and branch name passed but invalid branch ref', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs/heads/master' });
options.query = {semver: true, branch: 'dev'};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.err, 'Branches do not match', 'correct server response');
Expand All @@ -187,7 +187,7 @@ test('pass url_secret', function (t) {
t.test('pass url_secret in query string but not in config', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs/heads/master' });
options.query = {secret: 'password123'};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};

request(payload, function (res, data) {
st.equal(data.msg, 'Build queued', 'correct server response');
Expand All @@ -199,7 +199,7 @@ test('pass url_secret', function (t) {
t.test('pass same url_secret in query string as in config', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs/heads/master' });
options.query = {secret: 'password123'};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};
config.url_secret = 'password123';

request(payload, function (res, data) {
Expand All @@ -212,7 +212,7 @@ test('pass url_secret', function (t) {
t.test('url_secret in config but not in query string', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs/heads/master' });
options.query = {};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};
config.url_secret = 'password123';

request(payload, function (res, data) {
Expand All @@ -225,7 +225,7 @@ test('pass url_secret', function (t) {
t.test('different url_secret in query string than in config', function (st) {
var payload = JSON.stringify({ repository: { full_name: 'repo' }, ref: 'refs/heads/master' });
options.query = {secret: 'bogus'};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload)};
options.headers = {'x-hub-signature': gen_sig(config.github_secret, payload), 'x-github-delivery': 1};
config.url_secret = 'password123';

request(payload, function (res, data) {
Expand Down

0 comments on commit e6f5b9a

Please sign in to comment.