Skip to content

Commit 5e32384

Browse files
committed
test(fuzz): blockForAuth action
1 parent ffe1015 commit 5e32384

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/processors/blockForAuth.test.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const fc = require('fast-check');
12
const chai = require('chai');
23
const sinon = require('sinon');
34
const proxyquire = require('proxyquire').noCallThru();
@@ -93,4 +94,47 @@ describe('blockForAuth', () => {
9394
expect(message).to.include('/push/push@special#chars!');
9495
});
9596
});
97+
98+
describe.only('fuzzing', () => {
99+
it('should handle all possible characters in action ID', () => {
100+
fc.assert(
101+
fc.property(fc.string(), (actionId) => {
102+
action.id = actionId;
103+
exec(req, action);
104+
})
105+
);
106+
});
107+
108+
it('should create a step with correct parameters regardless of action ID', () => {
109+
fc.assert(
110+
fc.asyncProperty(fc.string(), async (actionId) => {
111+
action.id = actionId;
112+
113+
const freshStepInstance = new Step('temp');
114+
const setAsyncBlockStub = sinon.stub(freshStepInstance, 'setAsyncBlock');
115+
116+
const StepSpyLocal = sinon.stub().returns(freshStepInstance);
117+
const getServiceUIURLStubLocal = sinon.stub().returns('http://localhost:8080');
118+
119+
const blockForAuth = proxyquire('../../src/proxy/processors/push-action/blockForAuth', {
120+
'../../../service/urls': { getServiceUIURL: getServiceUIURLStubLocal },
121+
'../../actions': { Step: StepSpyLocal }
122+
});
123+
124+
const result = await blockForAuth.exec(req, action);
125+
126+
expect(StepSpyLocal.calledOnce).to.be.true;
127+
expect(StepSpyLocal.calledWithExactly('authBlock')).to.be.true;
128+
expect(setAsyncBlockStub.calledOnce).to.be.true;
129+
130+
const message = setAsyncBlockStub.firstCall.args[0];
131+
expect(message).to.include(`http://localhost:8080/dashboard/push/${actionId}`);
132+
expect(message).to.include('\x1B[32mGitProxy has received your push ✅\x1B[0m');
133+
expect(message).to.include(`\x1B[34mhttp://localhost:8080/dashboard/push/${actionId}\x1B[0m`);
134+
expect(message).to.include('🔗 Shareable Link');
135+
expect(result).to.equal(action);
136+
})
137+
);
138+
});
139+
});
96140
});

0 commit comments

Comments
 (0)