Skip to content

Commit 58a17a2

Browse files
committed
test(fuzz): checkUserPushPermissions
1 parent a7174c7 commit 58a17a2

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

test/processors/checkCommitMessages.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ describe('checkCommitMessages', () => {
180180
'fuzz/repo'
181181
);
182182
fuzzAction.commitData = Array.isArray(fuzzedCommits) ? fuzzedCommits : [];
183-
183+
184184
const result = await exec({}, fuzzAction);
185-
185+
186186
expect(result).to.have.property('steps');
187187
expect(result.steps[0]).to.have.property('error').that.is.a('boolean');
188188
}

test/processors/checkUserPushPermission.test.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
const chai = require('chai');
22
const sinon = require('sinon');
33
const proxyquire = require('proxyquire');
4+
const fc = require('fast-check');
45
const { Action, Step } = require('../../src/proxy/actions');
56

67
chai.should();
78
const expect = chai.expect;
89

9-
describe('checkUserPushPermission', () => {
10+
describe.only('checkUserPushPermission', () => {
1011
let exec;
1112
let getUsersStub;
1213
let isUserPushAllowedStub;
@@ -98,5 +99,26 @@ describe('checkUserPushPermission', () => {
9899
expect(result.steps[0].error).to.be.true;
99100
expect(logStub.calledWith('Users for this git account: [{"username":"user1","gitAccount":"git-user"},{"username":"user2","gitAccount":"git-user"}]')).to.be.true;
100101
});
102+
103+
describe('fuzzing', () => {
104+
it('should not crash on arbitrary getUsers return values (fuzzing)', async () => {
105+
const userList = fc.sample(
106+
fc.array(
107+
fc.record({
108+
username: fc.string(),
109+
gitAccount: fc.string()
110+
}),
111+
{ maxLength: 5 }
112+
),
113+
1
114+
)[0];
115+
getUsersStub.resolves(userList);
116+
117+
const result = await exec(req, action);
118+
119+
expect(result.steps).to.have.lengthOf(1);
120+
expect(result.steps[0].error).to.be.true;
121+
});
122+
});
101123
});
102124
});

0 commit comments

Comments
 (0)